identity

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package identity implements the IndyKite Identity Service API Client.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseUUID

func ParseUUID(raw string) (uuid.UUID, error)

ParseUUID parse the raw input string and check if it's a RFC4122 variant UUID.

Types

type Client

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

func NewClient

func NewClient(ctx context.Context, opts ...api.ClientOption) (*Client, error)

NewClient creates a new Identity Management gRPC Client.

Example (Default)

This example demonstrates how to create a new Identity Client.

package main

import (
	"context"
	"log"

	"github.com/indykite/indykite-sdk-go/identity"
)

func main() {
	client, err := identity.NewClient(context.Background())
	if err != nil {
		log.Fatalf("failed to create client %v", err)
	}
	_ = client.Close()
}
Output:

Example (Options)

This example demonstrates how to create a new Identity Client.

package main

import (
	"context"
	"log"

	api "github.com/indykite/indykite-sdk-go/grpc"
	"github.com/indykite/indykite-sdk-go/identity"
)

func main() {
	client, err := identity.NewClient(context.Background(),
		api.WithCredentialsJSON([]byte(`{}`)))
	if err != nil {
		log.Fatalf("failed to create client %v", err)
	}
	_ = client.Close()
}
Output:

func NewTestClient

func NewTestClient(client identitypb.IdentityManagementAPIClient) (*Client, error)

NewTestClient creates a new Config Management gRPC Client.

func (*Client) CancelInvitation

func (c *Client) CancelInvitation(ctx context.Context, referenceID string, opts ...grpc.CallOption) error

CancelInvitation revokes a pending invitation identified by referenceID.

func (*Client) CheckInvitationState

func (c *Client) CheckInvitationState(ctx context.Context,
	referenceID string, opts ...grpc.CallOption) (*identitypb.CheckInvitationStateResponse, error)

CheckInvitationState checks the status of invitation.

func (*Client) CheckInvitationToke

func (c *Client) CheckInvitationToke(ctx context.Context,
	invitationToken string, opts ...grpc.CallOption) (*identitypb.CheckInvitationStateResponse, error)

CheckInvitationToke checks the status of invitation.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the API service. The user should invoke this when the client is no longer required.

func (*Client) CreateConsent

func (*Client) CreateEmailInvitation

func (c *Client) CreateEmailInvitation(ctx context.Context,
	invitee string, tenantID string, referenceID string,
	expireTime, inviteAtTime time.Time, messageAttributes map[string]any,
	opts ...grpc.CallOption) error

CreateEmailInvitation receive all properties for digital twin.

Example

This example demonstrates the use of an identity client to create a new invitation and notify invitee via email.

package main

import (
	"context"
	"log"
	"time"

	"github.com/indykite/indykite-sdk-go/identity"
)

func main() {
	client, err := identity.NewClient(context.Background())
	if err != nil {
		log.Fatalf("failed to create client %v", err)
	}
	defer func() {
		_ = client.Close()
	}()

	err = client.CreateEmailInvitation(context.Background(),
		"test@example.com",
		"696e6479-6b69-4465-8000-030100000002",
		"my-reference",
		time.Now().AddDate(0, 0, 7), time.Now(),
		map[string]any{
			"lang": "en",
		})
	if err != nil {
		log.Printf("failed to invoke operation on IndyKite Client %v", err)
	}
}
Output:

func (*Client) EnrichToken

func (*Client) IntrospectToken

func (c *Client) IntrospectToken(ctx context.Context,
	token string, opts ...grpc.CallOption) (*identitypb.TokenIntrospectResponse, error)

IntrospectToken function validates the token and returns information about it.

This is a protected operation and it can be accessed only with valid agent credentials!

Example

This example demonstrates the use of a identity client to introspect the access_token from the request.

package main

import (
	"context"
	"log"

	"github.com/grpc-ecosystem/go-grpc-middleware/v2/interceptors/retry"
	"google.golang.org/protobuf/encoding/protojson"

	"github.com/indykite/indykite-sdk-go/identity"
)

func main() {
	client, err := identity.NewClient(context.Background())
	if err != nil {
		log.Fatalf("failed to create client %v", err)
	}
	defer func() {
		_ = client.Close()
	}()

	/* #nosec */
	token := "JWT TOKEN HERE"
	tenant, err := client.IntrospectToken(context.Background(), token, retry.WithMax(2))
	if err != nil {
		log.Fatalf("failed to invoke operation on IndyKite Client %v", err)
	}
	json := protojson.MarshalOptions{
		Multiline: true,
	}
	println(json.Format(tenant))
}
Output:

func (*Client) ResendInvitation

func (c *Client) ResendInvitation(ctx context.Context, referenceID string, opts ...grpc.CallOption) error

ResendInvitation send invitation token to invitee.

func (*Client) RevokeConsent

Jump to

Keyboard shortcuts

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