Documentation
¶
Overview ¶
Package apiclient provides an HTTP client that can communicate with and interpret the responses of an instance of the service.
Index ¶
- Variables
- func UsingCookie(cookie *http.Cookie) func(*Client) error
- func UsingDebug(debug bool) func(*Client) error
- func UsingJSON() func(*Client) error
- func UsingLogger(logger logging.Logger) func(*Client) error
- func UsingLogin(ctx context.Context, input *types.UserLoginInput) func(*Client) error
- func UsingOAuth2(ctx context.Context, clientID, clientSecret string, cookie *http.Cookie) func(*Client) error
- func UsingTimeout(timeout time.Duration) func(*Client) error
- func UsingTracingProvider(tracerProvider tracing.TracerProvider) option
- func UsingURL(u string) func(*Client) error
- func UsingXML() func(*Client) error
- type Client
- func (c *Client) AcceptAccountInvitation(ctx context.Context, accountInvitationID, token, note string) error
- func (c *Client) ArchiveAccount(ctx context.Context, accountID string) error
- func (c *Client) ArchiveOAuth2Client(ctx context.Context, oauth2ClientDatabaseID string) error
- func (c *Client) ArchiveServiceSetting(ctx context.Context, serviceSettingID string) error
- func (c *Client) ArchiveServiceSettingConfiguration(ctx context.Context, serviceSettingConfigurationID string) error
- func (c *Client) ArchiveUser(ctx context.Context, userID string) error
- func (c *Client) ArchiveWebhook(ctx context.Context, webhookID string) error
- func (c *Client) ArchiveWebhookTriggerEvent(ctx context.Context, webhookID, webhookTriggerEventID string) error
- func (c *Client) AuthenticatedClient() *http.Client
- func (c *Client) BeginSession(ctx context.Context, input *types.UserLoginInput) (*http.Cookie, error)
- func (c *Client) BuildURL(ctx context.Context, qp url.Values, parts ...string) string
- func (c *Client) CancelAccountInvitation(ctx context.Context, accountInvitationID, token, note string) error
- func (c *Client) ChangePassword(ctx context.Context, cookie *http.Cookie, input *types.PasswordUpdateInput) error
- func (c *Client) CheckUserPermissions(ctx context.Context, permissions ...string) (*types.UserPermissionsResponse, error)
- func (c *Client) CreateAccount(ctx context.Context, input *types.AccountCreationRequestInput) (*types.Account, error)
- func (c *Client) CreateOAuth2Client(ctx context.Context, input *types.OAuth2ClientCreationRequestInput) (*types.OAuth2ClientCreationResponse, error)
- func (c *Client) CreateServiceSetting(ctx context.Context, input *types.ServiceSettingCreationRequestInput) (*types.ServiceSetting, error)
- func (c *Client) CreateServiceSettingConfiguration(ctx context.Context, ...) (*types.ServiceSettingConfiguration, error)
- func (c *Client) CreateUser(ctx context.Context, input *types.UserRegistrationInput) (*types.UserCreationResponse, error)
- func (c *Client) CreateUserNotification(ctx context.Context, input *types.UserNotificationCreationRequestInput) (*types.UserNotification, error)
- func (c *Client) CreateWebhook(ctx context.Context, input *types.WebhookCreationRequestInput) (*types.Webhook, error)
- func (c *Client) CycleTwoFactorSecret(ctx context.Context, cookie *http.Cookie, input *types.TOTPSecretRefreshInput) (*types.TOTPSecretRefreshResponse, error)
- func (c *Client) EndSession(ctx context.Context) error
- func (c *Client) GetAccount(ctx context.Context, accountID string) (*types.Account, error)
- func (c *Client) GetAccountInvitation(ctx context.Context, accountID, accountInvitationID string) (*types.AccountInvitation, error)
- func (c *Client) GetAccounts(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.Account], error)
- func (c *Client) GetAuditLogEntriesForAccount(ctx context.Context, resourceTypes ...string) (*types.QueryFilteredResult[types.AuditLogEntry], error)
- func (c *Client) GetAuditLogEntriesForUser(ctx context.Context, resourceTypes ...string) (*types.QueryFilteredResult[types.AuditLogEntry], error)
- func (c *Client) GetAuditLogEntry(ctx context.Context, auditLogEntryID string) (*types.AuditLogEntry, error)
- func (c *Client) GetCurrentAccount(ctx context.Context) (*types.Account, error)
- func (c *Client) GetOAuth2Client(ctx context.Context, oauth2ClientDatabaseID string) (*types.OAuth2Client, error)
- func (c *Client) GetOAuth2Clients(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.OAuth2Client], error)
- func (c *Client) GetPendingAccountInvitationsForUser(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.AccountInvitation], error)
- func (c *Client) GetPendingAccountInvitationsFromUser(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.AccountInvitation], error)
- func (c *Client) GetSelf(ctx context.Context) (*types.User, error)
- func (c *Client) GetServiceSetting(ctx context.Context, serviceSettingID string) (*types.ServiceSetting, error)
- func (c *Client) GetServiceSettingConfigurationForUserByName(ctx context.Context, settingName string, filter *types.QueryFilter) (*types.ServiceSettingConfiguration, error)
- func (c *Client) GetServiceSettingConfigurationsForAccount(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.ServiceSettingConfiguration], error)
- func (c *Client) GetServiceSettingConfigurationsForUser(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.ServiceSettingConfiguration], error)
- func (c *Client) GetServiceSettings(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.ServiceSetting], error)
- func (c *Client) GetUser(ctx context.Context, userID string) (*types.User, error)
- func (c *Client) GetUserNotification(ctx context.Context, userNotificationID string) (*types.UserNotification, error)
- func (c *Client) GetUserNotifications(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.UserNotification], error)
- func (c *Client) GetUsers(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.User], error)
- func (c *Client) GetWebhook(ctx context.Context, webhookID string) (*types.Webhook, error)
- func (c *Client) GetWebhooks(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.Webhook], error)
- func (c *Client) InviteUserToAccount(ctx context.Context, destinationAccountID string, ...) (*types.AccountInvitation, error)
- func (c *Client) IsUp(ctx context.Context) bool
- func (c *Client) MarkAsDefault(ctx context.Context, accountID string) error
- func (c *Client) ModifyMemberPermissions(ctx context.Context, accountID, userID string, ...) error
- func (c *Client) PlainClient() *http.Client
- func (c *Client) RedeemPasswordResetToken(ctx context.Context, input *types.PasswordResetTokenRedemptionRequestInput) error
- func (c *Client) RejectAccountInvitation(ctx context.Context, accountInvitationID, token, note string) error
- func (c *Client) RemoveUserFromAccount(ctx context.Context, accountID, userID string) error
- func (c *Client) RequestBuilder() *requests.Builder
- func (c *Client) RequestPasswordResetToken(ctx context.Context, emailAddress string) error
- func (c *Client) SearchForUsersByUsername(ctx context.Context, username string) ([]*types.User, error)
- func (c *Client) SearchServiceSettings(ctx context.Context, query string, limit uint8) ([]*types.ServiceSetting, error)
- func (c *Client) SetOptions(opts ...option) error
- func (c *Client) SwitchActiveAccount(ctx context.Context, accountID string) error
- func (c *Client) TransferAccountOwnership(ctx context.Context, accountID string, ...) error
- func (c *Client) URL() *url.URL
- func (c *Client) UpdateAccount(ctx context.Context, account *types.Account) error
- func (c *Client) UpdateServiceSettingConfiguration(ctx context.Context, ...) error
- func (c *Client) UpdateUserAccountStatus(ctx context.Context, input *types.UserAccountStatusUpdateInput) error
- func (c *Client) UpdateUserDetails(ctx context.Context, input *types.UserDetailsUpdateRequestInput) error
- func (c *Client) UpdateUserEmailAddress(ctx context.Context, input *types.UserEmailAddressUpdateInput) error
- func (c *Client) UpdateUserNotification(ctx context.Context, userNotification *types.UserNotification) error
- func (c *Client) UpdateUserUsername(ctx context.Context, input *types.UsernameUpdateInput) error
- func (c *Client) UploadNewAvatar(ctx context.Context, input *types.AvatarUpdateInput) error
- func (c *Client) UserStatus(ctx context.Context) (*types.UserStatusResponse, error)
- func (c *Client) VerifyTOTPSecret(ctx context.Context, userID, token string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrNotFound is a handy error to return when we receive a 404 response. ErrNotFound = errors.New("404: not found") // ErrInvalidRequestInput is a handy error to return when we receive a 400 response. ErrInvalidRequestInput = errors.New("400: bad request") // ErrInternalServerError is a handy error to return when we receive a 500 response. ErrInternalServerError = errors.New("500: internal server error") ErrUnauthorized = errors.New("401: not authorized") // ErrNoURLProvided is a handy error to return when we expect a *url.URL and don't receive one. ErrNoURLProvided = errors.New("no URL provided") // ErrInvalidTOTPToken is an error for when our TOTP validation request goes awry. ErrInvalidTOTPToken = errors.New("invalid TOTP token") // ErrNilInputProvided indicates nil input was provided in an unacceptable context. ErrNilInputProvided = errors.New("nil input provided") // ErrInvalidIDProvided indicates a required ID was passed in as zero. ErrInvalidIDProvided = errors.New("required ID provided is zero") // ErrEmptyEmailAddressProvided indicates the user provided an empty username for search. ErrEmptyEmailAddressProvided = errors.New("empty email address provided") // ErrEmptyQueryProvided indicates the user provided an empty query. ErrEmptyQueryProvided = errors.New("query provided was empty") // ErrEmptyUsernameProvided indicates the user provided an empty username for search. ErrEmptyUsernameProvided = errors.New("empty username provided") // ErrCookieRequired indicates a cookie is required. ErrCookieRequired = errors.New("cookie required for request") // ErrNoCookiesReturned indicates nil input was provided in an unacceptable context. ErrNoCookiesReturned = errors.New("no cookies returned from request") // ErrNilResponse indicates we received a nil response. ErrNilResponse = errors.New("nil response") // ErrArgumentIsNotPointer indicates we received a non-pointer interface argument. ErrArgumentIsNotPointer = errors.New("value is not a pointer") )
Functions ¶
func UsingCookie ¶
UsingCookie sets the authCookie value on the client.
func UsingDebug ¶
UsingDebug sets the debug value on the client.
func UsingLogger ¶
UsingLogger sets the logger on the client.
func UsingLogin ¶
UsingLogin sets the authCookie value on the client.
func UsingOAuth2 ¶
func UsingOAuth2(ctx context.Context, clientID, clientSecret string, cookie *http.Cookie) func(*Client) error
UsingOAuth2 sets the client to use OAuth2.
func UsingTimeout ¶
UsingTimeout sets the debug value on the client.
func UsingTracingProvider ¶
func UsingTracingProvider(tracerProvider tracing.TracerProvider) option
UsingTracingProvider sets the url on the client.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a client for interacting with v1 of our HTTP API.
func NewClient ¶
func NewClient(u *url.URL, tracerProvider tracing.TracerProvider, options ...option) (*Client, error)
NewClient builds a new API client for us.
func (*Client) AcceptAccountInvitation ¶
func (c *Client) AcceptAccountInvitation(ctx context.Context, accountInvitationID, token, note string) error
AcceptAccountInvitation accepts a given account invitation.
func (*Client) ArchiveAccount ¶
ArchiveAccount archives a account.
func (*Client) ArchiveOAuth2Client ¶
ArchiveOAuth2Client archives an OAuth2 client.
func (*Client) ArchiveServiceSetting ¶
ArchiveServiceSetting archives a service setting.
func (*Client) ArchiveServiceSettingConfiguration ¶
func (c *Client) ArchiveServiceSettingConfiguration(ctx context.Context, serviceSettingConfigurationID string) error
ArchiveServiceSettingConfiguration archives a service setting.
func (*Client) ArchiveUser ¶
ArchiveUser archives a user.
func (*Client) ArchiveWebhook ¶
ArchiveWebhook archives a webhook.
func (*Client) ArchiveWebhookTriggerEvent ¶
func (c *Client) ArchiveWebhookTriggerEvent(ctx context.Context, webhookID, webhookTriggerEventID string) error
ArchiveWebhookTriggerEvent archives a webhook trigger event.
func (*Client) AuthenticatedClient ¶
AuthenticatedClient returns the authenticated *apiclient.Client that we use to make most requests.
func (*Client) BeginSession ¶
func (c *Client) BeginSession(ctx context.Context, input *types.UserLoginInput) (*http.Cookie, error)
BeginSession fetches a login cookie.
func (*Client) CancelAccountInvitation ¶
func (c *Client) CancelAccountInvitation(ctx context.Context, accountInvitationID, token, note string) error
CancelAccountInvitation cancels a given account invitation.
func (*Client) ChangePassword ¶
func (c *Client) ChangePassword(ctx context.Context, cookie *http.Cookie, input *types.PasswordUpdateInput) error
ChangePassword changes a user's password.
func (*Client) CheckUserPermissions ¶
func (c *Client) CheckUserPermissions(ctx context.Context, permissions ...string) (*types.UserPermissionsResponse, error)
CheckUserPermissions checks if a user has certain permissions.
func (*Client) CreateAccount ¶
func (c *Client) CreateAccount(ctx context.Context, input *types.AccountCreationRequestInput) (*types.Account, error)
CreateAccount creates a account.
func (*Client) CreateOAuth2Client ¶
func (c *Client) CreateOAuth2Client(ctx context.Context, input *types.OAuth2ClientCreationRequestInput) (*types.OAuth2ClientCreationResponse, error)
CreateOAuth2Client creates an OAuth2 client.
func (*Client) CreateServiceSetting ¶
func (c *Client) CreateServiceSetting(ctx context.Context, input *types.ServiceSettingCreationRequestInput) (*types.ServiceSetting, error)
CreateServiceSetting creates a service setting.
func (*Client) CreateServiceSettingConfiguration ¶
func (c *Client) CreateServiceSettingConfiguration(ctx context.Context, input *types.ServiceSettingConfigurationCreationRequestInput) (*types.ServiceSettingConfiguration, error)
CreateServiceSettingConfiguration creates a service setting.
func (*Client) CreateUser ¶
func (c *Client) CreateUser(ctx context.Context, input *types.UserRegistrationInput) (*types.UserCreationResponse, error)
CreateUser creates a new user.
func (*Client) CreateUserNotification ¶
func (c *Client) CreateUserNotification(ctx context.Context, input *types.UserNotificationCreationRequestInput) (*types.UserNotification, error)
CreateUserNotification creates a user notification.
func (*Client) CreateWebhook ¶
func (c *Client) CreateWebhook(ctx context.Context, input *types.WebhookCreationRequestInput) (*types.Webhook, error)
CreateWebhook creates a webhook.
func (*Client) CycleTwoFactorSecret ¶
func (c *Client) CycleTwoFactorSecret(ctx context.Context, cookie *http.Cookie, input *types.TOTPSecretRefreshInput) (*types.TOTPSecretRefreshResponse, error)
CycleTwoFactorSecret cycles a user's 2FA secret.
func (*Client) EndSession ¶
EndSession logs a user out.
func (*Client) GetAccount ¶
GetAccount retrieves a account.
func (*Client) GetAccountInvitation ¶
func (c *Client) GetAccountInvitation(ctx context.Context, accountID, accountInvitationID string) (*types.AccountInvitation, error)
GetAccountInvitation retrieves a account invitation.
func (*Client) GetAccounts ¶
func (c *Client) GetAccounts(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.Account], error)
GetAccounts retrieves a list of accounts.
func (*Client) GetAuditLogEntriesForAccount ¶
func (c *Client) GetAuditLogEntriesForAccount(ctx context.Context, resourceTypes ...string) (*types.QueryFilteredResult[types.AuditLogEntry], error)
GetAuditLogEntriesForAccount fetches audit log entries for a user's account.
func (*Client) GetAuditLogEntriesForUser ¶
func (c *Client) GetAuditLogEntriesForUser(ctx context.Context, resourceTypes ...string) (*types.QueryFilteredResult[types.AuditLogEntry], error)
GetAuditLogEntriesForUser fetches audit log entries for a user.
func (*Client) GetAuditLogEntry ¶
func (c *Client) GetAuditLogEntry(ctx context.Context, auditLogEntryID string) (*types.AuditLogEntry, error)
GetAuditLogEntry fetches an audit log entry.
func (*Client) GetCurrentAccount ¶
GetCurrentAccount retrieves a account.
func (*Client) GetOAuth2Client ¶
func (c *Client) GetOAuth2Client(ctx context.Context, oauth2ClientDatabaseID string) (*types.OAuth2Client, error)
GetOAuth2Client gets an OAuth2 client.
func (*Client) GetOAuth2Clients ¶
func (c *Client) GetOAuth2Clients(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.OAuth2Client], error)
GetOAuth2Clients gets a list of OAuth2 clients.
func (*Client) GetPendingAccountInvitationsForUser ¶
func (c *Client) GetPendingAccountInvitationsForUser(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.AccountInvitation], error)
GetPendingAccountInvitationsForUser retrieves account invitations received by the user.
func (*Client) GetPendingAccountInvitationsFromUser ¶
func (c *Client) GetPendingAccountInvitationsFromUser(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.AccountInvitation], error)
GetPendingAccountInvitationsFromUser retrieves account invitations sent by the user.
func (*Client) GetServiceSetting ¶
func (c *Client) GetServiceSetting(ctx context.Context, serviceSettingID string) (*types.ServiceSetting, error)
GetServiceSetting gets a service setting.
func (*Client) GetServiceSettingConfigurationForUserByName ¶
func (c *Client) GetServiceSettingConfigurationForUserByName(ctx context.Context, settingName string, filter *types.QueryFilter) (*types.ServiceSettingConfiguration, error)
GetServiceSettingConfigurationForUserByName retrieves a list of service settings.
func (*Client) GetServiceSettingConfigurationsForAccount ¶
func (c *Client) GetServiceSettingConfigurationsForAccount(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.ServiceSettingConfiguration], error)
GetServiceSettingConfigurationsForAccount retrieves a list of service settings.
func (*Client) GetServiceSettingConfigurationsForUser ¶
func (c *Client) GetServiceSettingConfigurationsForUser(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.ServiceSettingConfiguration], error)
GetServiceSettingConfigurationsForUser retrieves a list of service settings.
func (*Client) GetServiceSettings ¶
func (c *Client) GetServiceSettings(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.ServiceSetting], error)
GetServiceSettings retrieves a list of service settings.
func (*Client) GetUserNotification ¶
func (c *Client) GetUserNotification(ctx context.Context, userNotificationID string) (*types.UserNotification, error)
GetUserNotification gets a user notification.
func (*Client) GetUserNotifications ¶
func (c *Client) GetUserNotifications(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.UserNotification], error)
GetUserNotifications retrieves a list of user notifications.
func (*Client) GetUsers ¶
func (c *Client) GetUsers(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.User], error)
GetUsers retrieves a list of users.
func (*Client) GetWebhook ¶
GetWebhook retrieves a webhook.
func (*Client) GetWebhooks ¶
func (c *Client) GetWebhooks(ctx context.Context, filter *types.QueryFilter) (*types.QueryFilteredResult[types.Webhook], error)
GetWebhooks gets a list of webhooks.
func (*Client) InviteUserToAccount ¶
func (c *Client) InviteUserToAccount(ctx context.Context, destinationAccountID string, input *types.AccountInvitationCreationRequestInput) (*types.AccountInvitation, error)
InviteUserToAccount adds a user to a account.
func (*Client) MarkAsDefault ¶
MarkAsDefault marks a given account as the default for a given user.
func (*Client) ModifyMemberPermissions ¶
func (c *Client) ModifyMemberPermissions(ctx context.Context, accountID, userID string, input *types.ModifyUserPermissionsInput) error
ModifyMemberPermissions modifies a given user's permissions for a given account.
func (*Client) PlainClient ¶
PlainClient returns the unauthenticated *apiclient.Client that we use to make certain requests.
func (*Client) RedeemPasswordResetToken ¶
func (c *Client) RedeemPasswordResetToken(ctx context.Context, input *types.PasswordResetTokenRedemptionRequestInput) error
RedeemPasswordResetToken redeems a password reset token.
func (*Client) RejectAccountInvitation ¶
func (c *Client) RejectAccountInvitation(ctx context.Context, accountInvitationID, token, note string) error
RejectAccountInvitation rejects a given account invitation.
func (*Client) RemoveUserFromAccount ¶
RemoveUserFromAccount removes a user from a account.
func (*Client) RequestBuilder ¶
RequestBuilder provides the client's *requests.Builder.
func (*Client) RequestPasswordResetToken ¶
RequestPasswordResetToken requests a password reset token.
func (*Client) SearchForUsersByUsername ¶
func (c *Client) SearchForUsersByUsername(ctx context.Context, username string) ([]*types.User, error)
SearchForUsersByUsername searches for a user from a list of users by their username.
func (*Client) SearchServiceSettings ¶
func (c *Client) SearchServiceSettings(ctx context.Context, query string, limit uint8) ([]*types.ServiceSetting, error)
SearchServiceSettings searches through a list of service settings.
func (*Client) SetOptions ¶
SetOptions sets a new option on the client.
func (*Client) SwitchActiveAccount ¶
SwitchActiveAccount will switch the account on whose behalf requests are made.
func (*Client) TransferAccountOwnership ¶
func (c *Client) TransferAccountOwnership(ctx context.Context, accountID string, input *types.AccountOwnershipTransferInput) error
TransferAccountOwnership transfers ownership of a account to a given user.
func (*Client) UpdateAccount ¶
UpdateAccount updates a account.
func (*Client) UpdateServiceSettingConfiguration ¶
func (c *Client) UpdateServiceSettingConfiguration(ctx context.Context, serviceSettingConfiguration *types.ServiceSettingConfiguration) error
UpdateServiceSettingConfiguration updates a service setting.
func (*Client) UpdateUserAccountStatus ¶
func (c *Client) UpdateUserAccountStatus(ctx context.Context, input *types.UserAccountStatusUpdateInput) error
UpdateUserAccountStatus updates a user's account status.
func (*Client) UpdateUserDetails ¶
func (c *Client) UpdateUserDetails(ctx context.Context, input *types.UserDetailsUpdateRequestInput) error
UpdateUserDetails updates a user's details.
func (*Client) UpdateUserEmailAddress ¶
func (c *Client) UpdateUserEmailAddress(ctx context.Context, input *types.UserEmailAddressUpdateInput) error
UpdateUserEmailAddress updates a user's email address.
func (*Client) UpdateUserNotification ¶
func (c *Client) UpdateUserNotification(ctx context.Context, userNotification *types.UserNotification) error
UpdateUserNotification updates a user notification.
func (*Client) UpdateUserUsername ¶
UpdateUserUsername updates a user's username.
func (*Client) UploadNewAvatar ¶
UploadNewAvatar uploads a new avatar.
func (*Client) UserStatus ¶
UserStatus fetches a user's status.