sdkgo

package module
v0.33.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 40 Imported by: 2

README

Topicus KeyHub SDK for Go

PkgGoDev

Note: The version number of the SDK must match the version of your Topicus KeyHub installation. An older version of the SDK might work on a newer version of Topicus KeyHub via the provided backwards compatibility layer, but a newer of the SDK will not work on an older version of Topicus KeyHub.

Note: The GO SDK is current considered in alpha status. It's API might change in future version, it is largely untested and at the moment only supports the client credentials grant.

1. Installation

go get github.com/topicuskeyhub/sdk-go

2. Getting started

2.1 Create a client application in Topicus KeyHub

Register a OAuth 2.0 client application in Topicus KeyHub as described in section 16.1 of the manual. Section 16.5 describes the permissions you can assign to this application.

2.2 Create a KeyHubClient object and make an API call
package main

import (
	"context"
	"log"
	"net/http"

	keyhub "github.com/topicuskeyhub/sdk-go"
)

func main() {
	issuer := "<the issuer of your Topicus KeyHub installation>"
	clientid := "<the client id of your application registration>"
	clientsecret := "<the client sercret of your application registration>"

	adapter, err := keyhub.NewKeyHubRequestAdapter(http.DefaultClient, issuer, clientid, clientsecret)
	if err != nil {
		log.Fatalf("Cannot create request adapter: %v\n", err)
	}

	client := keyhub.NewKeyHubClient(adapter)
	me, err := client.Client().Me().Get(context.Background(), nil)
	if err != nil {
		log.Fatalf("Error getting /client/me: %v\n", err)
	}
	log.Printf("me: %s", *me.GetName())
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextClient added in v0.30.0

func ContextClient(ctx context.Context) *nethttp.Client

func DeviceAuth added in v0.30.0

copied from https://github.com/golang/oauth2/blob/master/deviceauth.go until https://github.com/golang/oauth2/issues/685 is fixed DeviceAuth returns a device auth struct which contains a device code and authorization information provided for users to enter on another device.

func NewKeyHubRequestAdapter

func NewKeyHubRequestAdapter(client *nethttp.Client, issuer string, clientID string, clientSecret string) (*http.NetHttpRequestAdapter, error)

func NewKeyHubRequestAdapterForDeviceCode added in v0.30.0

func NewKeyHubRequestAdapterForDeviceCode(client *nethttp.Client, issuer string, clientID string, clientSecret string, scopes []string) (*http.NetHttpRequestAdapter, error)

func OpenAPISpec added in v0.28.1

func OpenAPISpec() []byte

Types

type KeyHubAccessTokenProvider

type KeyHubAccessTokenProvider struct {
	// contains filtered or unexported fields
}

func NewKeyHubAccessTokenProvider

func NewKeyHubAccessTokenProvider(tokenSource *oauth2.TokenSource) *KeyHubAccessTokenProvider

func (*KeyHubAccessTokenProvider) GetAllowedHostsValidator

func (p *KeyHubAccessTokenProvider) GetAllowedHostsValidator() *auth.AllowedHostsValidator

func (*KeyHubAccessTokenProvider) GetAuthorizationToken

func (p *KeyHubAccessTokenProvider) GetAuthorizationToken(ctx context.Context, url *url.URL, additionalAuthenticationContext map[string]interface{}) (string, error)

func (*KeyHubAccessTokenProvider) Intercept

func (p *KeyHubAccessTokenProvider) Intercept(pipeline http.Pipeline, middlewareIndex int, req *nethttp.Request) (*nethttp.Response, error)

type KeyHubClient

KeyHubClient the main entry point of the SDK, exposes the configuration and the fluent API.

func NewKeyHubClient

NewKeyHubClient instantiates a new KeyHubClient and sets the default values.

func (*KeyHubClient) Account

Account the account property returns a *AccountRequestBuilder when successful

func (*KeyHubClient) Audit

Audit the audit property returns a *AuditRequestBuilder when successful

func (*KeyHubClient) Certificate

Certificate the certificate property returns a *CertificateRequestBuilder when successful

func (*KeyHubClient) Client

Client the client property returns a *ClientRequestBuilder when successful

func (*KeyHubClient) Deletedvaultholder

Deletedvaultholder the deletedvaultholder property returns a *DeletedvaultholderRequestBuilder when successful

func (*KeyHubClient) Directory

Directory the directory property returns a *DirectoryRequestBuilder when successful

func (*KeyHubClient) Export added in v0.29.0

Export the export property returns a *ExportRequestBuilder when successful

func (*KeyHubClient) Group

Group the group property returns a *GroupRequestBuilder when successful

func (*KeyHubClient) Groupclassification

Groupclassification the groupclassification property returns a *GroupclassificationRequestBuilder when successful

func (*KeyHubClient) Groupclient

Groupclient the groupclient property returns a *GroupclientRequestBuilder when successful

func (*KeyHubClient) Groupfolder

Groupfolder the groupfolder property returns a *GroupfolderRequestBuilder when successful

func (*KeyHubClient) Info

Info the info property returns a *InfoRequestBuilder when successful

func (*KeyHubClient) Launchpadtile

Launchpadtile the launchpadtile property returns a *LaunchpadtileRequestBuilder when successful

func (*KeyHubClient) Numberseq

Numberseq the numberseq property returns a *NumberseqRequestBuilder when successful

func (*KeyHubClient) Organizationalunit

Organizationalunit the organizationalunit property returns a *OrganizationalunitRequestBuilder when successful

func (*KeyHubClient) Profile added in v0.33.0

Profile the profile property returns a *ProfileRequestBuilder when successful

func (*KeyHubClient) Provisioninggroup

Provisioninggroup the provisioninggroup property returns a *ProvisioninggroupRequestBuilder when successful

func (*KeyHubClient) Request

Request the request property returns a *RequestRequestBuilder when successful

func (*KeyHubClient) Serviceaccount

Serviceaccount the serviceaccount property returns a *ServiceaccountRequestBuilder when successful

func (*KeyHubClient) System

System the system property returns a *SystemRequestBuilder when successful

func (*KeyHubClient) Vaultrecord

Vaultrecord the vaultrecord property returns a *VaultrecordRequestBuilder when successful

func (*KeyHubClient) Webhook

Webhook the webhook property returns a *WebhookRequestBuilder when successful

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL