Documentation ¶
Index ¶
- type API
- type AcmeClient
- type Client
- func (c *Client) AddHeader(header, value string) *Client
- func (c *Client) ApproveOrg(ctx context.Context, token, code, action string) (*v1.OrgResponse, error)
- func (c *Client) Certificates(ctx context.Context) (*v1.CertificatesResponse, error)
- func (c *Client) Config() *Config
- func (c *Client) CreateSubscription(ctx context.Context, req *v1.CreateSubscriptionRequest) (*v1.CreateSubscriptionResponse, error)
- func (c *Client) CurrentHost() string
- func (c *Client) Delete(ctx context.Context, path string, body interface{}) (http.Header, int, error)
- func (c *Client) DeleteOrg(ctx context.Context, orgID string) error
- func (c *Client) Directory(ctx context.Context) (map[string]string, error)
- func (c *Client) FccContact(ctx context.Context, frn string) (*v1.FccContactResponse, error)
- func (c *Client) FccFRN(ctx context.Context, filerID string) (*v1.FccFrnResponse, error)
- func (c *Client) Get(ctx context.Context, path string, body interface{}) (http.Header, int, error)
- func (c *Client) GetFrom(ctx context.Context, hosts []string, path string, body interface{}) (http.Header, int, error)
- func (c *Client) GetOrgAPIKeys(ctx context.Context, orgID string) (*v1.GetOrgAPIKeysResponse, error)
- func (c *Client) GetResponse(ctx context.Context, path string, body io.Writer) (http.Header, int, error)
- func (c *Client) Hosts() []string
- func (c *Client) ListSubscriptions(ctx context.Context) (*v1.ListSubscriptionsResponse, error)
- func (c *Client) ListSubscriptionsProducts(ctx context.Context) (*v1.SubscriptionsProductsResponse, error)
- func (c *Client) Nonce() (string, error)
- func (c *Client) Org(ctx context.Context, id string) (*v1.OrgResponse, error)
- func (c *Client) OrgMemberAdd(ctx context.Context, orgID, email, role string) (*v1.OrgMembersResponse, error)
- func (c *Client) OrgMemberRemove(ctx context.Context, orgID, memberID string) (*v1.OrgMembersResponse, error)
- func (c *Client) OrgMembers(ctx context.Context, orgID string) (*v1.OrgMembersResponse, error)
- func (c *Client) Orgs(ctx context.Context) (*v1.OrgsResponse, error)
- func (c *Client) Post(ctx context.Context, path string, body []byte, responseBody interface{}) (http.Header, int, error)
- func (c *Client) PostRequest(ctx context.Context, path string, requestBody interface{}, ...) (http.Header, int, error)
- func (c *Client) PostRequestTo(ctx context.Context, hosts []string, path string, requestBody interface{}, ...) (http.Header, int, error)
- func (c *Client) PostTo(ctx context.Context, hosts []string, path string, body []byte, ...) (http.Header, int, error)
- func (c *Client) RefreshToken(ctx context.Context) (*v1.AuthTokenRefreshResponse, error)
- func (c *Client) RegisterOrg(ctx context.Context, filerID string) (*v1.OrgResponse, error)
- func (c *Client) Retriable() *retriable.Client
- func (c *Client) SearchCorps(ctx context.Context, name, jurisdiction string) (*v1.SearchOpenCorporatesResponse, error)
- func (c *Client) SearchOrgs(ctx context.Context, frn, regID string) (*v1.OrgsResponse, error)
- func (c *Client) ValidateOrg(ctx context.Context, orgID string) (*v1.ValidateOrgResponse, error)
- func (c *Client) WithAuthorization() *Client
- func (c *Client) WithHeaders(headers map[string]string) *Client
- func (c *Client) WithNonce(noncePath string) *Client
- func (c *Client) WithPolicy(r *retriable.Policy) *Client
- type Config
- type GenericHTTP
- type MartiniClient
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcmeClient ¶
type AcmeClient interface { // Directory returns directory response Directory(ctx context.Context) (map[string]string, error) }
AcmeClient interface
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents a logical connection to a Trusty cluster, it is safe for concurrent use across multiple go-routines.
func New ¶
New creates a new Trusty Client based on the supplied cluster members there needs to be at least one member from the cluster, starting from that the cluster membership, leader etc will be discovered. The Client is based on the supplied config, but the config is not referenced again after this [i.e. you can twiddle the config object you supply after you've created a client, and it'll make no difference to existing clients]
func (*Client) ApproveOrg ¶
func (c *Client) ApproveOrg(ctx context.Context, token, code, action string) (*v1.OrgResponse, error)
ApproveOrg approves Org registration
func (*Client) Certificates ¶
Certificates returns user's Certificates
func (*Client) CreateSubscription ¶
func (c *Client) CreateSubscription(ctx context.Context, req *v1.CreateSubscriptionRequest) (*v1.CreateSubscriptionResponse, error)
CreateSubscription pays for Org validation
func (*Client) CurrentHost ¶
CurrentHost returns the cluster member that is currently being used to service requests [typically this is the leader, but is not guaranteed to be so]
func (*Client) Delete ¶
func (c *Client) Delete(ctx context.Context, path string, body interface{}) (http.Header, int, error)
Delete removes the supplied resource using the current selected cluster member [typically the leader], it will decode the response payload into the supplied body parameter. it returns the HTTP status code, and an optional error for responses with status codes >= 300 it will try and convert the response into an go error. If configured, this call will wait & retry on rate limit and leader election errors path should be an absolute URI path, i.e. /foo/bar/baz
func (*Client) FccContact ¶
FccContact returns Fcc FRN Contact
func (*Client) Get ¶
Get fetches the supplied resource using the current selected cluster member [typically the leader], it will decode the response payload into the supplied body parameter. it returns the HTTP status code, and an optional error for responses with status codes >= 300 it will try and convert the response into an go error. If configured, this call will wait & retry on rate limit and leader election errors path should be an absolute URI path, i.e. /foo/bar/baz
func (*Client) GetFrom ¶
func (c *Client) GetFrom(ctx context.Context, hosts []string, path string, body interface{}) (http.Header, int, error)
GetFrom is the same as Get but makes the request to the specified host. The list of hosts in hosts are tried until one succeeds you can use CurrentMembership to find out the hosts we think are currently part of the cluster. each host should include all the protocol/host/port preamble, e.g. http://foo.bar:3444 path should be an absolute URI path, i.e. /foo/bar/baz
func (*Client) GetOrgAPIKeys ¶
func (c *Client) GetOrgAPIKeys(ctx context.Context, orgID string) (*v1.GetOrgAPIKeysResponse, error)
GetOrgAPIKeys returns Org API keys
func (*Client) GetResponse ¶
func (c *Client) GetResponse(ctx context.Context, path string, body io.Writer) (http.Header, int, error)
GetResponse makes a GET request to the server, path should be an absolute URI path, i.e. /foo/bar/baz the resulting HTTP body will be returned into the supplied body parameter, and the http status code returned.
func (*Client) ListSubscriptions ¶
ListSubscriptions returns user's subscriptions
func (*Client) ListSubscriptionsProducts ¶
func (c *Client) ListSubscriptionsProducts(ctx context.Context) (*v1.SubscriptionsProductsResponse, error)
ListSubscriptionsProducts returns list of available products
func (*Client) OrgMemberAdd ¶
func (c *Client) OrgMemberAdd(ctx context.Context, orgID, email, role string) (*v1.OrgMembersResponse, error)
OrgMemberAdd adds a member to an org
func (*Client) OrgMemberRemove ¶
func (c *Client) OrgMemberRemove(ctx context.Context, orgID, memberID string) (*v1.OrgMembersResponse, error)
OrgMemberRemove removes a member from an org
func (*Client) OrgMembers ¶
OrgMembers returns org members
func (*Client) Post ¶
func (c *Client) Post(ctx context.Context, path string, body []byte, responseBody interface{}) (http.Header, int, error)
Post makes an HTTP POST to the supplied path. The HTTP response will be decoded into reponseBody, and the status code (and potentially an error) returned. It'll try and map errors (statusCode >= 300) into a go error, waits & retries for rate limiting errors will be applied based on the client config. path should be an absolute URI path, i.e. /foo/bar/baz
func (*Client) PostRequest ¶
func (c *Client) PostRequest(ctx context.Context, path string, requestBody interface{}, responseBody interface{}) (http.Header, int, error)
PostRequest makes an HTTP POST to the supplied path, serializing requestBody to json and sending that as the HTTP body. the HTTP response will be decoded into reponseBody, and the status code (and potentially an error) returned. It'll try and map errors (statusCode >= 300) into a go error, waits & retries for rate limiting errors will be applied based on the client config. path should be an absolute URI path, i.e. /foo/bar/baz
func (*Client) PostRequestTo ¶
func (c *Client) PostRequestTo(ctx context.Context, hosts []string, path string, requestBody interface{}, responseBody interface{}) (http.Header, int, error)
PostRequestTo is the same as Post, but to the specified host. [the supplied hosts are tried in order until one succeeds, or we run out] each host should include all the protocol/host/port preamble, e.g. http://foo.bar:3444 path should be an absolute URI path, i.e. /foo/bar/baz if set, the callers identity will be passed to Trusty via the X-Trusty-Identity header
func (*Client) PostTo ¶
func (c *Client) PostTo(ctx context.Context, hosts []string, path string, body []byte, responseBody interface{}) (http.Header, int, error)
PostTo is the same as Post, but to the specified host. [the supplied hosts are tried in order until one succeeds, or we run out] each host should include all the protocol/host/port preamble, e.g. http://foo.bar:3444 path should be an absolute URI path, i.e. /foo/bar/baz if set, the callers identity will be passed to Trusty via the X-Trusty-Identity header
func (*Client) RefreshToken ¶
RefreshToken returns AuthTokenRefreshResponse
func (*Client) RegisterOrg ¶
RegisterOrg starts Org registration flow
func (*Client) SearchCorps ¶
func (c *Client) SearchCorps(ctx context.Context, name, jurisdiction string) (*v1.SearchOpenCorporatesResponse, error)
SearchCorps returns SearchOpenCorporatesResponse
func (*Client) SearchOrgs ¶
SearchOrgs returns OrgsResponse
func (*Client) ValidateOrg ¶
ValidateOrg validates Org registration
func (*Client) WithAuthorization ¶
WithAuthorization sets Authorization token
func (*Client) WithHeaders ¶
WithHeaders adds additional headers to the request
type Config ¶
type Config struct { // TLS contains all the TLS/HTTPS configuration, at a minimum Certificates should be set to the client cert // [a client cert is required to communicate with Keydi] TLS *tls.Config `json:"-"` }
Config of the client, particularly around error & retry handling
type GenericHTTP ¶
type GenericHTTP interface { // Context returns the current context Context() context.Context // WithContext sets new context WithContext(ctx context.Context) *Client // Get makes a GET request to he CurrentHost, path should be an absolute URI path, i.e. /foo/bar/baz // the resulting HTTP body will be decoded into the supplied body parameter, and the // http status code returned. Get(ctx context.Context, path string, body interface{}) (http.Header, int, error) // GetResponse makes a GET request to the server, path should be an absolute URI path, i.e. /foo/bar/baz // the resulting HTTP body will be returned into the supplied body parameter, and the // http status code returned. GetResponse(ctx context.Context, path string, body io.Writer) (http.Header, int, error) // GetFrom is the same as Get but makes the request to the specified host. // The list of hosts in hosts are tried until one succeeds // you can use CurrentMembership to find out the hosts we think are currently // part of the cluster. // each host should include all the protocol/host/port preamble, e.g. http://foo.bar:3444 // path should be an absolute URI path, i.e. /foo/bar/baz GetFrom(ctx context.Context, hosts []string, path string, body interface{}) (http.Header, int, error) // PostRequest makes an HTTP POST to the supplied path, serializing requestBody to json and sending // that as the HTTP body. the HTTP response will be decoded into reponseBody, and the status // code (and potentially an error) returned. It'll try and map errors (statusCode >= 300) // into a go error, waits & retries for rate limiting errors will be applied based on the // client config. // path should be an absolute URI path, i.e. /foo/bar/baz PostRequest(ctx context.Context, path string, requestBody interface{}, responseBody interface{}) (http.Header, int, error) // PostRequestTo is the same as Post, but to the specified host. [the supplied hosts are // tried in order until one succeeds, or we run out] // each host should include all the protocol/host/port preamble, e.g. http://foo.bar:3444 // path should be an absolute URI path, i.e. /foo/bar/baz // if set, the callers identity will be passed to Trusty via the X-Trusty-Identity header PostRequestTo(ctx context.Context, hosts []string, path string, requestBody interface{}, responseBody interface{}) (http.Header, int, error) // Post makes an HTTP POST to the supplied path. // The HTTP response will be decoded into reponseBody, and the status // code (and potentially an error) returned. It'll try and map errors (statusCode >= 300) // into a go error, waits & retries for rate limiting errors will be applied based on the // client config. // path should be an absolute URI path, i.e. /foo/bar/baz Post(ctx context.Context, path string, body []byte, responseBody interface{}) (http.Header, int, error) // PostTo is the same as Post, but to the specified host. [the supplied hosts are // tried in order until one succeeds, or we run out] // each host should include all the protocol/host/port preamble, e.g. http://foo.bar:3444 // path should be an absolute URI path, i.e. /foo/bar/baz // if set, the callers identity will be passed to Trusty via the X-Trusty-Identity header PostTo(ctx context.Context, hosts []string, path string, body []byte, responseBody interface{}) (http.Header, int, error) // Delete makes a DELETE request to the CurrentHost, path should be an absolute URI path, i.e. /foo/bar/baz // the resulting HTTP body will be decoded into the supplied body parameter, and the // http status code returned. Delete(ctx context.Context, path string, body interface{}) (http.Header, int, error) }
GenericHTTP defines a number of generalized HTTP request handling wrappers
type MartiniClient ¶
type MartiniClient interface { // SearchCorps returns SearchOpenCorporatesResponse SearchCorps(ctx context.Context, name, jurisdiction string) (*v1.SearchOpenCorporatesResponse, error) // SearchOrgs returns OrgsResponse SearchOrgs(ctx context.Context, frn, regID string) (*v1.OrgsResponse, error) // Orgs returns user's Orgs Orgs(ctx context.Context) (*v1.OrgsResponse, error) // Org returns the organization Org(ctx context.Context, id string) (*v1.OrgResponse, error) // OrgMembers returns org members OrgMembers(ctx context.Context, orgID string) (*v1.OrgMembersResponse, error) // OrgMemberAdd adds a member to the org OrgMemberAdd(ctx context.Context, orgID, email, role string) (*v1.OrgMembersResponse, error) // OrgMemberRemove removes the member from the org OrgMemberRemove(ctx context.Context, orgID, memberID string) (*v1.OrgMembersResponse, error) // Certificates returns user's Certificates Certificates(ctx context.Context) (*v1.CertificatesResponse, error) // FccFRN returns Fcc FRN FccFRN(ctx context.Context, filerID string) (*v1.FccFrnResponse, error) // FccContact returns Fcc FRN Contact FccContact(ctx context.Context, frn string) (*v1.FccContactResponse, error) // RegisterOrg starts Org registration flow RegisterOrg(ctx context.Context, filerID string) (*v1.OrgResponse, error) // ApproveOrg approves Org registration ApproveOrg(ctx context.Context, token, code, action string) (*v1.OrgResponse, error) // ValidateOrg validates Org registration ValidateOrg(ctx context.Context, orgID string) (*v1.ValidateOrgResponse, error) // DeleteOrg deletes Org DeleteOrg(ctx context.Context, orgID string) error // GetOrgAPIKeys returns Org API keys GetOrgAPIKeys(ctx context.Context, orgID string) (*v1.GetOrgAPIKeysResponse, error) // CreateSubscription pays for Org validation CreateSubscription(ctx context.Context, req *v1.CreateSubscriptionRequest) (*v1.CreateSubscriptionResponse, error) // ListSubscriptions returns user's subscriptions ListSubscriptions(ctx context.Context) (*v1.ListSubscriptionsResponse, error) // ListSubscriptionsProducts returns list of available products ListSubscriptionsProducts(ctx context.Context) (*v1.SubscriptionsProductsResponse, error) }
MartiniClient client interface