Documentation ¶
Overview ¶
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).
Index ¶
- Constants
- Variables
- type AuditPaginator
- type Client
- func (c *Client) AuditRepo(namespace, repoName string, subjectTypes api.AuditSubjectTypeList) ([]*api.Audit, error)
- func (c *Client) AuditRepoPaginator(namespace, repoName string) *AuditPaginator
- func (c *Client) AuditSecret(secretBlindName string, subjectTypes api.AuditSubjectTypeList) ([]*api.Audit, error)
- func (c *Client) AuditSecretPaginator(secretBlindName string) *AuditPaginator
- func (c *Client) CreateAccessRule(dirBlindName string, accountName api.AccountName, ...) (*api.AccessRule, error)
- func (c *Client) CreateAccountKey(in *api.CreateAccountKeyRequest, fingerprint string) (*api.EncryptedAccountKey, error)
- func (c *Client) CreateCredential(in *api.CreateCredentialRequest) (*api.Credential, error)
- func (c *Client) CreateDir(namespace, repoName string, in *api.CreateDirRequest) (*api.EncryptedDir, error)
- func (c *Client) CreateIDPLink(namespace string, t api.IdentityProviderLinkType, linkedID string, ...) (*api.IdentityProviderLink, error)
- func (c *Client) CreateOrg(in *api.CreateOrgRequest) (*api.Org, error)
- func (c *Client) CreateOrgMember(name string, in *api.CreateOrgMemberRequest) (*api.OrgMember, error)
- func (c *Client) CreateRepo(namespace string, in *api.CreateRepoRequest) (*api.Repo, error)
- func (c Client) CreateSecret(namespace, repoName, dirBlindName string, in *api.CreateSecretRequest) (*api.EncryptedSecretVersion, error)
- func (c *Client) CreateSecretKey(secretBlindName string, in *api.CreateSecretKeyRequest) (*api.EncryptedSecretKey, error)
- func (c Client) CreateSecretVersion(blindName string, in *api.CreateSecretVersionRequest) (*api.EncryptedSecretVersion, error)
- func (c *Client) CreateService(namespace, repoName string, in *api.CreateServiceRequest) (*api.Service, error)
- func (c *Client) CreateSession(in interface{}) (*api.Session, error)
- func (c *Client) DeleteAccessRule(dirBlindName string, accountName api.AccountName) error
- func (c *Client) DeleteDir(dirBlindName string) error
- func (c *Client) DeleteIDPLink(namespace string, t api.IdentityProviderLinkType, linkedID string) error
- func (c *Client) DeleteOrg(name string) error
- func (c *Client) DeleteRepo(namespace, repoName string) error
- func (c *Client) DeleteSecret(secretBlindName string) error
- func (c *Client) DeleteSecretVersion(secretBlindName string, version string) error
- func (c *Client) DeleteService(service string) (*api.RevokeRepoResponse, error)
- func (c *Client) GetAccessLevel(dirBlindName string, accountName api.AccountName) (*api.AccessLevel, error)
- func (c *Client) GetAccessRule(dirBlindName string, accountName api.AccountName) (*api.AccessRule, error)
- func (c *Client) GetAccount(name api.AccountName) (*api.Account, error)
- func (c *Client) GetAccountKey() (*api.EncryptedAccountKey, error)
- func (c *Client) GetCurrentSecretKey(secretBlindName string) (*api.EncryptedSecretKey, error)
- func (c *Client) GetDirByID(id uuid.UUID) (*api.EncryptedDir, error)
- func (c *Client) GetGCPOAuthConfig() (*api.OAuthConfig, error)
- func (c *Client) GetIDPLink(namespace string, t api.IdentityProviderLinkType, linkedID string) (*api.IdentityProviderLink, error)
- func (c *Client) GetMyUser() (*api.User, error)
- func (c *Client) GetOrg(name string) (*api.Org, error)
- func (c *Client) GetOrgMember(name string, username string) (*api.OrgMember, error)
- func (c *Client) GetRepo(namespace, repoName string) (*api.Repo, error)
- func (c *Client) GetRepoKeys(namespace, repoName string) (*api.RepoKeys, error)
- func (c *Client) GetRepoUser(namespace, repoName, username string) (*api.User, error)
- func (c *Client) GetSecret(secretBlindName string) (*api.EncryptedSecret, error)
- func (c *Client) GetSecretLatestVersion(secretBlindName string, withData bool) (*api.EncryptedSecretVersion, error)
- func (c *Client) GetSecretVersion(secretBlindName string, version string, withData bool) (*api.EncryptedSecretVersion, error)
- func (c *Client) GetService(service string) (*api.Service, error)
- func (c *Client) GetTree(dirBlindName string, depth int, ancestor bool) (*api.EncryptedTree, error)
- func (c *Client) GetUser(username string) (*api.User, error)
- func (c *Client) InviteRepo(namespace, repoName string, in *api.InviteUserRequest) (*api.RepoMember, error)
- func (c *Client) IsAuthenticated() bool
- func (c *Client) ListAccessRules(dirBlindName string, depth int, withAncestors bool) ([]*api.AccessRule, error)
- func (c *Client) ListDirAccounts(dirBlindName string) ([]*api.Account, error)
- func (c *Client) ListIDPLinks(namespace string, t api.IdentityProviderLinkType) ([]*api.IdentityProviderLink, error)
- func (c *Client) ListMyCredentials() ([]*api.Credential, error)
- func (c *Client) ListMyOrgs() ([]*api.Org, error)
- func (c *Client) ListMyRepos() ([]*api.Repo, error)
- func (c *Client) ListOrgMembers(name string) ([]*api.OrgMember, error)
- func (c *Client) ListRepoAccounts(namespace, repoName string) ([]*api.Account, error)
- func (c *Client) ListRepoUsers(namespace, repoName string) ([]*api.User, error)
- func (c *Client) ListRepos(namespace string) ([]*api.Repo, error)
- func (c *Client) ListSecretKeys(secretBlindName string) ([]*api.EncryptedSecretKey, error)
- func (c *Client) ListSecretVersions(secretBlindName string, withData bool) ([]*api.EncryptedSecretVersion, error)
- func (c *Client) ListServices(namespace, repoName string) ([]*api.Service, error)
- func (c *Client) Options(with ...ClientOption)
- func (c *Client) RemoveUser(namespace, repoName, username string) (*api.RevokeRepoResponse, error)
- func (c *Client) RevokeOrgMember(name string, username string, opts *api.RevokeOpts) (*api.RevokeOrgResponse, error)
- func (c *Client) SendVerificationEmail() error
- func (c *Client) UpdateAccessRule(dirBlindName string, accountName api.AccountName, ...) (*api.AccessRule, error)
- func (c *Client) UpdateCredential(fingerprint string, in *api.UpdateCredentialRequest) (*api.Credential, error)
- func (c *Client) UpdateOrgMember(name string, username string, in *api.UpdateOrgMemberRequest) (*api.OrgMember, error)
- type ClientOption
Constants ¶
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 = "secrets-go" )
Variables ¶
var ( ErrClientTimeout = errHTTP.Code("timeout").Error("client timed out during request. Please try again. See https://status.secrethub.io for system status.") ErrRequestFailed = errHTTP.Code("request_failed").ErrorPref("request to API server failed: %v") )
Errors
var (
ErrWrongContentType = errHTTP.Code("wrong_content_type").Error("server returned wrong content type in header")
)
Errors
Functions ¶
This section is empty.
Types ¶
type AuditPaginator ¶
type AuditPaginator struct {
// contains filtered or unexported fields
}
func (*AuditPaginator) Next ¶
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 ¶
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 ¶
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 ¶
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.
func (*Client) CreateIDPLink ¶
func (c *Client) CreateIDPLink(namespace string, t api.IdentityProviderLinkType, linkedID string, in *api.CreateIdentityProviderLinkGCPRequest) (*api.IdentityProviderLink, error)
CreateIDPLink creates a new IDP link for a namespace.
func (*Client) CreateOrgMember ¶
func (c *Client) CreateOrgMember(name string, in *api.CreateOrgMemberRequest) (*api.OrgMember, error)
CreateOrgMember creates a new organization member.
func (*Client) CreateRepo ¶
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 ¶
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) DeleteIDPLink ¶
func (c *Client) DeleteIDPLink(namespace string, t api.IdentityProviderLinkType, linkedID string) error
DeleteIDPLink deletes an existing IDP link for a namespace.
func (*Client) DeleteRepo ¶
DeleteRepo deletes a repo
func (*Client) DeleteSecret ¶
DeleteSecret deletes a secret.
func (*Client) DeleteSecretVersion ¶
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 ¶
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 ¶
GetDirByID retrieves a directory encrypted for the authenticated user.
func (*Client) GetGCPOAuthConfig ¶
func (c *Client) GetGCPOAuthConfig() (*api.OAuthConfig, error)
GetGCPOAuthConfig returns the client configuration for using OAuth with GCP.
func (*Client) GetIDPLink ¶
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) GetOrgMember ¶
GetOrgMember gets a user's organization membership details.
func (*Client) GetRepoKeys ¶
GetRepoKeys retrieves the repo key of the user.
func (*Client) GetRepoUser ¶
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 ¶
GetService retrieves a service.
func (*Client) GetTree ¶
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) InviteRepo ¶
func (c *Client) InviteRepo(namespace, repoName string, in *api.InviteUserRequest) (*api.RepoMember, error)
InviteRepo adds a user to a repo.
func (*Client) IsAuthenticated ¶
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 ¶
ListDirAccounts returns all accounts with read access.
func (*Client) ListIDPLinks ¶
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 ¶
func (c *Client) ListMyCredentials() ([]*api.Credential, error)
ListMyCredentials list all the currently authenticated account's credentials.
func (*Client) ListMyOrgs ¶
ListMyOrgs lists the organizations an account is a member of.
func (*Client) ListMyRepos ¶
ListMyRepos gets a list of repos from SecretHub
func (*Client) ListOrgMembers ¶
ListOrgMembers lists an organization's members.
func (*Client) ListRepoAccounts ¶
ListRepoAccounts lists the accounts of a repo.
func (*Client) ListRepoUsers ¶
ListRepoUsers lists the users of a repo.
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 ¶
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 ¶
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 ¶
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.