5476 lines
147 KiB
Go
5476 lines
147 KiB
Go
// Code generated by ogen, DO NOT EDIT.
|
|
|
|
package api
|
|
|
|
import (
|
|
"context"
|
|
"net/url"
|
|
"strings"
|
|
"time"
|
|
|
|
"github.com/go-faster/errors"
|
|
"go.opentelemetry.io/otel/attribute"
|
|
"go.opentelemetry.io/otel/codes"
|
|
"go.opentelemetry.io/otel/metric"
|
|
semconv "go.opentelemetry.io/otel/semconv/v1.26.0"
|
|
"go.opentelemetry.io/otel/trace"
|
|
|
|
"github.com/ogen-go/ogen/conv"
|
|
ht "github.com/ogen-go/ogen/http"
|
|
"github.com/ogen-go/ogen/ogenerrors"
|
|
"github.com/ogen-go/ogen/otelogen"
|
|
"github.com/ogen-go/ogen/uri"
|
|
)
|
|
|
|
func trimTrailingSlashes(u *url.URL) {
|
|
u.Path = strings.TrimRight(u.Path, "/")
|
|
u.RawPath = strings.TrimRight(u.RawPath, "/")
|
|
}
|
|
|
|
// Invoker invokes operations described by OpenAPI v3 specification.
|
|
type Invoker interface {
|
|
// ActionMapfixAccepted invokes actionMapfixAccepted operation.
|
|
//
|
|
// Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/reset-validating
|
|
ActionMapfixAccepted(ctx context.Context, params ActionMapfixAcceptedParams) error
|
|
// ActionMapfixReject invokes actionMapfixReject operation.
|
|
//
|
|
// Role Reviewer changes status from Submitted -> Rejected.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/reject
|
|
ActionMapfixReject(ctx context.Context, params ActionMapfixRejectParams) error
|
|
// ActionMapfixRequestChanges invokes actionMapfixRequestChanges operation.
|
|
//
|
|
// Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/request-changes
|
|
ActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) error
|
|
// ActionMapfixRetryValidate invokes actionMapfixRetryValidate operation.
|
|
//
|
|
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/retry-validate
|
|
ActionMapfixRetryValidate(ctx context.Context, params ActionMapfixRetryValidateParams) error
|
|
// ActionMapfixRevoke invokes actionMapfixRevoke operation.
|
|
//
|
|
// Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/revoke
|
|
ActionMapfixRevoke(ctx context.Context, params ActionMapfixRevokeParams) error
|
|
// ActionMapfixSubmit invokes actionMapfixSubmit operation.
|
|
//
|
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/submit
|
|
ActionMapfixSubmit(ctx context.Context, params ActionMapfixSubmitParams) error
|
|
// ActionMapfixTriggerUpload invokes actionMapfixTriggerUpload operation.
|
|
//
|
|
// Role Admin changes status from Validated -> Uploading.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/trigger-upload
|
|
ActionMapfixTriggerUpload(ctx context.Context, params ActionMapfixTriggerUploadParams) error
|
|
// ActionMapfixTriggerValidate invokes actionMapfixTriggerValidate operation.
|
|
//
|
|
// Role Reviewer triggers validation and changes status from Submitted -> Validating.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/trigger-validate
|
|
ActionMapfixTriggerValidate(ctx context.Context, params ActionMapfixTriggerValidateParams) error
|
|
// ActionMapfixValidated invokes actionMapfixValidated operation.
|
|
//
|
|
// Role Admin manually resets uploading softlock and changes status from Uploading -> Validated.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/reset-uploading
|
|
ActionMapfixValidated(ctx context.Context, params ActionMapfixValidatedParams) error
|
|
// ActionSubmissionAccepted invokes actionSubmissionAccepted operation.
|
|
//
|
|
// Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/reset-validating
|
|
ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error
|
|
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
|
//
|
|
// Role Reviewer changes status from Submitted -> Rejected.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/reject
|
|
ActionSubmissionReject(ctx context.Context, params ActionSubmissionRejectParams) error
|
|
// ActionSubmissionRequestChanges invokes actionSubmissionRequestChanges operation.
|
|
//
|
|
// Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/request-changes
|
|
ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error
|
|
// ActionSubmissionRetryValidate invokes actionSubmissionRetryValidate operation.
|
|
//
|
|
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/retry-validate
|
|
ActionSubmissionRetryValidate(ctx context.Context, params ActionSubmissionRetryValidateParams) error
|
|
// ActionSubmissionRevoke invokes actionSubmissionRevoke operation.
|
|
//
|
|
// Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/revoke
|
|
ActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) error
|
|
// ActionSubmissionSubmit invokes actionSubmissionSubmit operation.
|
|
//
|
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/submit
|
|
ActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) error
|
|
// ActionSubmissionTriggerUpload invokes actionSubmissionTriggerUpload operation.
|
|
//
|
|
// Role Admin changes status from Validated -> Uploading.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/trigger-upload
|
|
ActionSubmissionTriggerUpload(ctx context.Context, params ActionSubmissionTriggerUploadParams) error
|
|
// ActionSubmissionTriggerValidate invokes actionSubmissionTriggerValidate operation.
|
|
//
|
|
// Role Reviewer triggers validation and changes status from Submitted -> Validating.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/trigger-validate
|
|
ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error
|
|
// ActionSubmissionValidated invokes actionSubmissionValidated operation.
|
|
//
|
|
// Role Admin manually resets uploading softlock and changes status from Uploading -> Validated.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/reset-uploading
|
|
ActionSubmissionValidated(ctx context.Context, params ActionSubmissionValidatedParams) error
|
|
// CreateMapfix invokes createMapfix operation.
|
|
//
|
|
// Create new mapfix.
|
|
//
|
|
// POST /mapfixes
|
|
CreateMapfix(ctx context.Context, request *MapfixCreate) (*ID, error)
|
|
// CreateScript invokes createScript operation.
|
|
//
|
|
// Create a new script.
|
|
//
|
|
// POST /scripts
|
|
CreateScript(ctx context.Context, request *ScriptCreate) (*ID, error)
|
|
// CreateScriptPolicy invokes createScriptPolicy operation.
|
|
//
|
|
// Create a new script policy.
|
|
//
|
|
// POST /script-policy
|
|
CreateScriptPolicy(ctx context.Context, request *ScriptPolicyCreate) (*ID, error)
|
|
// CreateSubmission invokes createSubmission operation.
|
|
//
|
|
// Create new submission.
|
|
//
|
|
// POST /submissions
|
|
CreateSubmission(ctx context.Context, request *SubmissionCreate) (*ID, error)
|
|
// DeleteScript invokes deleteScript operation.
|
|
//
|
|
// Delete the specified script by ID.
|
|
//
|
|
// DELETE /scripts/{ScriptID}
|
|
DeleteScript(ctx context.Context, params DeleteScriptParams) error
|
|
// DeleteScriptPolicy invokes deleteScriptPolicy operation.
|
|
//
|
|
// Delete the specified script policy by ID.
|
|
//
|
|
// DELETE /script-policy/{ScriptPolicyID}
|
|
DeleteScriptPolicy(ctx context.Context, params DeleteScriptPolicyParams) error
|
|
// GetMapfix invokes getMapfix operation.
|
|
//
|
|
// Retrieve map with ID.
|
|
//
|
|
// GET /mapfixes/{MapfixID}
|
|
GetMapfix(ctx context.Context, params GetMapfixParams) (*Mapfix, error)
|
|
// GetScript invokes getScript operation.
|
|
//
|
|
// Get the specified script by ID.
|
|
//
|
|
// GET /scripts/{ScriptID}
|
|
GetScript(ctx context.Context, params GetScriptParams) (*Script, error)
|
|
// GetScriptPolicy invokes getScriptPolicy operation.
|
|
//
|
|
// Get the specified script policy by ID.
|
|
//
|
|
// GET /script-policy/{ScriptPolicyID}
|
|
GetScriptPolicy(ctx context.Context, params GetScriptPolicyParams) (*ScriptPolicy, error)
|
|
// GetSubmission invokes getSubmission operation.
|
|
//
|
|
// Retrieve map with ID.
|
|
//
|
|
// GET /submissions/{SubmissionID}
|
|
GetSubmission(ctx context.Context, params GetSubmissionParams) (*Submission, error)
|
|
// ListMapfixes invokes listMapfixes operation.
|
|
//
|
|
// Get list of mapfixes.
|
|
//
|
|
// GET /mapfixes
|
|
ListMapfixes(ctx context.Context, params ListMapfixesParams) ([]Mapfix, error)
|
|
// ListScriptPolicy invokes listScriptPolicy operation.
|
|
//
|
|
// Get list of script policies.
|
|
//
|
|
// GET /script-policy
|
|
ListScriptPolicy(ctx context.Context, params ListScriptPolicyParams) ([]ScriptPolicy, error)
|
|
// ListScripts invokes listScripts operation.
|
|
//
|
|
// Get list of scripts.
|
|
//
|
|
// GET /scripts
|
|
ListScripts(ctx context.Context, params ListScriptsParams) ([]Script, error)
|
|
// ListSubmissions invokes listSubmissions operation.
|
|
//
|
|
// Get list of submissions.
|
|
//
|
|
// GET /submissions
|
|
ListSubmissions(ctx context.Context, params ListSubmissionsParams) ([]Submission, error)
|
|
// ReleaseSubmissions invokes releaseSubmissions operation.
|
|
//
|
|
// Release a set of uploaded maps.
|
|
//
|
|
// POST /release-submissions
|
|
ReleaseSubmissions(ctx context.Context, request []ReleaseInfo) error
|
|
// SessionRoles invokes sessionRoles operation.
|
|
//
|
|
// Get list of roles for the current session.
|
|
//
|
|
// GET /session/roles
|
|
SessionRoles(ctx context.Context) (*Roles, error)
|
|
// SessionUser invokes sessionUser operation.
|
|
//
|
|
// Get information about the currently logged in user.
|
|
//
|
|
// GET /session/user
|
|
SessionUser(ctx context.Context) (*User, error)
|
|
// SessionValidate invokes sessionValidate operation.
|
|
//
|
|
// Ask if the current session is valid.
|
|
//
|
|
// GET /session/validate
|
|
SessionValidate(ctx context.Context) (bool, error)
|
|
// SetMapfixCompleted invokes setMapfixCompleted operation.
|
|
//
|
|
// Called by maptest when a player completes the map.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/completed
|
|
SetMapfixCompleted(ctx context.Context, params SetMapfixCompletedParams) error
|
|
// SetSubmissionCompleted invokes setSubmissionCompleted operation.
|
|
//
|
|
// Called by maptest when a player completes the map.
|
|
//
|
|
// POST /submissions/{SubmissionID}/completed
|
|
SetSubmissionCompleted(ctx context.Context, params SetSubmissionCompletedParams) error
|
|
// UpdateMapfixModel invokes updateMapfixModel operation.
|
|
//
|
|
// Update model following role restrictions.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/model
|
|
UpdateMapfixModel(ctx context.Context, params UpdateMapfixModelParams) error
|
|
// UpdateScript invokes updateScript operation.
|
|
//
|
|
// Update the specified script by ID.
|
|
//
|
|
// POST /scripts/{ScriptID}
|
|
UpdateScript(ctx context.Context, request *ScriptUpdate, params UpdateScriptParams) error
|
|
// UpdateScriptPolicy invokes updateScriptPolicy operation.
|
|
//
|
|
// Update the specified script policy by ID.
|
|
//
|
|
// POST /script-policy/{ScriptPolicyID}
|
|
UpdateScriptPolicy(ctx context.Context, request *ScriptPolicyUpdate, params UpdateScriptPolicyParams) error
|
|
// UpdateSubmissionModel invokes updateSubmissionModel operation.
|
|
//
|
|
// Update model following role restrictions.
|
|
//
|
|
// POST /submissions/{SubmissionID}/model
|
|
UpdateSubmissionModel(ctx context.Context, params UpdateSubmissionModelParams) error
|
|
}
|
|
|
|
// Client implements OAS client.
|
|
type Client struct {
|
|
serverURL *url.URL
|
|
sec SecuritySource
|
|
baseClient
|
|
}
|
|
type errorHandler interface {
|
|
NewError(ctx context.Context, err error) *ErrorStatusCode
|
|
}
|
|
|
|
var _ Handler = struct {
|
|
errorHandler
|
|
*Client
|
|
}{}
|
|
|
|
// NewClient initializes new Client defined by OAS.
|
|
func NewClient(serverURL string, sec SecuritySource, opts ...ClientOption) (*Client, error) {
|
|
u, err := url.Parse(serverURL)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
trimTrailingSlashes(u)
|
|
|
|
c, err := newClientConfig(opts...).baseClient()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return &Client{
|
|
serverURL: u,
|
|
sec: sec,
|
|
baseClient: c,
|
|
}, nil
|
|
}
|
|
|
|
type serverURLKey struct{}
|
|
|
|
// WithServerURL sets context key to override server URL.
|
|
func WithServerURL(ctx context.Context, u *url.URL) context.Context {
|
|
return context.WithValue(ctx, serverURLKey{}, u)
|
|
}
|
|
|
|
func (c *Client) requestURL(ctx context.Context) *url.URL {
|
|
u, ok := ctx.Value(serverURLKey{}).(*url.URL)
|
|
if !ok {
|
|
return c.serverURL
|
|
}
|
|
return u
|
|
}
|
|
|
|
// ActionMapfixAccepted invokes actionMapfixAccepted operation.
|
|
//
|
|
// Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/reset-validating
|
|
func (c *Client) ActionMapfixAccepted(ctx context.Context, params ActionMapfixAcceptedParams) error {
|
|
_, err := c.sendActionMapfixAccepted(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionMapfixAccepted(ctx context.Context, params ActionMapfixAcceptedParams) (res *ActionMapfixAcceptedNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionMapfixAccepted"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/reset-validating"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixAcceptedOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/reset-validating"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionMapfixAcceptedOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionMapfixAcceptedResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionMapfixReject invokes actionMapfixReject operation.
|
|
//
|
|
// Role Reviewer changes status from Submitted -> Rejected.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/reject
|
|
func (c *Client) ActionMapfixReject(ctx context.Context, params ActionMapfixRejectParams) error {
|
|
_, err := c.sendActionMapfixReject(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionMapfixReject(ctx context.Context, params ActionMapfixRejectParams) (res *ActionMapfixRejectNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionMapfixReject"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/reject"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixRejectOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/reject"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionMapfixRejectOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionMapfixRejectResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionMapfixRequestChanges invokes actionMapfixRequestChanges operation.
|
|
//
|
|
// Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/request-changes
|
|
func (c *Client) ActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) error {
|
|
_, err := c.sendActionMapfixRequestChanges(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionMapfixRequestChanges(ctx context.Context, params ActionMapfixRequestChangesParams) (res *ActionMapfixRequestChangesNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionMapfixRequestChanges"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/request-changes"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixRequestChangesOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/request-changes"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionMapfixRequestChangesOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionMapfixRequestChangesResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionMapfixRetryValidate invokes actionMapfixRetryValidate operation.
|
|
//
|
|
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/retry-validate
|
|
func (c *Client) ActionMapfixRetryValidate(ctx context.Context, params ActionMapfixRetryValidateParams) error {
|
|
_, err := c.sendActionMapfixRetryValidate(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionMapfixRetryValidate(ctx context.Context, params ActionMapfixRetryValidateParams) (res *ActionMapfixRetryValidateNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionMapfixRetryValidate"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/retry-validate"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixRetryValidateOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/retry-validate"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionMapfixRetryValidateOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionMapfixRetryValidateResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionMapfixRevoke invokes actionMapfixRevoke operation.
|
|
//
|
|
// Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/revoke
|
|
func (c *Client) ActionMapfixRevoke(ctx context.Context, params ActionMapfixRevokeParams) error {
|
|
_, err := c.sendActionMapfixRevoke(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionMapfixRevoke(ctx context.Context, params ActionMapfixRevokeParams) (res *ActionMapfixRevokeNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionMapfixRevoke"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/revoke"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixRevokeOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/revoke"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionMapfixRevokeOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionMapfixRevokeResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionMapfixSubmit invokes actionMapfixSubmit operation.
|
|
//
|
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/submit
|
|
func (c *Client) ActionMapfixSubmit(ctx context.Context, params ActionMapfixSubmitParams) error {
|
|
_, err := c.sendActionMapfixSubmit(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionMapfixSubmit(ctx context.Context, params ActionMapfixSubmitParams) (res *ActionMapfixSubmitNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionMapfixSubmit"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/submit"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixSubmitOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/submit"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionMapfixSubmitOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionMapfixSubmitResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionMapfixTriggerUpload invokes actionMapfixTriggerUpload operation.
|
|
//
|
|
// Role Admin changes status from Validated -> Uploading.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/trigger-upload
|
|
func (c *Client) ActionMapfixTriggerUpload(ctx context.Context, params ActionMapfixTriggerUploadParams) error {
|
|
_, err := c.sendActionMapfixTriggerUpload(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionMapfixTriggerUpload(ctx context.Context, params ActionMapfixTriggerUploadParams) (res *ActionMapfixTriggerUploadNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionMapfixTriggerUpload"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/trigger-upload"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixTriggerUploadOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/trigger-upload"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionMapfixTriggerUploadOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionMapfixTriggerUploadResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionMapfixTriggerValidate invokes actionMapfixTriggerValidate operation.
|
|
//
|
|
// Role Reviewer triggers validation and changes status from Submitted -> Validating.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/trigger-validate
|
|
func (c *Client) ActionMapfixTriggerValidate(ctx context.Context, params ActionMapfixTriggerValidateParams) error {
|
|
_, err := c.sendActionMapfixTriggerValidate(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionMapfixTriggerValidate(ctx context.Context, params ActionMapfixTriggerValidateParams) (res *ActionMapfixTriggerValidateNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionMapfixTriggerValidate"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/trigger-validate"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixTriggerValidateOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/trigger-validate"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionMapfixTriggerValidateOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionMapfixTriggerValidateResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionMapfixValidated invokes actionMapfixValidated operation.
|
|
//
|
|
// Role Admin manually resets uploading softlock and changes status from Uploading -> Validated.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/status/reset-uploading
|
|
func (c *Client) ActionMapfixValidated(ctx context.Context, params ActionMapfixValidatedParams) error {
|
|
_, err := c.sendActionMapfixValidated(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionMapfixValidated(ctx context.Context, params ActionMapfixValidatedParams) (res *ActionMapfixValidatedNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionMapfixValidated"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/status/reset-uploading"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionMapfixValidatedOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/reset-uploading"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionMapfixValidatedOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionMapfixValidatedResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionSubmissionAccepted invokes actionSubmissionAccepted operation.
|
|
//
|
|
// Role Reviewer manually resets validating softlock and changes status from Validating -> Accepted.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/reset-validating
|
|
func (c *Client) ActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) error {
|
|
_, err := c.sendActionSubmissionAccepted(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionSubmissionAccepted(ctx context.Context, params ActionSubmissionAcceptedParams) (res *ActionSubmissionAcceptedNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionSubmissionAccepted"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/reset-validating"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionAcceptedOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/reset-validating"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionAcceptedOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionSubmissionAcceptedResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionSubmissionReject invokes actionSubmissionReject operation.
|
|
//
|
|
// Role Reviewer changes status from Submitted -> Rejected.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/reject
|
|
func (c *Client) ActionSubmissionReject(ctx context.Context, params ActionSubmissionRejectParams) error {
|
|
_, err := c.sendActionSubmissionReject(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionSubmissionReject(ctx context.Context, params ActionSubmissionRejectParams) (res *ActionSubmissionRejectNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionSubmissionReject"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/reject"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionRejectOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/reject"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionRejectOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionSubmissionRejectResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionSubmissionRequestChanges invokes actionSubmissionRequestChanges operation.
|
|
//
|
|
// Role Reviewer changes status from Validated|Accepted|Submitted -> ChangesRequested.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/request-changes
|
|
func (c *Client) ActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) error {
|
|
_, err := c.sendActionSubmissionRequestChanges(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionSubmissionRequestChanges(ctx context.Context, params ActionSubmissionRequestChangesParams) (res *ActionSubmissionRequestChangesNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionSubmissionRequestChanges"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/request-changes"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionRequestChangesOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/request-changes"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionRequestChangesOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionSubmissionRequestChangesResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionSubmissionRetryValidate invokes actionSubmissionRetryValidate operation.
|
|
//
|
|
// Role Reviewer re-runs validation and changes status from Accepted -> Validating.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/retry-validate
|
|
func (c *Client) ActionSubmissionRetryValidate(ctx context.Context, params ActionSubmissionRetryValidateParams) error {
|
|
_, err := c.sendActionSubmissionRetryValidate(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionSubmissionRetryValidate(ctx context.Context, params ActionSubmissionRetryValidateParams) (res *ActionSubmissionRetryValidateNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionSubmissionRetryValidate"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/retry-validate"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionRetryValidateOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/retry-validate"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionRetryValidateOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionSubmissionRetryValidateResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionSubmissionRevoke invokes actionSubmissionRevoke operation.
|
|
//
|
|
// Role Submitter changes status from Submitted|ChangesRequested -> UnderConstruction.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/revoke
|
|
func (c *Client) ActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) error {
|
|
_, err := c.sendActionSubmissionRevoke(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionSubmissionRevoke(ctx context.Context, params ActionSubmissionRevokeParams) (res *ActionSubmissionRevokeNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionSubmissionRevoke"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/revoke"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionRevokeOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/revoke"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionRevokeOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionSubmissionRevokeResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionSubmissionSubmit invokes actionSubmissionSubmit operation.
|
|
//
|
|
// Role Submitter changes status from UnderConstruction|ChangesRequested -> Submitted.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/submit
|
|
func (c *Client) ActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) error {
|
|
_, err := c.sendActionSubmissionSubmit(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionSubmissionSubmit(ctx context.Context, params ActionSubmissionSubmitParams) (res *ActionSubmissionSubmitNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionSubmissionSubmit"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/submit"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionSubmitOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/submit"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionSubmitOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionSubmissionSubmitResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionSubmissionTriggerUpload invokes actionSubmissionTriggerUpload operation.
|
|
//
|
|
// Role Admin changes status from Validated -> Uploading.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/trigger-upload
|
|
func (c *Client) ActionSubmissionTriggerUpload(ctx context.Context, params ActionSubmissionTriggerUploadParams) error {
|
|
_, err := c.sendActionSubmissionTriggerUpload(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionSubmissionTriggerUpload(ctx context.Context, params ActionSubmissionTriggerUploadParams) (res *ActionSubmissionTriggerUploadNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionSubmissionTriggerUpload"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/trigger-upload"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionTriggerUploadOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/trigger-upload"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionTriggerUploadOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionSubmissionTriggerUploadResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionSubmissionTriggerValidate invokes actionSubmissionTriggerValidate operation.
|
|
//
|
|
// Role Reviewer triggers validation and changes status from Submitted -> Validating.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/trigger-validate
|
|
func (c *Client) ActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) error {
|
|
_, err := c.sendActionSubmissionTriggerValidate(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionSubmissionTriggerValidate(ctx context.Context, params ActionSubmissionTriggerValidateParams) (res *ActionSubmissionTriggerValidateNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionSubmissionTriggerValidate"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/trigger-validate"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionTriggerValidateOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/trigger-validate"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionTriggerValidateOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionSubmissionTriggerValidateResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ActionSubmissionValidated invokes actionSubmissionValidated operation.
|
|
//
|
|
// Role Admin manually resets uploading softlock and changes status from Uploading -> Validated.
|
|
//
|
|
// POST /submissions/{SubmissionID}/status/reset-uploading
|
|
func (c *Client) ActionSubmissionValidated(ctx context.Context, params ActionSubmissionValidatedParams) error {
|
|
_, err := c.sendActionSubmissionValidated(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendActionSubmissionValidated(ctx context.Context, params ActionSubmissionValidatedParams) (res *ActionSubmissionValidatedNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("actionSubmissionValidated"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/status/reset-uploading"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ActionSubmissionValidatedOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/status/reset-uploading"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ActionSubmissionValidatedOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeActionSubmissionValidatedResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// CreateMapfix invokes createMapfix operation.
|
|
//
|
|
// Create new mapfix.
|
|
//
|
|
// POST /mapfixes
|
|
func (c *Client) CreateMapfix(ctx context.Context, request *MapfixCreate) (*ID, error) {
|
|
res, err := c.sendCreateMapfix(ctx, request)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendCreateMapfix(ctx context.Context, request *MapfixCreate) (res *ID, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("createMapfix"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, CreateMapfixOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/mapfixes"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
if err := encodeCreateMapfixRequest(request, r); err != nil {
|
|
return res, errors.Wrap(err, "encode request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, CreateMapfixOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeCreateMapfixResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// CreateScript invokes createScript operation.
|
|
//
|
|
// Create a new script.
|
|
//
|
|
// POST /scripts
|
|
func (c *Client) CreateScript(ctx context.Context, request *ScriptCreate) (*ID, error) {
|
|
res, err := c.sendCreateScript(ctx, request)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendCreateScript(ctx context.Context, request *ScriptCreate) (res *ID, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("createScript"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/scripts"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, CreateScriptOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/scripts"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
if err := encodeCreateScriptRequest(request, r); err != nil {
|
|
return res, errors.Wrap(err, "encode request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, CreateScriptOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeCreateScriptResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// CreateScriptPolicy invokes createScriptPolicy operation.
|
|
//
|
|
// Create a new script policy.
|
|
//
|
|
// POST /script-policy
|
|
func (c *Client) CreateScriptPolicy(ctx context.Context, request *ScriptPolicyCreate) (*ID, error) {
|
|
res, err := c.sendCreateScriptPolicy(ctx, request)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendCreateScriptPolicy(ctx context.Context, request *ScriptPolicyCreate) (res *ID, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("createScriptPolicy"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/script-policy"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, CreateScriptPolicyOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/script-policy"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
if err := encodeCreateScriptPolicyRequest(request, r); err != nil {
|
|
return res, errors.Wrap(err, "encode request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, CreateScriptPolicyOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeCreateScriptPolicyResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// CreateSubmission invokes createSubmission operation.
|
|
//
|
|
// Create new submission.
|
|
//
|
|
// POST /submissions
|
|
func (c *Client) CreateSubmission(ctx context.Context, request *SubmissionCreate) (*ID, error) {
|
|
res, err := c.sendCreateSubmission(ctx, request)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendCreateSubmission(ctx context.Context, request *SubmissionCreate) (res *ID, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("createSubmission"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, CreateSubmissionOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/submissions"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
if err := encodeCreateSubmissionRequest(request, r); err != nil {
|
|
return res, errors.Wrap(err, "encode request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, CreateSubmissionOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeCreateSubmissionResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// DeleteScript invokes deleteScript operation.
|
|
//
|
|
// Delete the specified script by ID.
|
|
//
|
|
// DELETE /scripts/{ScriptID}
|
|
func (c *Client) DeleteScript(ctx context.Context, params DeleteScriptParams) error {
|
|
_, err := c.sendDeleteScript(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendDeleteScript(ctx context.Context, params DeleteScriptParams) (res *DeleteScriptNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("deleteScript"),
|
|
semconv.HTTPRequestMethodKey.String("DELETE"),
|
|
semconv.HTTPRouteKey.String("/scripts/{ScriptID}"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, DeleteScriptOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [2]string
|
|
pathParts[0] = "/scripts/"
|
|
{
|
|
// Encode "ScriptID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "ScriptID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.ScriptID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "DELETE", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, DeleteScriptOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeDeleteScriptResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// DeleteScriptPolicy invokes deleteScriptPolicy operation.
|
|
//
|
|
// Delete the specified script policy by ID.
|
|
//
|
|
// DELETE /script-policy/{ScriptPolicyID}
|
|
func (c *Client) DeleteScriptPolicy(ctx context.Context, params DeleteScriptPolicyParams) error {
|
|
_, err := c.sendDeleteScriptPolicy(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendDeleteScriptPolicy(ctx context.Context, params DeleteScriptPolicyParams) (res *DeleteScriptPolicyNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("deleteScriptPolicy"),
|
|
semconv.HTTPRequestMethodKey.String("DELETE"),
|
|
semconv.HTTPRouteKey.String("/script-policy/{ScriptPolicyID}"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, DeleteScriptPolicyOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [2]string
|
|
pathParts[0] = "/script-policy/"
|
|
{
|
|
// Encode "ScriptPolicyID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "ScriptPolicyID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.ScriptPolicyID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "DELETE", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, DeleteScriptPolicyOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeDeleteScriptPolicyResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// GetMapfix invokes getMapfix operation.
|
|
//
|
|
// Retrieve map with ID.
|
|
//
|
|
// GET /mapfixes/{MapfixID}
|
|
func (c *Client) GetMapfix(ctx context.Context, params GetMapfixParams) (*Mapfix, error) {
|
|
res, err := c.sendGetMapfix(ctx, params)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendGetMapfix(ctx context.Context, params GetMapfixParams) (res *Mapfix, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("getMapfix"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, GetMapfixOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [2]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeGetMapfixResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// GetScript invokes getScript operation.
|
|
//
|
|
// Get the specified script by ID.
|
|
//
|
|
// GET /scripts/{ScriptID}
|
|
func (c *Client) GetScript(ctx context.Context, params GetScriptParams) (*Script, error) {
|
|
res, err := c.sendGetScript(ctx, params)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendGetScript(ctx context.Context, params GetScriptParams) (res *Script, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("getScript"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/scripts/{ScriptID}"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, GetScriptOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [2]string
|
|
pathParts[0] = "/scripts/"
|
|
{
|
|
// Encode "ScriptID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "ScriptID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.ScriptID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeGetScriptResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// GetScriptPolicy invokes getScriptPolicy operation.
|
|
//
|
|
// Get the specified script policy by ID.
|
|
//
|
|
// GET /script-policy/{ScriptPolicyID}
|
|
func (c *Client) GetScriptPolicy(ctx context.Context, params GetScriptPolicyParams) (*ScriptPolicy, error) {
|
|
res, err := c.sendGetScriptPolicy(ctx, params)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendGetScriptPolicy(ctx context.Context, params GetScriptPolicyParams) (res *ScriptPolicy, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("getScriptPolicy"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/script-policy/{ScriptPolicyID}"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, GetScriptPolicyOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [2]string
|
|
pathParts[0] = "/script-policy/"
|
|
{
|
|
// Encode "ScriptPolicyID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "ScriptPolicyID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.ScriptPolicyID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeGetScriptPolicyResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// GetSubmission invokes getSubmission operation.
|
|
//
|
|
// Retrieve map with ID.
|
|
//
|
|
// GET /submissions/{SubmissionID}
|
|
func (c *Client) GetSubmission(ctx context.Context, params GetSubmissionParams) (*Submission, error) {
|
|
res, err := c.sendGetSubmission(ctx, params)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendGetSubmission(ctx context.Context, params GetSubmissionParams) (res *Submission, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("getSubmission"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, GetSubmissionOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [2]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeGetSubmissionResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ListMapfixes invokes listMapfixes operation.
|
|
//
|
|
// Get list of mapfixes.
|
|
//
|
|
// GET /mapfixes
|
|
func (c *Client) ListMapfixes(ctx context.Context, params ListMapfixesParams) ([]Mapfix, error) {
|
|
res, err := c.sendListMapfixes(ctx, params)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendListMapfixes(ctx context.Context, params ListMapfixesParams) (res []Mapfix, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("listMapfixes"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/mapfixes"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ListMapfixesOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/mapfixes"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeQueryParams"
|
|
q := uri.NewQueryEncoder()
|
|
{
|
|
// Encode "Page" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Page",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int32ToString(params.Page))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Limit" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Limit",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int32ToString(params.Limit))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Sort" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Sort",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.Sort.Get(); ok {
|
|
return e.EncodeValue(conv.Int32ToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
u.RawQuery = q.Values().Encode()
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeListMapfixesResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ListScriptPolicy invokes listScriptPolicy operation.
|
|
//
|
|
// Get list of script policies.
|
|
//
|
|
// GET /script-policy
|
|
func (c *Client) ListScriptPolicy(ctx context.Context, params ListScriptPolicyParams) ([]ScriptPolicy, error) {
|
|
res, err := c.sendListScriptPolicy(ctx, params)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendListScriptPolicy(ctx context.Context, params ListScriptPolicyParams) (res []ScriptPolicy, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("listScriptPolicy"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/script-policy"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ListScriptPolicyOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/script-policy"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeQueryParams"
|
|
q := uri.NewQueryEncoder()
|
|
{
|
|
// Encode "Page" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Page",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int32ToString(params.Page))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Limit" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Limit",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int32ToString(params.Limit))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "FromScriptHash" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "FromScriptHash",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.FromScriptHash.Get(); ok {
|
|
return e.EncodeValue(conv.StringToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "ToScriptID" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "ToScriptID",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.ToScriptID.Get(); ok {
|
|
return e.EncodeValue(conv.Int64ToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Policy" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Policy",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.Policy.Get(); ok {
|
|
return e.EncodeValue(conv.Int32ToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
u.RawQuery = q.Values().Encode()
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeListScriptPolicyResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ListScripts invokes listScripts operation.
|
|
//
|
|
// Get list of scripts.
|
|
//
|
|
// GET /scripts
|
|
func (c *Client) ListScripts(ctx context.Context, params ListScriptsParams) ([]Script, error) {
|
|
res, err := c.sendListScripts(ctx, params)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendListScripts(ctx context.Context, params ListScriptsParams) (res []Script, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("listScripts"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/scripts"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ListScriptsOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/scripts"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeQueryParams"
|
|
q := uri.NewQueryEncoder()
|
|
{
|
|
// Encode "Page" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Page",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int32ToString(params.Page))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Limit" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Limit",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int32ToString(params.Limit))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Hash" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Hash",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.Hash.Get(); ok {
|
|
return e.EncodeValue(conv.StringToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Name" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Name",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.Name.Get(); ok {
|
|
return e.EncodeValue(conv.StringToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Source" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Source",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.Source.Get(); ok {
|
|
return e.EncodeValue(conv.StringToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "ResourceType" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "ResourceType",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.ResourceType.Get(); ok {
|
|
return e.EncodeValue(conv.Int32ToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "ResourceID" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "ResourceID",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.ResourceID.Get(); ok {
|
|
return e.EncodeValue(conv.Int64ToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
u.RawQuery = q.Values().Encode()
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeListScriptsResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ListSubmissions invokes listSubmissions operation.
|
|
//
|
|
// Get list of submissions.
|
|
//
|
|
// GET /submissions
|
|
func (c *Client) ListSubmissions(ctx context.Context, params ListSubmissionsParams) ([]Submission, error) {
|
|
res, err := c.sendListSubmissions(ctx, params)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendListSubmissions(ctx context.Context, params ListSubmissionsParams) (res []Submission, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("listSubmissions"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/submissions"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ListSubmissionsOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/submissions"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeQueryParams"
|
|
q := uri.NewQueryEncoder()
|
|
{
|
|
// Encode "Page" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Page",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int32ToString(params.Page))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Limit" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Limit",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int32ToString(params.Limit))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "DisplayName" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "DisplayName",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.DisplayName.Get(); ok {
|
|
return e.EncodeValue(conv.StringToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Creator" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Creator",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.Creator.Get(); ok {
|
|
return e.EncodeValue(conv.StringToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "GameID" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "GameID",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.GameID.Get(); ok {
|
|
return e.EncodeValue(conv.Int32ToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "Sort" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "Sort",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
if val, ok := params.Sort.Get(); ok {
|
|
return e.EncodeValue(conv.Int32ToString(val))
|
|
}
|
|
return nil
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
u.RawQuery = q.Values().Encode()
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeListSubmissionsResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// ReleaseSubmissions invokes releaseSubmissions operation.
|
|
//
|
|
// Release a set of uploaded maps.
|
|
//
|
|
// POST /release-submissions
|
|
func (c *Client) ReleaseSubmissions(ctx context.Context, request []ReleaseInfo) error {
|
|
_, err := c.sendReleaseSubmissions(ctx, request)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendReleaseSubmissions(ctx context.Context, request []ReleaseInfo) (res *ReleaseSubmissionsCreated, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("releaseSubmissions"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/release-submissions"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, ReleaseSubmissionsOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/release-submissions"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
if err := encodeReleaseSubmissionsRequest(request, r); err != nil {
|
|
return res, errors.Wrap(err, "encode request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, ReleaseSubmissionsOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeReleaseSubmissionsResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// SessionRoles invokes sessionRoles operation.
|
|
//
|
|
// Get list of roles for the current session.
|
|
//
|
|
// GET /session/roles
|
|
func (c *Client) SessionRoles(ctx context.Context) (*Roles, error) {
|
|
res, err := c.sendSessionRoles(ctx)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendSessionRoles(ctx context.Context) (res *Roles, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("sessionRoles"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/session/roles"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, SessionRolesOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/session/roles"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, SessionRolesOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeSessionRolesResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// SessionUser invokes sessionUser operation.
|
|
//
|
|
// Get information about the currently logged in user.
|
|
//
|
|
// GET /session/user
|
|
func (c *Client) SessionUser(ctx context.Context) (*User, error) {
|
|
res, err := c.sendSessionUser(ctx)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendSessionUser(ctx context.Context) (res *User, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("sessionUser"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/session/user"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, SessionUserOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/session/user"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, SessionUserOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeSessionUserResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// SessionValidate invokes sessionValidate operation.
|
|
//
|
|
// Ask if the current session is valid.
|
|
//
|
|
// GET /session/validate
|
|
func (c *Client) SessionValidate(ctx context.Context) (bool, error) {
|
|
res, err := c.sendSessionValidate(ctx)
|
|
return res, err
|
|
}
|
|
|
|
func (c *Client) sendSessionValidate(ctx context.Context) (res bool, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("sessionValidate"),
|
|
semconv.HTTPRequestMethodKey.String("GET"),
|
|
semconv.HTTPRouteKey.String("/session/validate"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, SessionValidateOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [1]string
|
|
pathParts[0] = "/session/validate"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "GET", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, SessionValidateOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeSessionValidateResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// SetMapfixCompleted invokes setMapfixCompleted operation.
|
|
//
|
|
// Called by maptest when a player completes the map.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/completed
|
|
func (c *Client) SetMapfixCompleted(ctx context.Context, params SetMapfixCompletedParams) error {
|
|
_, err := c.sendSetMapfixCompleted(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendSetMapfixCompleted(ctx context.Context, params SetMapfixCompletedParams) (res *SetMapfixCompletedNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("setMapfixCompleted"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/completed"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, SetMapfixCompletedOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/completed"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, SetMapfixCompletedOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeSetMapfixCompletedResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// SetSubmissionCompleted invokes setSubmissionCompleted operation.
|
|
//
|
|
// Called by maptest when a player completes the map.
|
|
//
|
|
// POST /submissions/{SubmissionID}/completed
|
|
func (c *Client) SetSubmissionCompleted(ctx context.Context, params SetSubmissionCompletedParams) error {
|
|
_, err := c.sendSetSubmissionCompleted(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendSetSubmissionCompleted(ctx context.Context, params SetSubmissionCompletedParams) (res *SetSubmissionCompletedNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("setSubmissionCompleted"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/completed"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, SetSubmissionCompletedOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/completed"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, SetSubmissionCompletedOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeSetSubmissionCompletedResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// UpdateMapfixModel invokes updateMapfixModel operation.
|
|
//
|
|
// Update model following role restrictions.
|
|
//
|
|
// POST /mapfixes/{MapfixID}/model
|
|
func (c *Client) UpdateMapfixModel(ctx context.Context, params UpdateMapfixModelParams) error {
|
|
_, err := c.sendUpdateMapfixModel(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendUpdateMapfixModel(ctx context.Context, params UpdateMapfixModelParams) (res *UpdateMapfixModelNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("updateMapfixModel"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/mapfixes/{MapfixID}/model"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, UpdateMapfixModelOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/mapfixes/"
|
|
{
|
|
// Encode "MapfixID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "MapfixID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.MapfixID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/model"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeQueryParams"
|
|
q := uri.NewQueryEncoder()
|
|
{
|
|
// Encode "ModelID" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "ModelID",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int64ToString(params.ModelID))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "VersionID" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "VersionID",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int64ToString(params.VersionID))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
u.RawQuery = q.Values().Encode()
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, UpdateMapfixModelOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeUpdateMapfixModelResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// UpdateScript invokes updateScript operation.
|
|
//
|
|
// Update the specified script by ID.
|
|
//
|
|
// POST /scripts/{ScriptID}
|
|
func (c *Client) UpdateScript(ctx context.Context, request *ScriptUpdate, params UpdateScriptParams) error {
|
|
_, err := c.sendUpdateScript(ctx, request, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendUpdateScript(ctx context.Context, request *ScriptUpdate, params UpdateScriptParams) (res *UpdateScriptNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("updateScript"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/scripts/{ScriptID}"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, UpdateScriptOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [2]string
|
|
pathParts[0] = "/scripts/"
|
|
{
|
|
// Encode "ScriptID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "ScriptID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.ScriptID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
if err := encodeUpdateScriptRequest(request, r); err != nil {
|
|
return res, errors.Wrap(err, "encode request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, UpdateScriptOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeUpdateScriptResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// UpdateScriptPolicy invokes updateScriptPolicy operation.
|
|
//
|
|
// Update the specified script policy by ID.
|
|
//
|
|
// POST /script-policy/{ScriptPolicyID}
|
|
func (c *Client) UpdateScriptPolicy(ctx context.Context, request *ScriptPolicyUpdate, params UpdateScriptPolicyParams) error {
|
|
_, err := c.sendUpdateScriptPolicy(ctx, request, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendUpdateScriptPolicy(ctx context.Context, request *ScriptPolicyUpdate, params UpdateScriptPolicyParams) (res *UpdateScriptPolicyNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("updateScriptPolicy"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/script-policy/{ScriptPolicyID}"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, UpdateScriptPolicyOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [2]string
|
|
pathParts[0] = "/script-policy/"
|
|
{
|
|
// Encode "ScriptPolicyID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "ScriptPolicyID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.ScriptPolicyID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
if err := encodeUpdateScriptPolicyRequest(request, r); err != nil {
|
|
return res, errors.Wrap(err, "encode request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, UpdateScriptPolicyOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeUpdateScriptPolicyResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|
|
|
|
// UpdateSubmissionModel invokes updateSubmissionModel operation.
|
|
//
|
|
// Update model following role restrictions.
|
|
//
|
|
// POST /submissions/{SubmissionID}/model
|
|
func (c *Client) UpdateSubmissionModel(ctx context.Context, params UpdateSubmissionModelParams) error {
|
|
_, err := c.sendUpdateSubmissionModel(ctx, params)
|
|
return err
|
|
}
|
|
|
|
func (c *Client) sendUpdateSubmissionModel(ctx context.Context, params UpdateSubmissionModelParams) (res *UpdateSubmissionModelNoContent, err error) {
|
|
otelAttrs := []attribute.KeyValue{
|
|
otelogen.OperationID("updateSubmissionModel"),
|
|
semconv.HTTPRequestMethodKey.String("POST"),
|
|
semconv.HTTPRouteKey.String("/submissions/{SubmissionID}/model"),
|
|
}
|
|
|
|
// Run stopwatch.
|
|
startTime := time.Now()
|
|
defer func() {
|
|
// Use floating point division here for higher precision (instead of Millisecond method).
|
|
elapsedDuration := time.Since(startTime)
|
|
c.duration.Record(ctx, float64(elapsedDuration)/float64(time.Millisecond), metric.WithAttributes(otelAttrs...))
|
|
}()
|
|
|
|
// Increment request counter.
|
|
c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
|
|
// Start a span for this request.
|
|
ctx, span := c.cfg.Tracer.Start(ctx, UpdateSubmissionModelOperation,
|
|
trace.WithAttributes(otelAttrs...),
|
|
clientSpanKind,
|
|
)
|
|
// Track stage for error reporting.
|
|
var stage string
|
|
defer func() {
|
|
if err != nil {
|
|
span.RecordError(err)
|
|
span.SetStatus(codes.Error, stage)
|
|
c.errors.Add(ctx, 1, metric.WithAttributes(otelAttrs...))
|
|
}
|
|
span.End()
|
|
}()
|
|
|
|
stage = "BuildURL"
|
|
u := uri.Clone(c.requestURL(ctx))
|
|
var pathParts [3]string
|
|
pathParts[0] = "/submissions/"
|
|
{
|
|
// Encode "SubmissionID" parameter.
|
|
e := uri.NewPathEncoder(uri.PathEncoderConfig{
|
|
Param: "SubmissionID",
|
|
Style: uri.PathStyleSimple,
|
|
Explode: false,
|
|
})
|
|
if err := func() error {
|
|
return e.EncodeValue(conv.Int64ToString(params.SubmissionID))
|
|
}(); err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
encoded, err := e.Result()
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "encode path")
|
|
}
|
|
pathParts[1] = encoded
|
|
}
|
|
pathParts[2] = "/model"
|
|
uri.AddPathParts(u, pathParts[:]...)
|
|
|
|
stage = "EncodeQueryParams"
|
|
q := uri.NewQueryEncoder()
|
|
{
|
|
// Encode "ModelID" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "ModelID",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int64ToString(params.ModelID))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
{
|
|
// Encode "VersionID" parameter.
|
|
cfg := uri.QueryParameterEncodingConfig{
|
|
Name: "VersionID",
|
|
Style: uri.QueryStyleForm,
|
|
Explode: true,
|
|
}
|
|
|
|
if err := q.EncodeParam(cfg, func(e uri.Encoder) error {
|
|
return e.EncodeValue(conv.Int64ToString(params.VersionID))
|
|
}); err != nil {
|
|
return res, errors.Wrap(err, "encode query")
|
|
}
|
|
}
|
|
u.RawQuery = q.Values().Encode()
|
|
|
|
stage = "EncodeRequest"
|
|
r, err := ht.NewRequest(ctx, "POST", u)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "create request")
|
|
}
|
|
|
|
{
|
|
type bitset = [1]uint8
|
|
var satisfied bitset
|
|
{
|
|
stage = "Security:CookieAuth"
|
|
switch err := c.securityCookieAuth(ctx, UpdateSubmissionModelOperation, r); {
|
|
case err == nil: // if NO error
|
|
satisfied[0] |= 1 << 0
|
|
case errors.Is(err, ogenerrors.ErrSkipClientSecurity):
|
|
// Skip this security.
|
|
default:
|
|
return res, errors.Wrap(err, "security \"CookieAuth\"")
|
|
}
|
|
}
|
|
|
|
if ok := func() bool {
|
|
nextRequirement:
|
|
for _, requirement := range []bitset{
|
|
{0b00000001},
|
|
} {
|
|
for i, mask := range requirement {
|
|
if satisfied[i]&mask != mask {
|
|
continue nextRequirement
|
|
}
|
|
}
|
|
return true
|
|
}
|
|
return false
|
|
}(); !ok {
|
|
return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied
|
|
}
|
|
}
|
|
|
|
stage = "SendRequest"
|
|
resp, err := c.cfg.Client.Do(r)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "do request")
|
|
}
|
|
defer resp.Body.Close()
|
|
|
|
stage = "DecodeResponse"
|
|
result, err := decodeUpdateSubmissionModelResponse(resp)
|
|
if err != nil {
|
|
return res, errors.Wrap(err, "decode response")
|
|
}
|
|
|
|
return result, nil
|
|
}
|