Version: v0.33.0 Latest Latest

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

Go to latest
Published: Aug 20, 2021 License: Apache-2.0 Imports: 14 Imported by: 0



Package http implements the RESTful HTTP client that talks directly to the API, as opposed to the client package, which wraps the http client with additional logic (e.g. for encryption).



View Source
const (
	// DefaultTimeout defines the default client http timeout.
	DefaultTimeout = time.Second * 30
	// DefaultUserAgent is the user-agent the client uses when none is explicitly provided.
	DefaultUserAgent = "secrethub-go"


View Source
var (
	ErrClientTimeout = errHTTP.Code("timeout").Error("client timed out during request. Please try again. See for system status.")
	ErrRequestFailed = errHTTP.Code("request_failed").ErrorPref("request to API server failed: %v")


View Source
var (
	ErrWrongContentType = errHTTP.Code("wrong_content_type").Error("server returned wrong content type in header")



This section is empty.


type AuditPaginator added in v0.24.0

type AuditPaginator struct {
	// contains filtered or unexported fields

func (*AuditPaginator) Next added in v0.24.0

func (pag *AuditPaginator) Next() ([]interface{}, error)

type Client

type Client struct {
	// contains filtered or unexported fields

Client is a raw client for the SecretHub HTTP API. This client just makes HTTP calls, use secrethub.Client for a user-friendly client that can decrypt secrets and more.

func NewClient

func NewClient(with ...ClientOption) *Client

NewClient configures a new Client and applies the provided ClientOptions.

func (*Client) AuditRepo

func (c *Client) AuditRepo(namespace, repoName string, subjectTypes api.AuditSubjectTypeList) ([]*api.Audit, error)

AuditRepo gets the audit events for a given repo.

func (*Client) AuditRepoPaginator added in v0.24.0

func (c *Client) AuditRepoPaginator(namespace, repoName string) *AuditPaginator

AuditRepoPaginator returns a paginator to fetch the audit events for a given repo.

func (*Client) AuditSecret

func (c *Client) AuditSecret(secretBlindName string, subjectTypes api.AuditSubjectTypeList) ([]*api.Audit, error)

AuditSecret gets the audit events for a given secret.

func (*Client) AuditSecretPaginator added in v0.24.0

func (c *Client) AuditSecretPaginator(secretBlindName string) *AuditPaginator

AuditSecretPaginator returns a paginator to fetch the audit events for a given secret.

func (*Client) CreateAccessRule

func (c *Client) CreateAccessRule(dirBlindName string, accountName api.AccountName, in *api.CreateAccessRuleRequest) (*api.AccessRule, error)

CreateAccessRule creates an AccessRule.

func (*Client) CreateAccountKey

func (c *Client) CreateAccountKey(in *api.CreateAccountKeyRequest, fingerprint string) (*api.EncryptedAccountKey, error)

CreateAccountKey creates a new account key encrypted by the credential with the given fingerprint.

func (*Client) CreateCredential added in v0.25.0

func (c *Client) CreateCredential(in *api.CreateCredentialRequest) (*api.Credential, error)

CreateCredential creates a new credential for the account.

func (*Client) CreateDir

func (c *Client) CreateDir(namespace, repoName string, in *api.CreateDirRequest) (*api.EncryptedDir, error)

CreateDir creates a new directory in the repo.

CreateIDPLink creates a new IDP link for a namespace.

func (*Client) CreateOrg

func (c *Client) CreateOrg(in *api.CreateOrgRequest) (*api.Org, error)

CreateOrg creates an organization.

func (*Client) CreateOrgMember

func (c *Client) CreateOrgMember(name string, in *api.CreateOrgMemberRequest) (*api.OrgMember, error)

CreateOrgMember creates a new organization member.

func (*Client) CreateRepo

func (c *Client) CreateRepo(namespace string, in *api.CreateRepoRequest) (*api.Repo, error)

CreateRepo creates a new repo at SecretHub

func (Client) CreateSecret

func (c Client) CreateSecret(namespace, repoName, dirBlindName string, in *api.CreateSecretRequest) (*api.EncryptedSecretVersion, error)

CreateSecret writes a new secret.

func (*Client) CreateSecretKey

func (c *Client) CreateSecretKey(secretBlindName string, in *api.CreateSecretKeyRequest) (*api.EncryptedSecretKey, error)

CreateSecretKey creates a new secret key.

func (Client) CreateSecretVersion

func (c Client) CreateSecretVersion(blindName string, in *api.CreateSecretVersionRequest) (*api.EncryptedSecretVersion, error)

CreateSecretVersion creates a new version of an existing secret.

func (*Client) CreateService

func (c *Client) CreateService(namespace, repoName string, in *api.CreateServiceRequest) (*api.Service, error)

CreateService creates a new service for a repo.

func (*Client) CreateSession

func (c *Client) CreateSession(in interface{}) (*api.Session, error)

CreateSession tries to create a new session that can be used for temporary authentication to the SecretHub API.

func (*Client) DeleteAccessRule

func (c *Client) DeleteAccessRule(dirBlindName string, accountName api.AccountName) error

DeleteAccessRule deletes an access rule for an account.

func (*Client) DeleteDir

func (c *Client) DeleteDir(dirBlindName string) error

DeleteDir deletes a directory by blind name.

func (c *Client) DeleteIDPLink(namespace string, t api.IdentityProviderLinkType, linkedID string) error

DeleteIDPLink deletes an existing IDP link for a namespace.

func (*Client) DeleteMyAccount added in v0.33.0

func (c *Client) DeleteMyAccount() error


func (*Client) DeleteOrg

func (c *Client) DeleteOrg(name string) error

DeleteOrg permanently deletes an organization and all of its resources.

func (*Client) DeleteRepo

func (c *Client) DeleteRepo(namespace, repoName string) error

DeleteRepo deletes a repo

func (*Client) DeleteSecret

func (c *Client) DeleteSecret(secretBlindName string) error

DeleteSecret deletes a secret.

func (*Client) DeleteSecretVersion

func (c *Client) DeleteSecretVersion(secretBlindName string, version string) error

DeleteSecretVersion deletes a version of a secret.

func (*Client) DeleteService

func (c *Client) DeleteService(service string) (*api.RevokeRepoResponse, error)

DeleteService deletes an service.

func (*Client) GetAccessLevel

func (c *Client) GetAccessLevel(dirBlindName string, accountName api.AccountName) (*api.AccessLevel, error)

GetAccessLevel gets an access level for an account.

func (*Client) GetAccessRule

func (c *Client) GetAccessRule(dirBlindName string, accountName api.AccountName) (*api.AccessRule, error)

GetAccessRule gets an access rule for an account.

func (*Client) GetAccount

func (c *Client) GetAccount(name api.AccountName) (*api.Account, error)

GetAccount returns the account for a name

func (*Client) GetAccountKey

func (c *Client) GetAccountKey() (*api.EncryptedAccountKey, error)

GetAccountKey returns the account's intermediate key encrypted with the key identified by key_identifier

func (*Client) GetCurrentSecretKey

func (c *Client) GetCurrentSecretKey(secretBlindName string) (*api.EncryptedSecretKey, error)

GetCurrentSecretKey gets the secret key currently used for encrypting the secret.

func (*Client) GetDirByID added in v0.22.0

func (c *Client) GetDirByID(id uuid.UUID) (*api.EncryptedDir, error)

GetDirByID retrieves a directory encrypted for the authenticated user.

func (*Client) GetGCPOAuthConfig added in v0.30.0

func (c *Client) GetGCPOAuthConfig() (*api.OAuthConfig, error)

GetGCPOAuthConfig returns the client configuration for using OAuth with GCP.

func (c *Client) GetIDPLink(namespace string, t api.IdentityProviderLinkType, linkedID string) (*api.IdentityProviderLink, error)

GetIDPLink return the link identified by namespace, type and linkedID..

func (*Client) GetMyUser

func (c *Client) GetMyUser() (*api.User, error)

GetMyUser gets the account's user.

func (*Client) GetOrg

func (c *Client) GetOrg(name string) (*api.Org, error)

GetOrg gets an organization's details.

func (*Client) GetOrgMember

func (c *Client) GetOrgMember(name string, username string) (*api.OrgMember, error)

GetOrgMember gets a user's organization membership details.

func (*Client) GetRepo

func (c *Client) GetRepo(namespace, repoName string) (*api.Repo, error)

GetRepo gets a repo by its namespace and repo name

func (*Client) GetRepoKeys

func (c *Client) GetRepoKeys(namespace, repoName string) (*api.RepoKeys, error)

GetRepoKeys retrieves the repo key of the user.

func (*Client) GetRepoUser

func (c *Client) GetRepoUser(namespace, repoName, username string) (*api.User, error)

GetRepoUser retrieves a user for a repo. If the user is a repo member, then the user is retrieved.

func (*Client) GetSecret

func (c *Client) GetSecret(secretBlindName string) (*api.EncryptedSecret, error)

GetSecret gets a secret by its blind name. Note that this does not include the versions and secret data.

func (*Client) GetSecretLatestVersion

func (c *Client) GetSecretLatestVersion(secretBlindName string, withData bool) (*api.EncryptedSecretVersion, error)

GetSecretLatestVersion gets the latest version of the secret with the given blind name.

func (*Client) GetSecretVersion

func (c *Client) GetSecretVersion(secretBlindName string, version string, withData bool) (*api.EncryptedSecretVersion, error)

GetSecretVersion gets a single version of a secret by its name.

func (*Client) GetService

func (c *Client) GetService(service string) (*api.Service, error)

GetService retrieves a service.

func (*Client) GetTree

func (c *Client) GetTree(dirBlindName string, depth int, ancestor bool) (*api.EncryptedTree, error)

GetTree gets a directory and all of it subdirs and secrets recursively by blind name. If depth is > 0 then the result is limited to depth If ancestors = true then ancestors are added.

func (*Client) GetUser

func (c *Client) GetUser(username string) (*api.User, error)

GetUser gets a user by its username from SecretHub

func (*Client) InviteRepo

func (c *Client) InviteRepo(namespace, repoName string, in *api.InviteUserRequest) (*api.RepoMember, error)

InviteRepo adds a user to a repo.

func (*Client) IsAuthenticated added in v0.31.0

func (c *Client) IsAuthenticated() bool

func (*Client) ListAccessRules

func (c *Client) ListAccessRules(dirBlindName string, depth int, withAncestors bool) ([]*api.AccessRule, error)

ListAccessRules gets the access rules for a given directory.

func (*Client) ListDirAccounts

func (c *Client) ListDirAccounts(dirBlindName string) ([]*api.Account, error)

ListDirAccounts returns all accounts with read access.

func (c *Client) ListIDPLinks(namespace string, t api.IdentityProviderLinkType) ([]*api.IdentityProviderLink, error)

ListIDPLinks lists all IDP links for a namespace and a given type.

func (*Client) ListMyCredentials added in v0.25.0

func (c *Client) ListMyCredentials() ([]*api.Credential, error)

ListMyCredentials list all the currently authenticated account's credentials.

func (*Client) ListMyOrgs

func (c *Client) ListMyOrgs() ([]*api.Org, error)

ListMyOrgs lists the organizations an account is a member of.

func (*Client) ListMyRepos

func (c *Client) ListMyRepos() ([]*api.Repo, error)

ListMyRepos gets a list of repos from SecretHub

func (*Client) ListOrgMembers

func (c *Client) ListOrgMembers(name string) ([]*api.OrgMember, error)

ListOrgMembers lists an organization's members.

func (*Client) ListRepoAccounts

func (c *Client) ListRepoAccounts(namespace, repoName string) ([]*api.Account, error)

ListRepoAccounts lists the accounts of a repo.

func (*Client) ListRepoUsers

func (c *Client) ListRepoUsers(namespace, repoName string) ([]*api.User, error)

ListRepoUsers lists the users of a repo.

func (*Client) ListRepos

func (c *Client) ListRepos(namespace string) ([]*api.Repo, error)

ListRepos lists all repos in the given namespace.

func (*Client) ListSecretKeys

func (c *Client) ListSecretKeys(secretBlindName string) ([]*api.EncryptedSecretKey, error)

ListSecretKeys lists an account's secret keys.

func (*Client) ListSecretVersions

func (c *Client) ListSecretVersions(secretBlindName string, withData bool) ([]*api.EncryptedSecretVersion, error)

ListSecretVersions lists all versions of a secret by its name.

func (*Client) ListServices

func (c *Client) ListServices(namespace, repoName string) ([]*api.Service, error)

ListServices lists the services for a repo.

func (*Client) Options

func (c *Client) Options(with ...ClientOption)

Options applies the provided options to an existing client.

func (*Client) RemoveUser

func (c *Client) RemoveUser(namespace, repoName, username string) (*api.RevokeRepoResponse, error)

RemoveUser removes a user from a repo.

func (*Client) RevokeOrgMember

func (c *Client) RevokeOrgMember(name string, username string, opts *api.RevokeOpts) (*api.RevokeOrgResponse, error)

RevokeOrgMember revokes an organization member.

func (*Client) SendVerificationEmail

func (c *Client) SendVerificationEmail() error

SendVerificationEmail sends an email to the users registered email address for them to prove they own that email address.

func (*Client) UpdateAccessRule

func (c *Client) UpdateAccessRule(dirBlindName string, accountName api.AccountName, in *api.UpdateAccessRuleRequest) (*api.AccessRule, error)

UpdateAccessRule updates an AccessRule.

func (*Client) UpdateCredential added in v0.25.0

func (c *Client) UpdateCredential(fingerprint string, in *api.UpdateCredentialRequest) (*api.Credential, error)

UpdateCredential updates an existing credential.

func (*Client) UpdateOrgMember

func (c *Client) UpdateOrgMember(name string, username string, in *api.UpdateOrgMemberRequest) (*api.OrgMember, error)

UpdateOrgMember updates the role of the given username in the org with the given name.

type ClientOption

type ClientOption func(*Client)

ClientOption is an option that can be set on an http.Client.

func WithAuthenticator

func WithAuthenticator(authenticator auth.Authenticator) ClientOption

WithAuthenticator sets the authenticator used to authenticate requests made by the HTTP client.

func WithServerURL

func WithServerURL(url url.URL) ClientOption

WithServerURL overrides the default server endpoint URL used by the HTTP client.

func WithTimeout

func WithTimeout(timeout time.Duration) ClientOption

WithTimeout overrides the default request timeout of the HTTP client.

func WithTransport

func WithTransport(transport http.RoundTripper) ClientOption

WithTransport replaces the DefaultTransport used by the HTTP client with the provided RoundTripper.

func WithUserAgent

func WithUserAgent(userAgent string) ClientOption

WithUserAgent overrides the default user-agent supplied by HTTP client in requests.

Jump to

Keyboard shortcuts

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