staxsdk

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2023 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//  TaskStarted indicates an asynchronous task has started.
	TaskStarted = models.OperationStatus("STARTED")

	// TaskSucceeded indicates an asynchronous task completed successfully.
	TaskSucceeded = models.OperationStatus("SUCCEEDED")

	// TaskFailed indicates an asynchronous task failed.
	TaskFailed = models.OperationStatus("FAILED")
)

Variables

View Source
var (
	//  ErrAuthSessionEmpty is returned when an API call is made without first calling Authenticate.
	ErrAuthSessionEmpty = errors.New("auth session is empty, please call Authenticate to login")

	// ErrMissingAPIToken is returned when the client is constructed without an API token.
	ErrMissingAPIToken = errors.New("missing required api token, must provide WithAPIToken")

	//  ErrMissingTaskID is returned when MonitorTask is called without a task ID.
	ErrMissingTaskID = errors.New("missing task id, provided value is empty")

	//  ErrMissingTaskCallbackFunc is returned when MonitorTask is called without a callback function.
	ErrMissingTaskCallbackFunc = errors.New("missing task monitoring callback function")

	ErrInvalidInstallation = errors.New("invalid installation, url is unknown")
)

Functions

This section is empty.

Types

type AuthFn

type AuthFn func(ctx context.Context, client client.ClientWithResponsesInterface, apiToken *auth.APIToken) (*auth.AuthResponse, error)
AuthFn is the authentication function used to authenticate a client.

It takes in a context, client client and auth.APIToken. It returns an auth.AuthResponse containing the AWS SDK config with credentials and Cognito IDP tokens.

type Client

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

func NewClient

func NewClient(ctx context.Context, apiToken *auth.APIToken, opts ...ClientOption) (*Client, error)
NewClient creates a new STAX API client.

apiToken: The API token to use for authentication. opts: Optional configuration for the client.

Returns: - client: The STAX API client. - err: Any error that occurred.

The client can be configured using the opts. The available options are:

- WithInstallation: Sets the STAX installation used by the client. Options are "dev", "test", "au1", "eu1" or "us1". - WithEndpointURL: Sets the endpoint URL for the STAX API. - WithAuthRequestSigner: Sets the request signer used to sign API Gateway requests. - WithUserAgentVersion: Sets the user agent version used in requests. - WithHttpClient: Sets the HTTP client used to make requests.

func (*Client) APITokenCreate added in v0.0.8

func (*Client) APITokenRead added in v0.0.8

func (cl *Client) APITokenRead(ctx context.Context, apiTokenIDs []string) (*client.TeamsReadApiTokensResp, error)

func (*Client) APITokenReadByID added in v0.0.8

func (cl *Client) APITokenReadByID(ctx context.Context, apiTokenID string) (*client.TeamsReadApiTokenResp, error)

func (*Client) AccountClose

func (cl *Client) AccountClose(ctx context.Context, accountID string) (*client.AccountsCloseAccountResp, error)
AccountClose closes an account in STAX.

ctx: The context to use for this request. accountID: The ID of the account to close.

Returns: - accountCloseResp: The response from the AccountsCloseAccount API call. - err: Any error that occurred.

func (*Client) AccountCreate

func (cl *Client) AccountCreate(ctx context.Context, createAccount models.AccountsCreateAccount) (*client.AccountsCreateAccountResp, error)
AccountCreate creates an account in STAX.

ctx: The context to use for this request. createAccount: The account details to create.

Returns: - createResp: The response from the AccountsCreateAccount API call. - err: Any error that occurred.

func (*Client) AccountRead

func (cl *Client) AccountRead(ctx context.Context, accountIDs []string, accountNames []string) (*client.AccountsReadAccountsResp, error)
AccountRead reads accounts from STAX.

ctx: The context to use for this request. accountIDs: Optional list of account IDs to filter by. accountNames: Optional list of account names to filter by.

Returns: - readAccountsRes: The response from the AccountsReadAccounts API call. - err: Any error that occurred.

func (*Client) AccountReadByID added in v0.0.4

func (cl *Client) AccountReadByID(ctx context.Context, accountID string) (*client.AccountsReadAccountResp, error)
AccountReadByID reads an account by ID from STAX.

ctx: The context to use for this request. accountID: The ID of the account to read.

Returns: - readAccountRes: The response from the AccountsReadAccount API call. - err: Any error that occurred.

func (*Client) AccountTypeCreate

