identity

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2024 License: Apache-2.0 Imports: 15 Imported by: 2

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) DeleteDigitalTwin

func (c *Client) DeleteDigitalTwin(ctx context.Context,
	digitalTwin *identitypb.DigitalTwin,
	opts ...grpc.CallOption,
) (*identitypb.DigitalTwin, error)

DeleteDigitalTwin deletes the digital twin.

func (*Client) DeleteDigitalTwinByToken

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

DeleteDigitalTwinByToken deletes the digital twin.

func (*Client) EnrichToken

func (*Client) GetDigitalTwin

func (c *Client) GetDigitalTwin(ctx context.Context,
	digitalTwin *identitypb.DigitalTwin,
	properties []*identitypb.PropertyMask,
	opts ...grpc.CallOption,
) (*identitypb.GetDigitalTwinResponse, error)

GetDigitalTwin receive all properties for given digital twin. Deprecated: Use the equivalent function in the knowledge package.

func (*Client) GetDigitalTwinByToken

func (c *Client) GetDigitalTwinByToken(ctx context.Context,
	token string,
	properties []*identitypb.PropertyMask,
	opts ...grpc.CallOption,
) (*identitypb.GetDigitalTwinResponse, error)

GetDigitalTwinByToken receive all properties for digital twin. Deprecated: Use the equivalent function in the knowledge package.

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) PatchDigitalTwin

func (c *Client) PatchDigitalTwin(ctx context.Context,
	digitalTwin *identitypb.DigitalTwin,
	operations []*identitypb.PropertyBatchOperation,
	forceDelete bool,
	opts ...grpc.CallOption,
) ([]*identitypb.BatchOperationResult, error)

PatchDigitalTwin update properties for given digital twin.

func (*Client) PatchDigitalTwinByToken

func (c *Client) PatchDigitalTwinByToken(ctx context.Context,
	token string,
	operations []*identitypb.PropertyBatchOperation,
	forceDelete bool,
	opts ...grpc.CallOption,
) ([]*identitypb.BatchOperationResult, error)

PatchDigitalTwinByToken update properties for digital twin.

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