mirror of
https://github.com/hanzo-go/sdk.git
synced 2026-11-20 20:13:42 +00:00
228 lines
7.3 KiB
Go
228 lines
7.3 KiB
Go
/*
|
|
Hanzo Cloud API
|
|
|
|
The Hanzo Cloud API as a customer calls it: every operation under /v1/ except the operator's admin product, relay routes, legacy spellings and capabilities still reached by flag. Tagged by product: the first path segment after /v1/.
|
|
|
|
API version: v1
|
|
*/
|
|
|
|
// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT.
|
|
|
|
package hanzoai
|
|
|
|
import (
|
|
"bytes"
|
|
"context"
|
|
"io"
|
|
"net/http"
|
|
"net/url"
|
|
)
|
|
|
|
// AuditAPIService AuditAPI service
|
|
type AuditAPIService service
|
|
|
|
type AuditAPIGetAuditRequest struct {
|
|
ctx context.Context
|
|
ApiService *AuditAPIService
|
|
sub *string
|
|
action *string
|
|
resource *string
|
|
resourceId *string
|
|
result *string
|
|
since *string
|
|
until *string
|
|
pageSize *string
|
|
p *string
|
|
}
|
|
|
|
// Sub narrows the trail to one actor — the validated subject that made the request. Blank means every actor in the org.
|
|
func (r AuditAPIGetAuditRequest) Sub(sub string) AuditAPIGetAuditRequest {
|
|
r.sub = &sub
|
|
return r
|
|
}
|
|
|
|
// Action narrows it to one action name, e.g. \"machine.create\".
|
|
func (r AuditAPIGetAuditRequest) Action(action string) AuditAPIGetAuditRequest {
|
|
r.action = &action
|
|
return r
|
|
}
|
|
|
|
// Resource narrows it to one resource TYPE, e.g. \"apikey\".
|
|
func (r AuditAPIGetAuditRequest) Resource(resource string) AuditAPIGetAuditRequest {
|
|
r.resource = &resource
|
|
return r
|
|
}
|
|
|
|
// ResourceID narrows it to one resource instance.
|
|
func (r AuditAPIGetAuditRequest) ResourceId(resourceId string) AuditAPIGetAuditRequest {
|
|
r.resourceId = &resourceId
|
|
return r
|
|
}
|
|
|
|
// Result narrows it to one outcome: \"success\", \"deny\" or \"error\".
|
|
func (r AuditAPIGetAuditRequest) Result(result string) AuditAPIGetAuditRequest {
|
|
r.result = &result
|
|
return r
|
|
}
|
|
|
|
// Since is the inclusive lower time bound, RFC3339. An unparseable value is ignored rather than refused — one malformed filter must not hide the trail.
|
|
func (r AuditAPIGetAuditRequest) Since(since string) AuditAPIGetAuditRequest {
|
|
r.since = &since
|
|
return r
|
|
}
|
|
|
|
// Until is the upper time bound, RFC3339, with the same tolerance.
|
|
func (r AuditAPIGetAuditRequest) Until(until string) AuditAPIGetAuditRequest {
|
|
r.until = &until
|
|
return r
|
|
}
|
|
|
|
// PageSize is rows per page, default 100. A value that is not a positive integer falls back to the default.
|
|
func (r AuditAPIGetAuditRequest) PageSize(pageSize string) AuditAPIGetAuditRequest {
|
|
r.pageSize = &pageSize
|
|
return r
|
|
}
|
|
|
|
// Page is the 1-based page number, driving the offset. Anything below 2 reads the first page.
|
|
func (r AuditAPIGetAuditRequest) P(p string) AuditAPIGetAuditRequest {
|
|
r.p = &p
|
|
return r
|
|
}
|
|
|
|
func (r AuditAPIGetAuditRequest) Execute() (*AuditTrailPage, *http.Response, error) {
|
|
return r.ApiService.GetAuditExecute(r)
|
|
}
|
|
|
|
/*
|
|
GetAudit Reads the caller's OWN org audit trail, newest first, with the total the filter matched so a console can page it.
|
|
|
|
Reads the caller's OWN org audit trail, newest first, with the total the
|
|
filter matched so a console can page it.
|
|
|
|
Every filter is optional and applies WITHIN the caller's org — the org itself is
|
|
the validated principal's and can never be widened by a request. Fails closed:
|
|
an absent principal is a true "not signed in" (401), and a deployment with no
|
|
local tamper-evident store answers an honest 501 rather than silently serving
|
|
somebody else's trail.
|
|
|
|
@param ctx context.Context - for authentication, logging, cancellation, deadlines, tracing, etc. Passed from http.Request or context.Background().
|
|
@return AuditAPIGetAuditRequest
|
|
*/
|
|
func (a *AuditAPIService) GetAudit(ctx context.Context) AuditAPIGetAuditRequest {
|
|
return AuditAPIGetAuditRequest{
|
|
ApiService: a,
|
|
ctx: ctx,
|
|
}
|
|
}
|
|
|
|
// Execute executes the request
|
|
//
|
|
// @return AuditTrailPage
|
|
func (a *AuditAPIService) GetAuditExecute(r AuditAPIGetAuditRequest) (*AuditTrailPage, *http.Response, error) {
|
|
var (
|
|
localVarHTTPMethod = http.MethodGet
|
|
localVarPostBody interface{}
|
|
formFiles []formFile
|
|
localVarReturnValue *AuditTrailPage
|
|
)
|
|
|
|
localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "AuditAPIService.GetAudit")
|
|
if err != nil {
|
|
return localVarReturnValue, nil, &GenericOpenAPIError{error: err.Error()}
|
|
}
|
|
|
|
localVarPath := localBasePath + "/v1/audit"
|
|
|
|
localVarHeaderParams := make(map[string]string)
|
|
localVarQueryParams := url.Values{}
|
|
localVarFormParams := url.Values{}
|
|
|
|
if r.sub != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "sub", r.sub, "form", "")
|
|
}
|
|
if r.action != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "action", r.action, "form", "")
|
|
}
|
|
if r.resource != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "resource", r.resource, "form", "")
|
|
}
|
|
if r.resourceId != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "resourceId", r.resourceId, "form", "")
|
|
}
|
|
if r.result != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "result", r.result, "form", "")
|
|
}
|
|
if r.since != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "since", r.since, "form", "")
|
|
}
|
|
if r.until != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "until", r.until, "form", "")
|
|
}
|
|
if r.pageSize != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "pageSize", r.pageSize, "form", "")
|
|
}
|
|
if r.p != nil {
|
|
parameterAddToHeaderOrQuery(localVarQueryParams, "p", r.p, "form", "")
|
|
}
|
|
// to determine the Content-Type header
|
|
localVarHTTPContentTypes := []string{}
|
|
|
|
// set Content-Type header
|
|
localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes)
|
|
if localVarHTTPContentType != "" {
|
|
localVarHeaderParams["Content-Type"] = localVarHTTPContentType
|
|
}
|
|
|
|
// to determine the Accept header
|
|
localVarHTTPHeaderAccepts := []string{"application/json", "application/problem+json"}
|
|
|
|
// set Accept header
|
|
localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts)
|
|
if localVarHTTPHeaderAccept != "" {
|
|
localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept
|
|
}
|
|
req, err := a.client.prepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, formFiles)
|
|
if err != nil {
|
|
return localVarReturnValue, nil, err
|
|
}
|
|
|
|
localVarHTTPResponse, err := a.client.callAPI(req)
|
|
if err != nil || localVarHTTPResponse == nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
localVarBody, err := io.ReadAll(localVarHTTPResponse.Body)
|
|
localVarHTTPResponse.Body.Close()
|
|
localVarHTTPResponse.Body = io.NopCloser(bytes.NewBuffer(localVarBody))
|
|
if err != nil {
|
|
return localVarReturnValue, localVarHTTPResponse, err
|
|
}
|
|
|
|
if localVarHTTPResponse.StatusCode >= 300 {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: localVarHTTPResponse.Status,
|
|
}
|
|
var v ProblemDetails
|
|
err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr.error = err.Error()
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
newErr.error = formatErrorMessage(localVarHTTPResponse.Status, &v)
|
|
newErr.model = v
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
|
|
if err != nil {
|
|
newErr := &GenericOpenAPIError{
|
|
body: localVarBody,
|
|
error: err.Error(),
|
|
}
|
|
return localVarReturnValue, localVarHTTPResponse, newErr
|
|
}
|
|
|
|
return localVarReturnValue, localVarHTTPResponse, nil
|
|
}
|