func (cl *Client) AccountTypeCreate(ctx context.Context, name string) (*client.AccountsCreateAccountTypeResp, error)
AccountTypeCreate creates an account type in STAX.

ctx: The context to use for this request. name: The name of the account type to create.

Returns: - accountTypeResp: The response from the AccountsCreateAccountType API call. - err: Any error that occurred.

func (*Client) AccountTypeDelete

func (cl *Client) AccountTypeDelete(ctx context.Context, accountTypeID string) (*client.AccountsDeleteAccountTypeResp, error)
AccountTypeDelete deletes an account type in STAX.

ctx: The context to use for this request. accountTypeID: The ID of the account type to delete.

Returns: - accountTypeDeleteResp: The response from the AccountsDeleteAccountType API call. - err: Any error that occurred.

func (*Client) AccountTypeRead

func (cl *Client) AccountTypeRead(ctx context.Context, accountTypeIDs []string) (*client.AccountsReadAccountTypesResp, error)
AccountTypeRead reads account types from STAX.

ctx: The context to use for this request. accountTypeIDs: A list of account type IDs to filter the results. If empty, all account types will be returned.

Returns: - accountTypesResp: The response from the AccountsReadAccountTypes API call. - err: Any error that occurred.

func (*Client) AccountTypeReadById added in v0.0.4

func (cl *Client) AccountTypeReadById(ctx context.Context, accountTypeID string) (*client.AccountsReadAccountTypeResp, error)
AccountTypeReadById reads an account type by ID.

ctx: The context for the request accountTypeID: The ID of the account type to read

It returns:

- *client.AccountsReadAccountTypeResp: The response containing the requested account type - error: Any error that occurred while making the request.

func (*Client) AccountTypeUpdate

func (cl *Client) AccountTypeUpdate(ctx context.Context, accountTypeID, name string) (*client.AccountsUpdateAccountTypeResp, error)
AccountTypeUpdate updates an account type in STAX.

ctx: The context to use for this request. accountTypeID: The ID of the account type to update. name: The new name of the account type.

Returns: - accountTypeUpdateResp: The response from the AccountsUpdateAccountType API call. - err: Any error that occurred.

func (*Client) AccountUpdate

func (cl *Client) AccountUpdate(ctx context.Context, accountID string, updateAccount models.AccountsUpdateAccount) (*client.AccountsUpdateAccountResp, error)
AccountUpdate updates an account in STAX.

ctx: The context to use for this request. accountID: The ID of the account to update. updateAccount: The account update parameters.

Returns: - accountUpdateRes: The response from the AccountsUpdateAccount API call. - err: Any error that occurred.

func (*Client) ApiTokenDelete added in v0.0.8

func (cl *Client) ApiTokenDelete(ctx context.Context, apiTokenID string) (*client.TeamsDeleteApiTokenResp, error)

func (*Client) ApiTokenUpdate added in v0.0.8

func (cl *Client) ApiTokenUpdate(ctx context.Context, apiTokenID string, params models.TeamsUpdateApiToken) (*client.TeamsUpdateApiTokenResp, error)

func (*Client) Authenticate

func (cl *Client) Authenticate(ctx context.Context) error

func (*Client) GroupAssignUsers added in v0.0.7

func (cl *Client) GroupAssignUsers(ctx context.Context, groupID string, addMemberUserIDs []string, removeMemberUserIDs []string) (*client.TeamsUpdateGroupMembersResp, error)

func (*Client) GroupCreate added in v0.0.4

func (cl *Client) GroupCreate(ctx context.Context, name string) (*client.TeamsCreateGroupResp, error)

func (*Client) GroupDelete added in v0.0.4

func (cl *Client) GroupDelete(ctx context.Context, groupID string) (*client.TeamsDeleteGroupResp, error)

func (*Client) GroupRead

func (cl *Client) GroupRead(ctx context.Context, groupIDs []string) (*client.TeamsReadGroupsResp, error)
GroupRead reads groups from STAX.

ctx: The context to use for this request. groupIDs: A list of group IDs to filter the response by. Optional.

Returns: - teamsReadResp: The response from the TeamsReadGroups API call. - err: Any error that occurred.

func (*Client) GroupReadByID added in v0.0.4

func (cl *Client) GroupReadByID(ctx context.Context, groupID string) (*client.TeamsReadGroupResp, error)
GroupReadByID reads a group by ID from STAX.

ctx is the context to use for this request. groupID is the ID of the group to read.

