Documentation ¶
Index ¶
- func DefaultBackoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration
- func DefaultRetryPolicy(resp *http.Response, err error) (bool, error)
- type Backoff
- type CheckForRetry
- type Client
- func (a *Client) CheckInspectionReportExportCompletion(ctx context.Context, auditID string, messageID string) (*InspectionReportExportCompletionResponse, error)
- func (a *Client) DownloadInspectionReportFile(ctx context.Context, url string) (io.ReadCloser, error)
- func (a *Client) DrainAccountActivityHistoryLog(ctx context.Context, req *GetAccountsActivityLogRequestParams, ...) error
- func (a *Client) DrainFeed(ctx context.Context, request *GetFeedRequest, ...) error
- func (a *Client) DrainInspections(ctx context.Context, params *ListInspectionsParams, ...) error
- func (a *Client) GetFeed(ctx context.Context, request *GetFeedRequest) (*GetFeedResponse, error)
- func (a *Client) GetInspection(ctx context.Context, id string) (*json.RawMessage, error)
- func (a *Client) GetMedia(ctx context.Context, request *GetMediaRequest) (*GetMediaResponse, error)
- func (a *Client) HTTPClient() *http.Client
- func (a *Client) HTTPTransport() *http.Transport
- func (a *Client) InitiateInspectionReportExport(ctx context.Context, auditID string, format string, preferenceID string) (string, error)
- func (a *Client) ListInspections(ctx context.Context, params *ListInspectionsParams) (*ListInspectionsResponse, error)
- func (a *Client) ListOrganisationActivityLog(ctx context.Context, request *GetAccountsActivityLogRequestParams) (*GetAccountsActivityLogResponse, error)
- func (a *Client) WhoAmI(ctx context.Context) (*WhoAmIResponse, error)
- type FeedMetadata
- type GetAccountsActivityLogRequestParams
- type GetAccountsActivityLogResponse
- type GetFeedParams
- type GetFeedRequest
- type GetFeedResponse
- type GetMediaRequest
- type GetMediaResponse
- type HTTPDoer
- type Header
- type Inspection
- type InspectionReportExportCompletionResponse
- type ListInspectionsParams
- type ListInspectionsResponse
- type Opt
- type WhoAmIResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultBackoff ¶
DefaultBackoff provides a default callback for Backoff which will perform exponential backoff based on the attempt number and limited by the provided minimum and maximum durations. It also tries to parse XRateLimitReset response header when a http.StatusTooManyRequests (HTTP Code 429) is found in the resp parameter. Hence it will return the number of seconds the server states it may be ready to process more requests from this client.
Types ¶
type Backoff ¶
Backoff specifies a policy for how long to wait between retries. It is called after a failing request to determine the amount of time that should pass before trying again.
type CheckForRetry ¶
CheckForRetry specifies a policy for handling retries. It is called following each request with the response and error values returned by the http.Client. If it returns false, the Client stops retrying and returns the response to the caller. If it returns an error, that error value is returned in lieu of the error from the request.
type Client ¶
type Client struct { Duration time.Duration CheckForRetry CheckForRetry Backoff Backoff RetryMax int RetryWaitMin time.Duration RetryWaitMax time.Duration // contains filtered or unexported fields }
Client is used to with iAuditor API's.
func GetTestClient ¶
GetTestClient creates a new test apiClient
func (*Client) CheckInspectionReportExportCompletion ¶
func (a *Client) CheckInspectionReportExportCompletion(ctx context.Context, auditID string, messageID string) (*InspectionReportExportCompletionResponse, error)
CheckInspectionReportExportCompletion checks if the report export is complete.
func (*Client) DownloadInspectionReportFile ¶
func (a *Client) DownloadInspectionReportFile(ctx context.Context, url string) (io.ReadCloser, error)
DownloadInspectionReportFile downloads the report file of the inspection.
func (*Client) DrainAccountActivityHistoryLog ¶
func (a *Client) DrainAccountActivityHistoryLog(ctx context.Context, req *GetAccountsActivityLogRequestParams, feedFn func(*GetAccountsActivityLogResponse) error) error
DrainAccountActivityHistoryLog cycle throgh GetAccountsActivityLogResponse and adapts the filter whule there is a next page
func (*Client) DrainFeed ¶
func (a *Client) DrainFeed(ctx context.Context, request *GetFeedRequest, feedFn func(*GetFeedResponse) error) error
DrainFeed fetches the data in batches and triggers the callback for each batch.
func (*Client) DrainInspections ¶
func (a *Client) DrainInspections( ctx context.Context, params *ListInspectionsParams, callback func(*ListInspectionsResponse) error, ) error
DrainInspections fetches the inspections in batches and triggers the callback for each batch.
func (*Client) GetFeed ¶
func (a *Client) GetFeed(ctx context.Context, request *GetFeedRequest) (*GetFeedResponse, error)
GetFeed executes the feed request and
func (*Client) GetInspection ¶
GetInspection retrieves the inspection of the given id.
func (*Client) GetMedia ¶
func (a *Client) GetMedia(ctx context.Context, request *GetMediaRequest) (*GetMediaResponse, error)
GetMedia fetches the media object from iAuditor.
func (*Client) HTTPClient ¶
HTTPClient returns the http Client used by APIClient
func (*Client) HTTPTransport ¶
HTTPTransport returns the http Transport used by APIClient
func (*Client) InitiateInspectionReportExport ¶
func (a *Client) InitiateInspectionReportExport(ctx context.Context, auditID string, format string, preferenceID string) (string, error)
InitiateInspectionReportExport export the report of the given auditID.
func (*Client) ListInspections ¶
func (a *Client) ListInspections(ctx context.Context, params *ListInspectionsParams) (*ListInspectionsResponse, error)
ListInspections retrieves the list of inspections from iAuditor
func (*Client) ListOrganisationActivityLog ¶
func (a *Client) ListOrganisationActivityLog(ctx context.Context, request *GetAccountsActivityLogRequestParams) (*GetAccountsActivityLogResponse, error)
ListOrganisationActivityLog returns response from AccountsActivityLog or error
type FeedMetadata ¶
type FeedMetadata struct { NextPage string `json:"next_page"` RemainingRecords int64 `json:"remaining_records"` }
FeedMetadata is a representation of the metadata returned when fetching a feed
type GetAccountsActivityLogRequestParams ¶
type GetAccountsActivityLogRequestParams struct { OrgID string `json:"org_id"` PageSize int `json:"page_size"` PageToken string `json:"page_token"` Filters accountsActivityLogFilter `json:"filters"` }
GetAccountsActivityLogRequestParams contains fields required to make a post request to activity log history api
func NewGetAccountsActivityLogRequest ¶
func NewGetAccountsActivityLogRequest(pageSize int, from time.Time) *GetAccountsActivityLogRequestParams
NewGetAccountsActivityLogRequest build a request for AccountsActivityLog for now it serves the purposes only for inspection.deleted. If we need later, we can change this builder
type GetAccountsActivityLogResponse ¶
type GetAccountsActivityLogResponse struct { Activities []activityResponse NextPageToken string `json:"next_page_token"` }
GetAccountsActivityLogResponse is the response from activity log history api
type GetFeedParams ¶
type GetFeedParams struct { ModifiedAfter time.Time `url:"modified_after,omitempty"` TemplateIDs []string `url:"template,omitempty"` Archived string `url:"archived,omitempty"` Completed string `url:"completed,omitempty"` IncludeInactive bool `url:"include_inactive,omitempty"` Limit int `url:"limit,omitempty"` WebReportLink string `url:"web_report_link,omitempty"` // Applicable only for sites IncludeDeleted bool `url:"include_deleted,omitempty"` ShowOnlyLeafNodes *bool `url:"show_only_leaf_nodes,omitempty"` }
GetFeedParams is a list of all parameters we can set when fetching a feed
type GetFeedRequest ¶
type GetFeedRequest struct { URL string InitialURL string Params GetFeedParams }
GetFeedRequest has all the data needed to make a request to get a feed
type GetFeedResponse ¶
type GetFeedResponse struct { Metadata FeedMetadata `json:"metadata"` Data json.RawMessage `json:"data"` }
GetFeedResponse is a representation of the data returned when fetching a feed
type GetMediaRequest ¶
GetMediaRequest has all the data needed to make a request to get a media
type GetMediaResponse ¶
GetMediaResponse is a representation of the data returned when fetching media
type Header ¶
type Header string
Header is used to represent name of a header
const ( Authorization Header = "Authorization" ContentType Header = "Content-Type" XRequestID Header = "X-Request-ID" IntegrationID Header = "sc-integration-id" IntegrationVersion Header = "sc-integration-version" XRateLimitReset Header = "X-RateLimit-Reset" )
Headers that are sent with each request when making api calls
type Inspection ¶
Inspection represents some properties present in an inspection
type InspectionReportExportCompletionResponse ¶
type InspectionReportExportCompletionResponse struct { Status string `json:"status"` URL string `json:"url,omitempty"` }
InspectionReportExportCompletionResponse represents the response of report export completion status
type ListInspectionsParams ¶
type ListInspectionsParams struct { ModifiedAfter time.Time `url:"modified_after,omitempty"` TemplateIDs []string `url:"template,omitempty"` Archived string `url:"archived,omitempty"` Completed string `url:"completed,omitempty"` Limit int `url:"limit,omitempty"` }
ListInspectionsParams is a list of all parameters we can set when fetching inspections
type ListInspectionsResponse ¶
type ListInspectionsResponse struct { Count int `json:"count"` Total int `json:"total"` Inspections []Inspection `json:"audits"` }
ListInspectionsResponse represents the response of listing inspections
type Opt ¶
type Opt func(*Client)
Opt is an option to configure the Client
func OptAddTLSCert ¶
OptAddTLSCert adds a certificate at the supplied path to the cert pool
func OptSetInsecureTLS ¶
OptSetInsecureTLS sets whether TLS certs should be verified
func OptSetProxy ¶
OptSetProxy sets the proxy URL to use for API requests
func OptSetTimeout ¶
OptSetTimeout sets the timeout for the request