Returns: - teamsReadResp: The response from the TeamsReadGroup API call. - err: Any error that occurred.

func (*Client) GroupUpdate added in v0.0.4

func (cl *Client) GroupUpdate(ctx context.Context, groupID, name string) (*client.TeamsUpdateGroupResp, error)

func (*Client) MonitorTask

func (cl *Client) MonitorTask(ctx context.Context, taskID string, callbackFunc func(context.Context, *client.TasksReadTaskResp) bool) (*client.TasksReadTaskResp, error)
MonitorTask polls an asynchronous task and returns the final task response.

It uses a TaskPoller to poll the TasksReadTask API endpoint for the status of the task. It will continue polling until the task completes (succeeds or fails) or a timeout occurs. If the task fails or times out, an error is returned. Otherwise, the final client.TasksReadTaskResp is returned. taskID is the ID of the asynchronous task to monitor. callbackFunc is a function that will be called after each poll to determine whether polling should continue. It is passed the latest client.TasksReadTaskResp and should return true to continue polling or false to stop.

func (*Client) PermissionSetAssignmentCreate added in v0.0.5

func (*Client) PermissionSetAssignmentDelete added in v0.0.5

func (cl *Client) PermissionSetAssignmentDelete(ctx context.Context, permissionSetId string, assignmentId string) (*permissionssetsclient.DeletePermissionSetAssignmentResponse, error)

func (*Client) PermissionSetAssignmentList added in v0.0.5

func (*Client) PermissionSetsDelete added in v0.0.5

func (cl *Client) PermissionSetsDelete(ctx context.Context, permissionSetId string) (*permissionssetsclient.DeletePermissionSetResponse, error)

func (*Client) PermissionSetsReadByID added in v0.0.5

func (cl *Client) PermissionSetsReadByID(ctx context.Context, permissionSetId string) (*permissionssetsclient.GetPermissionSetResponse, error)

func (*Client) PermissionSetsUpdate added in v0.0.5

func (*Client) PublicReadConfig

func (cl *Client) PublicReadConfig(ctx context.Context) (*client.PublicReadConfigResp, error)
PublicReadConfig reads the public configuration from the STAX API.

ctx: The context to use for this request.

Returns: - publicConfigResp: The response from the PublicReadConfig API call. - err: Any error that occurred.

func (*Client) UserCreate added in v0.0.4

func (cl *Client) UserCreate(ctx context.Context, params models.TeamsCreateUser) (*client.TeamsCreateUserResp, error)

func (*Client) UserDelete added in v0.0.7

func (cl *Client) UserDelete(ctx context.Context, userID string) (*client.TeamsDeleteUserResp, error)

func (*Client) UserRead added in v0.0.7

func (cl *Client) UserRead(ctx context.Context, userIDs []string) (*client.TeamsReadUsersResp, error)

func (*Client) UserReadByID added in v0.0.7

func (cl *Client) UserReadByID(ctx context.Context, userID string) (*client.TeamsReadUserResp, error)

func (*Client) UserUpdate added in v0.0.7

func (cl *Client) UserUpdate(ctx context.Context, userID string, params models.TeamsUpdateUser) (*client.TeamsUpdateUserResp, error)

func (*Client) WorkloadCreate

func (cl *Client) WorkloadCreate(ctx context.Context, createWorkload models.WorkloadsCreateWorkload) (*client.WorkloadsCreateWorkloadResp, error)
WorkloadCreate creates a new workload in STAX.

ctx: The context to use for this request. createWorkload: The details of the workload to create.

Returns: - workloadCreateResp: The response from the WorkloadsCreateWorkload API call. - err: Any error that occurred.

func (*Client) WorkloadDelete

func (cl *Client) WorkloadDelete(ctx context.Context, workloadID string) (*client.WorkloadsDeleteWorkloadResp, error)
WorkloadDelete deletes a workload in STAX.

ctx: The context to use for this request. workloadID: The ID of the workload to delete.

Returns: - workloadDeleteResp: The response from the WorkloadsDeleteWorkload API call. - err: Any error that occurred.

func (*Client) WorkloadRead

WorkloadRead reads workloads from STAX.

ctx: The context to use for this request. params: The parameters for filtering which workloads to read.

Returns: - workloadsReadResp: The response from the WorkloadsReadWorkloads API call. - err: Any error that occurred.

type ClientInterface

type ClientInterface interface {
	// Authenticate authenticates the client and returns an error.
	Authenticate(ctx context.Context) error
	// PublicReadConfig reads the public configuration and returns a client.PublicReadConfigResp.
	PublicReadConfig(ctx context.Context) (*client.PublicReadConfigResp, error)
	// AccountCreate creates an account and returns a SyncResult containing the response and final task status.
	AccountCreate(ctx context.Context, createAccount models.AccountsCreateAccount) (*client.AccountsCreateAccountResp, error)
	// AccountReadByID reads an account by ID and returns a client.AccountsReadAccountResp.
	AccountReadByID(ctx context.Context, accountID string) (*client.AccountsReadAccountResp, error)
	// AccountRead reads accounts and returns a client.AccountsReadAccountsResp.
	AccountRead(ctx context.Context, accountIDs []string, accountNames []string) (*client.AccountsReadAccountsResp, error)
	// AccountUpdate updates an account and returns a SyncResult containing the response and final task status.
	AccountUpdate(ctx context.Context, accountID string, updateAccount models.AccountsUpdateAccount) (*client.AccountsUpdateAccountResp, error)
	// AccountClose closes an account and returns a SyncResult containing the response and final task status.
	AccountClose(ctx context.Context, accountID string) (*client.AccountsCloseAccountResp, error)
	// AccountTypeCreate creates an account type and returns a client.AccountsCreateAccountTypeResp.
	AccountTypeCreate(ctx context.Context, name string) (*client.AccountsCreateAccountTypeResp, error)
	// AccountTypeUpdate updates an account type and returns a client.AccountsUpdateAccountTypeResp.
	AccountTypeUpdate(ctx context.Context, accountTypeID, name string) (*client.AccountsUpdateAccountTypeResp, error)
	//  AccountTypeDelete deletes an account type and returns a client.AccountsDeleteAccountTypeResp.
	AccountTypeDelete(ctx context.Context, accountTypeID string) (*client.AccountsDeleteAccountTypeResp, error)
	// AccountTypeReadById reads an account type by ID and returns a client.AccountsReadAccountTypeResp.
	AccountTypeReadById(ctx context.Context, accountTypeID string) (*client.AccountsReadAccountTypeResp, error)
	// AccountTypeRead reads account types and returns a client.AccountsReadAccountTypesResp.
	AccountTypeRead(ctx context.Context, accountTypeIDs []string) (*client.AccountsReadAccountTypesResp, error)
	// WorkloadDelete deletes a workload and returns a client.WorkloadsDeleteWorkloadResp.
	WorkloadDelete(ctx context.Context, workloadID string) (*client.WorkloadsDeleteWorkloadResp, error)
	UserReadByID(ctx context.Context, userID string) (*client.TeamsReadUserResp, error)
	UserRead(ctx context.Context, userIDs []string) (*client.TeamsReadUsersResp, error)
	UserCreate(ctx context.Context, params models.TeamsCreateUser) (*client.TeamsCreateUserResp, error)
	UserUpdate(ctx context.Context, userID string, params models.TeamsUpdateUser) (*client.TeamsUpdateUserResp, error)
	UserDelete(ctx context.Context, userID string) (*client.TeamsDeleteUserResp, error)
	APITokenReadByID(ctx context.Context, userID string) (*client.TeamsReadApiTokenResp, error)
	APITokenRead(ctx context.Context, apiTokenIDs []string) (*client.TeamsReadApiTokensResp, error)
	APITokenCreate(ctx context.Context, params models.TeamsCreateApiToken) (*client.TeamsCreateApiTokenResp, error)
	ApiTokenUpdate(ctx context.Context, apiTokenID string, params models.TeamsUpdateApiToken) (*client.TeamsUpdateApiTokenResp, error)
	ApiTokenDelete(ctx context.Context, apiTokenID string) (*client.TeamsDeleteApiTokenResp, error)
	// GroupCreate create a group and returns a client.TeamsCreateGroupResp.
	GroupCreate(ctx context.Context, name string) (*client.TeamsCreateGroupResp, error)
	//  GroupUpdate updates a group and returns a client.TeamsUpdateGroupResp.
	GroupUpdate(ctx context.Context, groupID, name string) (*client.TeamsUpdateGroupResp, error)
	// GroupDelete deletes a group and returns a client.TeamsDeleteGroupResp.
	GroupDelete(ctx context.Context, groupID string) (*client.TeamsDeleteGroupResp, error)
	//  GroupReadByID reads a group by ID and returns a client.TeamsReadGroupResp.
	GroupReadByID(ctx context.Context, groupID string) (*client.TeamsReadGroupResp, error)
	//  GroupRead reads groups and returns a client.TeamsReadGroupsResp.
	GroupRead(ctx context.Context, groupIDs []string) (*client.TeamsReadGroupsResp, error)
	GroupAssignUsers(ctx context.Context, groupID string, addMemberUserIDs []string, removeMemberUserIDs []string) (*client.TeamsUpdateGroupMembersResp, error)
	//  PermissionSetsList lists permission sets and returns a permissionssetsclient.ListPermissionSetsResponse.
	PermissionSetsList(ctx context.Context, params *permissionssetsmodels.ListPermissionSetsParams) (*permissionssetsclient.ListPermissionSetsResponse, error)
	//  PermissionSetsReadByID reads a permission set by ID and returns a permissionssetsclient.GetPermissionSetResponse.
	PermissionSetsReadByID(ctx context.Context, permissionSetId string) (*permissionssetsclient.GetPermissionSetResponse, error)
	//  PermissionSetsCreate creates a permission set and returns a permissionssetsclient.CreatePermissionSetResponse.
	PermissionSetsCreate(ctx context.Context, params permissionssetsmodels.CreatePermissionSetRecord) (*permissionssetsclient.CreatePermissionSetResponse, error)
	//  PermissionSetsUpdate updates a permission set and returns a permissionssetsclient.UpdatePermissionSetResponse.
	PermissionSetsUpdate(ctx context.Context, permissionSetId string, params permissionssetsmodels.UpdatePermissionSetRecord) (*permissionssetsclient.UpdatePermissionSetResponse, error)
	//  PermissionSetsDelete deletes a permission set and returns a permissionssetsclient.DeletePermissionSetResponse.
	PermissionSetsDelete(ctx context.Context, permissionSetId string) (*permissionssetsclient.DeletePermissionSetResponse, error)
	PermissionSetAssignmentCreate(ctx context.Context, permissionSetId string, params permissionssetsmodels.CreateAssignmentsRequest) (*permissionssetsclient.CreatePermissionSetAssignmentsResponse, error)
	PermissionSetAssignmentList(ctx context.Context, permissionSetId string, params *permissionssetsmodels.ListPermissionSetAssignmentsParams) (*permissionssetsclient.ListPermissionSetAssignmentsResponse, error)
	PermissionSetAssignmentDelete(ctx context.Context, permissionSetId string, assignmentId string) (*permissionssetsclient.DeletePermissionSetAssignmentResponse, error)
	//	MonitorTask polls an asynchronous task and returns the final task response.
	MonitorTask(ctx context.Context, taskID string, callbackFunc func(context.Context, *client.TasksReadTaskResp) bool) (*client.TasksReadTaskResp, error)
	//	MonitorPermissionSetAssignments polls an asynchronous assignment update and returns the final response.
	MonitorPermissionSetAssignments(ctx context.Context, permissionSetID, assignmentID string, completionStatuses []permissionssetsmodels.AssignmentRecordStatus, params *permissionssetsmodels.ListPermissionSetAssignmentsParams, callbackFunc func(context.Context, *permissionssetsclient.ListPermissionSetAssignmentsResponse) bool) (*permissionssetsclient.ListPermissionSetAssignmentsResponse, error)
}

ClientInterface defines the interface for interacting with the Stax API.

type ClientOption

type ClientOption func(*Client)

func WithAuthFn

func WithAuthFn(authFn AuthFn) ClientOption

func WithAuthRequestSigner

func WithAuthRequestSigner(authRequestSigner client.RequestEditorFn) ClientOption

func WithEndpointURL

func WithEndpointURL(endpointURL string) ClientOption

func WithHttpClient

func WithHttpClient(httpClient *http.Client) ClientOption

func WithInstallation

func WithInstallation(installation string) ClientOption
WithInstallation sets the Stax installation used by the client.

Options are "dev", "test", "au1", "eu1" or "us1".

func WithPermissionSetsClient added in v0.0.5

func WithPermissionSetsClient(client permissionssetsclient.ClientWithResponsesInterface) ClientOption

func WithPermissionSetsEndpointURL added in v0.0.5

func WithPermissionSetsEndpointURL(permissionSetsEndpointURL string) ClientOption

func WithUserAgentVersion added in v0.0.2

func WithUserAgentVersion(userAgentVersion string) ClientOption

WithUserAgentVersion sets the user agent version used by the client.

Jump to

Keyboard shortcuts

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