diff --git a/internal/agent/http_cache/tuistcache/api/oas_client_gen.go b/internal/agent/http_cache/tuistcache/api/oas_client_gen.go index 60b30bee..50a76716 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_client_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_client_gen.go @@ -17,7 +17,6 @@ import ( "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" ) @@ -39,6 +38,12 @@ type Invoker interface { // // GET /api/cache/exists CacheArtifactExists(ctx context.Context, params CacheArtifactExistsParams) (CacheArtifactExistsRes, error) + // CancelInvitation invokes cancelInvitation operation. + // + // Cancels an invitation for a given invitee email and an organization. + // + // DELETE /api/organizations/{organization_name}/invitations + CancelInvitation(ctx context.Context, request OptCancelInvitationReq, params CancelInvitationParams) (CancelInvitationRes, error) // CleanCache invokes cleanCache operation. // // Cleans cache for a given project. @@ -73,6 +78,12 @@ type Invoker interface { // // POST /api/projects/{account_handle}/{project_handle}/previews/complete CompletePreviewsMultipartUpload(ctx context.Context, request OptCompletePreviewsMultipartUploadReq, params CompletePreviewsMultipartUploadParams) (CompletePreviewsMultipartUploadRes, error) + // CreateAccountToken invokes createAccountToken operation. + // + // This endpoint returns a new account token. + // + // POST /api/accounts/{account_handle}/tokens + CreateAccountToken(ctx context.Context, request OptCreateAccountTokenReq, params CreateAccountTokenParams) (CreateAccountTokenRes, error) // CreateCommandEvent invokes createCommandEvent operation. // // Create a a new command analytics event. @@ -123,7 +134,7 @@ type Invoker interface { DownloadCacheArtifact(ctx context.Context, params DownloadCacheArtifactParams) (DownloadCacheArtifactRes, error) // DownloadPreview invokes downloadPreview operation. // - // This endpoint returns a signed URL that can be used to download a preview. + // This endpoint returns a preview with a given id, including the url to download the preview. // // GET /api/projects/{account_handle}/{project_handle}/previews/{preview_id} DownloadPreview(ctx context.Context, params DownloadPreviewParams) (DownloadPreviewRes, error) @@ -166,6 +177,12 @@ type Invoker interface { // // GET /api/organizations ListOrganizations(ctx context.Context) (ListOrganizationsRes, error) + // ListPreviews invokes listPreviews operation. + // + // This endpoint returns a list of previews for a given project. + // + // GET /api/projects/{account_handle}/{project_handle}/previews + ListPreviews(ctx context.Context, params ListPreviewsParams) (ListPreviewsRes, error) // ListProjectTokens invokes listProjectTokens operation. // // This endpoint returns all tokens for a given project. @@ -178,6 +195,12 @@ type Invoker interface { // // GET /api/projects ListProjects(ctx context.Context) (ListProjectsRes, error) + // ListRuns invokes listRuns operation. + // + // List runs associated with a given project. + // + // GET /api/projects/{account_handle}/{project_handle}/runs + ListRuns(ctx context.Context, params ListRunsParams) (ListRunsRes, error) // RefreshToken invokes refreshToken operation. // // This endpoint returns new tokens for a given refresh token if the refresh token is valid. @@ -214,7 +237,7 @@ type Invoker interface { // complete the upload. // // POST /api/runs/{run_id}/start - StartAnalyticsArtifactMultipartUpload(ctx context.Context, request CommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (StartAnalyticsArtifactMultipartUploadRes, error) + StartAnalyticsArtifactMultipartUpload(ctx context.Context, request OptCommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (StartAnalyticsArtifactMultipartUploadRes, error) // StartCacheArtifactMultipartUpload invokes startCacheArtifactMultipartUpload operation. // // The endpoint returns an upload ID that can be used to generate URLs for the individual parts and @@ -229,6 +252,12 @@ type Invoker interface { // // POST /api/projects/{account_handle}/{project_handle}/previews/start StartPreviewsMultipartUpload(ctx context.Context, request OptStartPreviewsMultipartUploadReq, params StartPreviewsMultipartUploadParams) (StartPreviewsMultipartUploadRes, error) + // UpdateAccount invokes updateAccount operation. + // + // Updates the given account. + // + // PATCH /api/accounts/{account_handle} + UpdateAccount(ctx context.Context, request OptUpdateAccountReq, params UpdateAccountParams) (UpdateAccountRes, error) // UpdateOrganization invokes updateOrganization operation. // // Updates an organization with given parameters. @@ -260,12 +289,17 @@ type Invoker interface { // // POST /api/projects/{account_handle}/{project_handle}/cache/ac UploadCacheActionItem(ctx context.Context, request OptUploadCacheActionItemReq, params UploadCacheActionItemParams) (UploadCacheActionItemRes, error) + // UploadPreviewIcon invokes uploadPreviewIcon operation. + // + // The endpoint uploads a preview icon. + // + // POST /api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons + UploadPreviewIcon(ctx context.Context, params UploadPreviewIconParams) (UploadPreviewIconRes, error) } // Client implements OAS client. type Client struct { serverURL *url.URL - sec SecuritySource baseClient } @@ -279,7 +313,7 @@ func trimTrailingSlashes(u *url.URL) { } // NewClient initializes new Client defined by OAS. -func NewClient(serverURL string, sec SecuritySource, opts ...ClientOption) (*Client, error) { +func NewClient(serverURL string, opts ...ClientOption) (*Client, error) { u, err := url.Parse(serverURL) if err != nil { return nil, err @@ -292,7 +326,6 @@ func NewClient(serverURL string, sec SecuritySource, opts ...ClientOption) (*Cli } return &Client{ serverURL: u, - sec: sec, baseClient: c, }, nil } @@ -371,51 +404,6 @@ func (c *Client) sendAuthenticate(ctx context.Context, request OptAuthenticateRe return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "Authenticate", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "Authenticate", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -554,49 +542,98 @@ func (c *Client) sendCacheArtifactExists(ctx context.Context, params CacheArtifa 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 := decodeCacheArtifactExistsResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// CancelInvitation invokes cancelInvitation operation. +// +// Cancels an invitation for a given invitee email and an organization. +// +// DELETE /api/organizations/{organization_name}/invitations +func (c *Client) CancelInvitation(ctx context.Context, request OptCancelInvitationReq, params CancelInvitationParams) (CancelInvitationRes, error) { + res, err := c.sendCancelInvitation(ctx, request, params) + return res, err +} + +func (c *Client) sendCancelInvitation(ctx context.Context, request OptCancelInvitationReq, params CancelInvitationParams) (res CancelInvitationRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("cancelInvitation"), + semconv.HTTPRequestMethodKey.String("DELETE"), + semconv.HTTPRouteKey.String("/api/organizations/{organization_name}/invitations"), + } + + // 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(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, "CancelInvitation", + 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] = "/api/organizations/" { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CacheArtifactExists", 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 \"Authorization\"") - } + // Encode "organization_name" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "organization_name", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.OrganizationName)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CacheArtifactExists", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") } + pathParts[1] = encoded + } + pathParts[2] = "/invitations" + uri.AddPathParts(u, pathParts[:]...) - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied - } + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "DELETE", u) + if err != nil { + return res, errors.Wrap(err, "create request") + } + if err := encodeCancelInvitationRequest(request, r); err != nil { + return res, errors.Wrap(err, "encode request") } stage = "SendRequest" @@ -607,7 +644,7 @@ func (c *Client) sendCacheArtifactExists(ctx context.Context, params CacheArtifa defer resp.Body.Close() stage = "DecodeResponse" - result, err := decodeCacheArtifactExistsResponse(resp) + result, err := decodeCancelInvitationResponse(resp) if err != nil { return res, errors.Wrap(err, "decode response") } @@ -709,51 +746,6 @@ func (c *Client) sendCleanCache(ctx context.Context, params CleanCacheParams) (r return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CleanCache", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CleanCache", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -849,51 +841,6 @@ func (c *Client) sendCompleteAnalyticsArtifactMultipartUpload(ctx context.Contex return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CompleteAnalyticsArtifactMultipartUpload", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CompleteAnalyticsArtifactMultipartUpload", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -989,51 +936,6 @@ func (c *Client) sendCompleteAnalyticsArtifactsUploads(ctx context.Context, requ return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CompleteAnalyticsArtifactsUploads", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CompleteAnalyticsArtifactsUploads", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -1187,51 +1089,6 @@ func (c *Client) sendCompleteCacheArtifactMultipartUpload(ctx context.Context, r return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CompleteCacheArtifactMultipartUpload", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CompleteCacheArtifactMultipartUpload", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -1346,49 +1203,98 @@ func (c *Client) sendCompletePreviewsMultipartUpload(ctx context.Context, reques return res, errors.Wrap(err, "encode 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 := decodeCompletePreviewsMultipartUploadResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// CreateAccountToken invokes createAccountToken operation. +// +// This endpoint returns a new account token. +// +// POST /api/accounts/{account_handle}/tokens +func (c *Client) CreateAccountToken(ctx context.Context, request OptCreateAccountTokenReq, params CreateAccountTokenParams) (CreateAccountTokenRes, error) { + res, err := c.sendCreateAccountToken(ctx, request, params) + return res, err +} + +func (c *Client) sendCreateAccountToken(ctx context.Context, request OptCreateAccountTokenReq, params CreateAccountTokenParams) (res CreateAccountTokenRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("createAccountToken"), + semconv.HTTPRequestMethodKey.String("POST"), + semconv.HTTPRouteKey.String("/api/accounts/{account_handle}/tokens"), + } + + // 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(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, "CreateAccountToken", + 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] = "/api/accounts/" { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CompletePreviewsMultipartUpload", 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 \"Authorization\"") - } + // Encode "account_handle" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "account_handle", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.AccountHandle)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CompletePreviewsMultipartUpload", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") } + pathParts[1] = encoded + } + pathParts[2] = "/tokens" + uri.AddPathParts(u, pathParts[:]...) - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied - } + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "POST", u) + if err != nil { + return res, errors.Wrap(err, "create request") + } + if err := encodeCreateAccountTokenRequest(request, r); err != nil { + return res, errors.Wrap(err, "encode request") } stage = "SendRequest" @@ -1399,7 +1305,7 @@ func (c *Client) sendCompletePreviewsMultipartUpload(ctx context.Context, reques defer resp.Body.Close() stage = "DecodeResponse" - result, err := decodeCompletePreviewsMultipartUploadResponse(resp) + result, err := decodeCreateAccountTokenResponse(resp) if err != nil { return res, errors.Wrap(err, "decode response") } @@ -1484,51 +1390,6 @@ func (c *Client) sendCreateCommandEvent(ctx context.Context, request OptCreateCo return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CreateCommandEvent", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CreateCommandEvent", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -1623,51 +1484,6 @@ func (c *Client) sendCreateInvitation(ctx context.Context, request OptCreateInvi return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CreateInvitation", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CreateInvitation", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -1743,51 +1559,6 @@ func (c *Client) sendCreateOrganization(ctx context.Context, request OptCreateOr return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CreateOrganization", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CreateOrganization", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -1863,51 +1634,6 @@ func (c *Client) sendCreateProject(ctx context.Context, request OptCreateProject return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CreateProject", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CreateProject", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -2018,51 +1744,6 @@ func (c *Client) sendCreateProjectToken(ctx context.Context, params CreateProjec return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "CreateProjectToken", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "CreateProjectToken", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -2153,51 +1834,6 @@ func (c *Client) sendDeleteOrganization(ctx context.Context, params DeleteOrgani return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "DeleteOrganization", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "DeleteOrganization", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -2288,51 +1924,6 @@ func (c *Client) sendDeleteProject(ctx context.Context, params DeleteProjectPara return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "DeleteProject", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "DeleteProject", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -2468,51 +2059,6 @@ func (c *Client) sendDownloadCacheArtifact(ctx context.Context, params DownloadC return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "DownloadCacheArtifact", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "DownloadCacheArtifact", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -2531,7 +2077,7 @@ func (c *Client) sendDownloadCacheArtifact(ctx context.Context, params DownloadC // DownloadPreview invokes downloadPreview operation. // -// This endpoint returns a signed URL that can be used to download a preview. +// This endpoint returns a preview with a given id, including the url to download the preview. // // GET /api/projects/{account_handle}/{project_handle}/previews/{preview_id} func (c *Client) DownloadPreview(ctx context.Context, params DownloadPreviewParams) (DownloadPreviewRes, error) { @@ -2641,51 +2187,6 @@ func (c *Client) sendDownloadPreview(ctx context.Context, params DownloadPreview return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "DownloadPreview", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "DownloadPreview", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -2781,51 +2282,6 @@ func (c *Client) sendGenerateAnalyticsArtifactMultipartUploadURL(ctx context.Con return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "GenerateAnalyticsArtifactMultipartUploadURL", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "GenerateAnalyticsArtifactMultipartUploadURL", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -3007,51 +2463,6 @@ func (c *Client) sendGenerateCacheArtifactMultipartUploadURL(ctx context.Context return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "GenerateCacheArtifactMultipartUploadURL", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "GenerateCacheArtifactMultipartUploadURL", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -3166,51 +2577,6 @@ func (c *Client) sendGeneratePreviewsMultipartUploadURL(ctx context.Context, req return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "GeneratePreviewsMultipartUploadURL", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "GeneratePreviewsMultipartUploadURL", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -3339,51 +2705,6 @@ func (c *Client) sendGetCacheActionItem(ctx context.Context, params GetCacheActi return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "GetCacheActionItem", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "GetCacheActionItem", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -3474,51 +2795,6 @@ func (c *Client) sendGetDeviceCode(ctx context.Context, params GetDeviceCodePara return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "GetDeviceCode", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "GetDeviceCode", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -3591,51 +2867,6 @@ func (c *Client) sendListOrganizations(ctx context.Context) (res ListOrganizatio return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "ListOrganizations", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "ListOrganizations", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -3652,21 +2883,21 @@ func (c *Client) sendListOrganizations(ctx context.Context) (res ListOrganizatio return result, nil } -// ListProjectTokens invokes listProjectTokens operation. +// ListPreviews invokes listPreviews operation. // -// This endpoint returns all tokens for a given project. +// This endpoint returns a list of previews for a given project. // -// GET /api/projects/{account_handle}/{project_handle}/tokens -func (c *Client) ListProjectTokens(ctx context.Context, params ListProjectTokensParams) (ListProjectTokensRes, error) { - res, err := c.sendListProjectTokens(ctx, params) +// GET /api/projects/{account_handle}/{project_handle}/previews +func (c *Client) ListPreviews(ctx context.Context, params ListPreviewsParams) (ListPreviewsRes, error) { + res, err := c.sendListPreviews(ctx, params) return res, err } -func (c *Client) sendListProjectTokens(ctx context.Context, params ListProjectTokensParams) (res ListProjectTokensRes, err error) { +func (c *Client) sendListPreviews(ctx context.Context, params ListPreviewsParams) (res ListPreviewsRes, err error) { otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listProjectTokens"), + otelogen.OperationID("listPreviews"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/projects/{account_handle}/{project_handle}/tokens"), + semconv.HTTPRouteKey.String("/api/projects/{account_handle}/{project_handle}/previews"), } // Run stopwatch. @@ -3681,7 +2912,7 @@ func (c *Client) sendListProjectTokens(ctx context.Context, params ListProjectTo c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...)) // Start a span for this request. - ctx, span := c.cfg.Tracer.Start(ctx, "ListProjectTokens", + ctx, span := c.cfg.Tracer.Start(ctx, "ListPreviews", trace.WithAttributes(otelAttrs...), clientSpanKind, ) @@ -3737,59 +2968,129 @@ func (c *Client) sendListProjectTokens(ctx context.Context, params ListProjectTo } pathParts[3] = encoded } - pathParts[4] = "/tokens" + pathParts[4] = "/previews" uri.AddPathParts(u, pathParts[:]...) - stage = "EncodeRequest" - r, err := ht.NewRequest(ctx, "GET", u) - if err != nil { - return res, errors.Wrap(err, "create request") + stage = "EncodeQueryParams" + q := uri.NewQueryEncoder() + { + // Encode "display_name" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "display_name", + 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 "specifier" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "specifier", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.Specifier.Get(); ok { + return e.EncodeValue(conv.StringToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } } + { + // Encode "supported_platforms" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "supported_platforms", + Style: uri.QueryStyleForm, + Explode: true, + } + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if params.SupportedPlatforms != nil { + return e.EncodeArray(func(e uri.Encoder) error { + for i, item := range params.SupportedPlatforms { + if err := func() error { + return e.EncodeValue(conv.StringToString(string(item))) + }(); err != nil { + return errors.Wrapf(err, "[%d]", i) + } + } + return nil + }) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "ListProjectTokens", 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 \"Authorization\"") + // Encode "page_size" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "page_size", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.PageSize.Get(); ok { + return e.EncodeValue(conv.IntToString(val)) } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + { + // Encode "page" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "page", + Style: uri.QueryStyleForm, + Explode: true, } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "ListProjectTokens", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.Page.Get(); ok { + return e.EncodeValue(conv.IntToString(val)) } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + { + // Encode "distinct_field" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "distinct_field", + Style: uri.QueryStyleForm, + Explode: true, } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.DistinctField.Get(); ok { + return e.EncodeValue(conv.StringToString(string(val))) } - return false - }(); !ok { - return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied + 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) @@ -3799,7 +3100,7 @@ func (c *Client) sendListProjectTokens(ctx context.Context, params ListProjectTo defer resp.Body.Close() stage = "DecodeResponse" - result, err := decodeListProjectTokensResponse(resp) + result, err := decodeListPreviewsResponse(resp) if err != nil { return res, errors.Wrap(err, "decode response") } @@ -3807,21 +3108,21 @@ func (c *Client) sendListProjectTokens(ctx context.Context, params ListProjectTo return result, nil } -// ListProjects invokes listProjects operation. +// ListProjectTokens invokes listProjectTokens operation. // -// List projects the authenticated user has access to. +// This endpoint returns all tokens for a given project. // -// GET /api/projects -func (c *Client) ListProjects(ctx context.Context) (ListProjectsRes, error) { - res, err := c.sendListProjects(ctx) +// GET /api/projects/{account_handle}/{project_handle}/tokens +func (c *Client) ListProjectTokens(ctx context.Context, params ListProjectTokensParams) (ListProjectTokensRes, error) { + res, err := c.sendListProjectTokens(ctx, params) return res, err } -func (c *Client) sendListProjects(ctx context.Context) (res ListProjectsRes, err error) { +func (c *Client) sendListProjectTokens(ctx context.Context, params ListProjectTokensParams) (res ListProjectTokensRes, err error) { otelAttrs := []attribute.KeyValue{ - otelogen.OperationID("listProjects"), + otelogen.OperationID("listProjectTokens"), semconv.HTTPRequestMethodKey.String("GET"), - semconv.HTTPRouteKey.String("/api/projects"), + semconv.HTTPRouteKey.String("/api/projects/{account_handle}/{project_handle}/tokens"), } // Run stopwatch. @@ -3836,7 +3137,117 @@ func (c *Client) sendListProjects(ctx context.Context) (res ListProjectsRes, err c.requests.Add(ctx, 1, metric.WithAttributes(otelAttrs...)) // Start a span for this request. - ctx, span := c.cfg.Tracer.Start(ctx, "ListProjects", + ctx, span := c.cfg.Tracer.Start(ctx, "ListProjectTokens", + 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 [5]string + pathParts[0] = "/api/projects/" + { + // Encode "account_handle" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "account_handle", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.AccountHandle)) + }(); 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] = "/" + { + // Encode "project_handle" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "project_handle", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.ProjectHandle)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") + } + pathParts[3] = encoded + } + pathParts[4] = "/tokens" + 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 := decodeListProjectTokensResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// ListProjects invokes listProjects operation. +// +// List projects the authenticated user has access to. +// +// GET /api/projects +func (c *Client) ListProjects(ctx context.Context) (ListProjectsRes, error) { + res, err := c.sendListProjects(ctx) + return res, err +} + +func (c *Client) sendListProjects(ctx context.Context) (res ListProjectsRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listProjects"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/projects"), + } + + // 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(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, "ListProjects", trace.WithAttributes(otelAttrs...), clientSpanKind, ) @@ -3863,50 +3274,221 @@ func (c *Client) sendListProjects(ctx context.Context) (res ListProjectsRes, err 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 := decodeListProjectsResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// ListRuns invokes listRuns operation. +// +// List runs associated with a given project. +// +// GET /api/projects/{account_handle}/{project_handle}/runs +func (c *Client) ListRuns(ctx context.Context, params ListRunsParams) (ListRunsRes, error) { + res, err := c.sendListRuns(ctx, params) + return res, err +} + +func (c *Client) sendListRuns(ctx context.Context, params ListRunsParams) (res ListRunsRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listRuns"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/projects/{account_handle}/{project_handle}/runs"), + } + + // 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(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, "ListRuns", + 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 [5]string + pathParts[0] = "/api/projects/" + { + // Encode "account_handle" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "account_handle", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.AccountHandle)) + }(); 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] = "/" + { + // Encode "project_handle" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "project_handle", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.ProjectHandle)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") + } + pathParts[3] = encoded + } + pathParts[4] = "/runs" + uri.AddPathParts(u, pathParts[:]...) + + stage = "EncodeQueryParams" + q := uri.NewQueryEncoder() { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "ListProjects", 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 \"Authorization\"") + // 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") } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "ListProjects", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") + } + { + // Encode "git_ref" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "git_ref", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.GitRef.Get(); ok { + return e.EncodeValue(conv.StringToString(val)) } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + { + // Encode "git_branch" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "git_branch", + Style: uri.QueryStyleForm, + Explode: true, } - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.GitBranch.Get(); ok { + return e.EncodeValue(conv.StringToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + { + // Encode "git_commit_sha" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "git_commit_sha", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.GitCommitSha.Get(); ok { + return e.EncodeValue(conv.StringToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + { + // Encode "page_size" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "page_size", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.PageSize.Get(); ok { + return e.EncodeValue(conv.IntToString(val)) + } + return nil + }); err != nil { + return res, errors.Wrap(err, "encode query") + } + } + { + // Encode "page" parameter. + cfg := uri.QueryParameterEncodingConfig{ + Name: "page", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.EncodeParam(cfg, func(e uri.Encoder) error { + if val, ok := params.Page.Get(); ok { + return e.EncodeValue(conv.IntToString(val)) } - return false - }(); !ok { - return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied + 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) @@ -3916,7 +3498,7 @@ func (c *Client) sendListProjects(ctx context.Context) (res ListProjectsRes, err defer resp.Body.Close() stage = "DecodeResponse" - result, err := decodeListProjectsResponse(resp) + result, err := decodeListRunsResponse(resp) if err != nil { return res, errors.Wrap(err, "decode response") } @@ -3983,51 +3565,6 @@ func (c *Client) sendRefreshToken(ctx context.Context, request OptRefreshTokenRe return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "RefreshToken", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "RefreshToken", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -4156,51 +3693,6 @@ func (c *Client) sendRevokeProjectToken(ctx context.Context, params RevokeProjec return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "RevokeProjectToken", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "RevokeProjectToken", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -4291,51 +3783,6 @@ func (c *Client) sendShowOrganization(ctx context.Context, params ShowOrganizati return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "ShowOrganization", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "ShowOrganization", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -4427,51 +3874,6 @@ func (c *Client) sendShowOrganizationUsage(ctx context.Context, params ShowOrgan return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "ShowOrganizationUsage", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "ShowOrganizationUsage", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -4581,51 +3983,6 @@ func (c *Client) sendShowProject(ctx context.Context, params ShowProjectParams) return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "ShowProject", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "ShowProject", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -4648,12 +4005,12 @@ func (c *Client) sendShowProject(ctx context.Context, params ShowProjectParams) // complete the upload. // // POST /api/runs/{run_id}/start -func (c *Client) StartAnalyticsArtifactMultipartUpload(ctx context.Context, request CommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (StartAnalyticsArtifactMultipartUploadRes, error) { +func (c *Client) StartAnalyticsArtifactMultipartUpload(ctx context.Context, request OptCommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (StartAnalyticsArtifactMultipartUploadRes, error) { res, err := c.sendStartAnalyticsArtifactMultipartUpload(ctx, request, params) return res, err } -func (c *Client) sendStartAnalyticsArtifactMultipartUpload(ctx context.Context, request CommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (res StartAnalyticsArtifactMultipartUploadRes, err error) { +func (c *Client) sendStartAnalyticsArtifactMultipartUpload(ctx context.Context, request OptCommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (res StartAnalyticsArtifactMultipartUploadRes, err error) { otelAttrs := []attribute.KeyValue{ otelogen.OperationID("startAnalyticsArtifactMultipartUpload"), semconv.HTTPRequestMethodKey.String("POST"), @@ -4718,52 +4075,7 @@ func (c *Client) sendStartAnalyticsArtifactMultipartUpload(ctx context.Context, return res, errors.Wrap(err, "create request") } if err := encodeStartAnalyticsArtifactMultipartUploadRequest(request, r); err != nil { - return res, errors.Wrap(err, "encode request") - } - - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "StartAnalyticsArtifactMultipartUpload", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "StartAnalyticsArtifactMultipartUpload", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied - } + return res, errors.Wrap(err, "encode request") } stage = "SendRequest" @@ -4902,51 +4214,6 @@ func (c *Client) sendStartCacheArtifactMultipartUpload(ctx context.Context, para return res, errors.Wrap(err, "create request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "StartCacheArtifactMultipartUpload", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "StartCacheArtifactMultipartUpload", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -5061,49 +4328,97 @@ func (c *Client) sendStartPreviewsMultipartUpload(ctx context.Context, request O return res, errors.Wrap(err, "encode 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 := decodeStartPreviewsMultipartUploadResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// UpdateAccount invokes updateAccount operation. +// +// Updates the given account. +// +// PATCH /api/accounts/{account_handle} +func (c *Client) UpdateAccount(ctx context.Context, request OptUpdateAccountReq, params UpdateAccountParams) (UpdateAccountRes, error) { + res, err := c.sendUpdateAccount(ctx, request, params) + return res, err +} + +func (c *Client) sendUpdateAccount(ctx context.Context, request OptUpdateAccountReq, params UpdateAccountParams) (res UpdateAccountRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("updateAccount"), + semconv.HTTPRequestMethodKey.String("PATCH"), + semconv.HTTPRouteKey.String("/api/accounts/{account_handle}"), + } + + // 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(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, "UpdateAccount", + 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] = "/api/accounts/" { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "StartPreviewsMultipartUpload", 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 \"Authorization\"") - } + // Encode "account_handle" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "account_handle", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.AccountHandle)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "StartPreviewsMultipartUpload", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") } + pathParts[1] = encoded + } + uri.AddPathParts(u, pathParts[:]...) - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied - } + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "PATCH", u) + if err != nil { + return res, errors.Wrap(err, "create request") + } + if err := encodeUpdateAccountRequest(request, r); err != nil { + return res, errors.Wrap(err, "encode request") } stage = "SendRequest" @@ -5114,7 +4429,7 @@ func (c *Client) sendStartPreviewsMultipartUpload(ctx context.Context, request O defer resp.Body.Close() stage = "DecodeResponse" - result, err := decodeStartPreviewsMultipartUploadResponse(resp) + result, err := decodeUpdateAccountResponse(resp) if err != nil { return res, errors.Wrap(err, "decode response") } @@ -5199,51 +4514,6 @@ func (c *Client) sendUpdateOrganization(ctx context.Context, request OptUpdateOr return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "UpdateOrganization", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "UpdateOrganization", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -5337,51 +4607,6 @@ func (c *Client) sendUpdateOrganization2(ctx context.Context, request OptUpdateO return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "UpdateOrganization2", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "UpdateOrganization2", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -5494,51 +4719,6 @@ func (c *Client) sendUpdateOrganizationMember(ctx context.Context, request OptUp return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "UpdateOrganizationMember", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "UpdateOrganizationMember", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -5651,51 +4831,6 @@ func (c *Client) sendUpdateProject(ctx context.Context, request OptUpdateProject return res, errors.Wrap(err, "encode request") } - { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "UpdateProject", 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 \"Authorization\"") - } - } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "UpdateProject", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - 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 { @@ -5810,49 +4945,133 @@ func (c *Client) sendUploadCacheActionItem(ctx context.Context, request OptUploa return res, errors.Wrap(err, "encode 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 := decodeUploadCacheActionItemResponse(resp) + if err != nil { + return res, errors.Wrap(err, "decode response") + } + + return result, nil +} + +// UploadPreviewIcon invokes uploadPreviewIcon operation. +// +// The endpoint uploads a preview icon. +// +// POST /api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons +func (c *Client) UploadPreviewIcon(ctx context.Context, params UploadPreviewIconParams) (UploadPreviewIconRes, error) { + res, err := c.sendUploadPreviewIcon(ctx, params) + return res, err +} + +func (c *Client) sendUploadPreviewIcon(ctx context.Context, params UploadPreviewIconParams) (res UploadPreviewIconRes, err error) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("uploadPreviewIcon"), + semconv.HTTPRequestMethodKey.String("POST"), + semconv.HTTPRouteKey.String("/api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons"), + } + + // 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(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, "UploadPreviewIcon", + 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 [7]string + pathParts[0] = "/api/projects/" { - type bitset = [1]uint8 - var satisfied bitset - { - stage = "Security:Authorization" - switch err := c.securityAuthorization(ctx, "UploadCacheActionItem", 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 \"Authorization\"") - } + // Encode "account_handle" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "account_handle", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.AccountHandle)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") } - { - stage = "Security:Cookie" - switch err := c.securityCookie(ctx, "UploadCacheActionItem", r); { - case err == nil: // if NO error - satisfied[0] |= 1 << 1 - case errors.Is(err, ogenerrors.ErrSkipClientSecurity): - // Skip this security. - default: - return res, errors.Wrap(err, "security \"Cookie\"") - } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - return res, ogenerrors.ErrSecurityRequirementIsNotSatisfied + pathParts[1] = encoded + } + pathParts[2] = "/" + { + // Encode "project_handle" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "project_handle", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.ProjectHandle)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") + } + pathParts[3] = encoded + } + pathParts[4] = "/previews/" + { + // Encode "preview_id" parameter. + e := uri.NewPathEncoder(uri.PathEncoderConfig{ + Param: "preview_id", + Style: uri.PathStyleSimple, + Explode: false, + }) + if err := func() error { + return e.EncodeValue(conv.StringToString(params.PreviewID)) + }(); err != nil { + return res, errors.Wrap(err, "encode path") + } + encoded, err := e.Result() + if err != nil { + return res, errors.Wrap(err, "encode path") + } + pathParts[5] = encoded + } + pathParts[6] = "/icons" + uri.AddPathParts(u, pathParts[:]...) + + stage = "EncodeRequest" + r, err := ht.NewRequest(ctx, "POST", u) + if err != nil { + return res, errors.Wrap(err, "create request") } stage = "SendRequest" @@ -5863,7 +5082,7 @@ func (c *Client) sendUploadCacheActionItem(ctx context.Context, request OptUploa defer resp.Body.Close() stage = "DecodeResponse" - result, err := decodeUploadCacheActionItemResponse(resp) + result, err := decodeUploadPreviewIconResponse(resp) if err != nil { return res, errors.Wrap(err, "decode response") } diff --git a/internal/agent/http_cache/tuistcache/api/oas_handlers_gen.go b/internal/agent/http_cache/tuistcache/api/oas_handlers_gen.go index 9e4e9df1..53628ca7 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_handlers_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_handlers_gen.go @@ -68,68 +68,6 @@ func (s *Server) handleAuthenticateRequest(args [0]string, argsEscaped bool, w h ID: "authenticate", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "Authenticate", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "Authenticate", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } request, close, err := s.decodeAuthenticateRequest(r) if err != nil { err = &ogenerrors.DecodeRequestError{ @@ -245,68 +183,6 @@ func (s *Server) handleCacheArtifactExistsRequest(args [0]string, argsEscaped bo ID: "cacheArtifactExists", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CacheArtifactExists", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CacheArtifactExists", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeCacheArtifactExistsParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -383,6 +259,133 @@ func (s *Server) handleCacheArtifactExistsRequest(args [0]string, argsEscaped bo } } +// handleCancelInvitationRequest handles cancelInvitation operation. +// +// Cancels an invitation for a given invitee email and an organization. +// +// DELETE /api/organizations/{organization_name}/invitations +func (s *Server) handleCancelInvitationRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("cancelInvitation"), + semconv.HTTPRequestMethodKey.String("DELETE"), + semconv.HTTPRouteKey.String("/api/organizations/{organization_name}/invitations"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "CancelInvitation", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "CancelInvitation", + ID: "cancelInvitation", + } + ) + params, err := decodeCancelInvitationParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + request, close, err := s.decodeCancelInvitationRequest(r) + if err != nil { + err = &ogenerrors.DecodeRequestError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeRequest", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + defer func() { + if err := close(); err != nil { + recordError("CloseRequest", err) + } + }() + + var response CancelInvitationRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "CancelInvitation", + OperationSummary: "Cancels an invitation", + OperationID: "cancelInvitation", + Body: request, + Params: middleware.Parameters{ + { + Name: "organization_name", + In: "path", + }: params.OrganizationName, + }, + Raw: r, + } + + type ( + Request = OptCancelInvitationReq + Params = CancelInvitationParams + Response = CancelInvitationRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackCancelInvitationParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.CancelInvitation(ctx, request, params) + return response, err + }, + ) + } else { + response, err = s.h.CancelInvitation(ctx, request, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeCancelInvitationResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + // handleCleanCacheRequest handles cleanCache operation. // // Cleans cache for a given project. @@ -431,68 +434,6 @@ func (s *Server) handleCleanCacheRequest(args [2]string, argsEscaped bool, w htt ID: "cleanCache", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CleanCache", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CleanCache", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeCleanCacheParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -610,68 +551,6 @@ func (s *Server) handleCompleteAnalyticsArtifactMultipartUploadRequest(args [1]s ID: "completeAnalyticsArtifactMultipartUpload", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CompleteAnalyticsArtifactMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CompleteAnalyticsArtifactMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeCompleteAnalyticsArtifactMultipartUploadParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -800,68 +679,6 @@ func (s *Server) handleCompleteAnalyticsArtifactsUploadsRequest(args [1]string, ID: "completeAnalyticsArtifactsUploads", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CompleteAnalyticsArtifactsUploads", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CompleteAnalyticsArtifactsUploads", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeCompleteAnalyticsArtifactsUploadsParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -990,68 +807,6 @@ func (s *Server) handleCompleteCacheArtifactMultipartUploadRequest(args [0]strin ID: "completeCacheArtifactMultipartUpload", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CompleteCacheArtifactMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CompleteCacheArtifactMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeCompleteCacheArtifactMultipartUploadParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -1196,68 +951,6 @@ func (s *Server) handleCompletePreviewsMultipartUploadRequest(args [2]string, ar ID: "completePreviewsMultipartUpload", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CompletePreviewsMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CompletePreviewsMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeCompletePreviewsMultipartUploadParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -1341,6 +1034,133 @@ func (s *Server) handleCompletePreviewsMultipartUploadRequest(args [2]string, ar } } +// handleCreateAccountTokenRequest handles createAccountToken operation. +// +// This endpoint returns a new account token. +// +// POST /api/accounts/{account_handle}/tokens +func (s *Server) handleCreateAccountTokenRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("createAccountToken"), + semconv.HTTPRequestMethodKey.String("POST"), + semconv.HTTPRouteKey.String("/api/accounts/{account_handle}/tokens"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "CreateAccountToken", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "CreateAccountToken", + ID: "createAccountToken", + } + ) + params, err := decodeCreateAccountTokenParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + request, close, err := s.decodeCreateAccountTokenRequest(r) + if err != nil { + err = &ogenerrors.DecodeRequestError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeRequest", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + defer func() { + if err := close(); err != nil { + recordError("CloseRequest", err) + } + }() + + var response CreateAccountTokenRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "CreateAccountToken", + OperationSummary: "Create a new account token.", + OperationID: "createAccountToken", + Body: request, + Params: middleware.Parameters{ + { + Name: "account_handle", + In: "path", + }: params.AccountHandle, + }, + Raw: r, + } + + type ( + Request = OptCreateAccountTokenReq + Params = CreateAccountTokenParams + Response = CreateAccountTokenRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackCreateAccountTokenParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.CreateAccountToken(ctx, request, params) + return response, err + }, + ) + } else { + response, err = s.h.CreateAccountToken(ctx, request, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeCreateAccountTokenResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + // handleCreateCommandEventRequest handles createCommandEvent operation. // // Create a a new command analytics event. @@ -1389,68 +1209,6 @@ func (s *Server) handleCreateCommandEventRequest(args [0]string, argsEscaped boo ID: "createCommandEvent", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CreateCommandEvent", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CreateCommandEvent", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeCreateCommandEventParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -1578,68 +1336,6 @@ func (s *Server) handleCreateInvitationRequest(args [1]string, argsEscaped bool, ID: "createInvitation", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CreateInvitation", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CreateInvitation", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeCreateInvitationParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -1767,68 +1463,6 @@ func (s *Server) handleCreateOrganizationRequest(args [0]string, argsEscaped boo ID: "createOrganization", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CreateOrganization", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CreateOrganization", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } request, close, err := s.decodeCreateOrganizationRequest(r) if err != nil { err = &ogenerrors.DecodeRequestError{ @@ -1941,68 +1575,6 @@ func (s *Server) handleCreateProjectRequest(args [0]string, argsEscaped bool, w ID: "createProject", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CreateProject", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CreateProject", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } request, close, err := s.decodeCreateProjectRequest(r) if err != nil { err = &ogenerrors.DecodeRequestError{ @@ -2115,68 +1687,6 @@ func (s *Server) handleCreateProjectTokenRequest(args [2]string, argsEscaped boo ID: "createProjectToken", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "CreateProjectToken", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "CreateProjectToken", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeCreateProjectTokenParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -2293,68 +1803,6 @@ func (s *Server) handleDeleteOrganizationRequest(args [1]string, argsEscaped boo ID: "deleteOrganization", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "DeleteOrganization", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "DeleteOrganization", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeDeleteOrganizationParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -2467,68 +1915,6 @@ func (s *Server) handleDeleteProjectRequest(args [1]string, argsEscaped bool, w ID: "deleteProject", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "DeleteProject", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "DeleteProject", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeDeleteProjectParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -2641,68 +2027,6 @@ func (s *Server) handleDownloadCacheArtifactRequest(args [0]string, argsEscaped ID: "downloadCacheArtifact", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "DownloadCacheArtifact", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "DownloadCacheArtifact", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeDownloadCacheArtifactParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -2781,7 +2105,7 @@ func (s *Server) handleDownloadCacheArtifactRequest(args [0]string, argsEscaped // handleDownloadPreviewRequest handles downloadPreview operation. // -// This endpoint returns a signed URL that can be used to download a preview. +// This endpoint returns a preview with a given id, including the url to download the preview. // // GET /api/projects/{account_handle}/{project_handle}/previews/{preview_id} func (s *Server) handleDownloadPreviewRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { @@ -2827,68 +2151,6 @@ func (s *Server) handleDownloadPreviewRequest(args [3]string, argsEscaped bool, ID: "downloadPreview", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "DownloadPreview", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "DownloadPreview", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeDownloadPreviewParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -2905,7 +2167,7 @@ func (s *Server) handleDownloadPreviewRequest(args [3]string, argsEscaped bool, mreq := middleware.Request{ Context: ctx, OperationName: "DownloadPreview", - OperationSummary: "Downloads a preview.", + OperationSummary: "Returns a preview with a given id.", OperationID: "downloadPreview", Body: nil, Params: middleware.Parameters{ @@ -3010,68 +2272,6 @@ func (s *Server) handleGenerateAnalyticsArtifactMultipartUploadURLRequest(args [ ID: "generateAnalyticsArtifactMultipartUploadURL", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "GenerateAnalyticsArtifactMultipartUploadURL", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "GenerateAnalyticsArtifactMultipartUploadURL", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeGenerateAnalyticsArtifactMultipartUploadURLParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -3200,68 +2400,6 @@ func (s *Server) handleGenerateCacheArtifactMultipartUploadURLRequest(args [0]st ID: "generateCacheArtifactMultipartUploadURL", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "GenerateCacheArtifactMultipartUploadURL", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "GenerateCacheArtifactMultipartUploadURL", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeGenerateCacheArtifactMultipartUploadURLParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -3399,68 +2537,6 @@ func (s *Server) handleGeneratePreviewsMultipartUploadURLRequest(args [2]string, ID: "generatePreviewsMultipartUploadURL", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "GeneratePreviewsMultipartUploadURL", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "GeneratePreviewsMultipartUploadURL", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeGeneratePreviewsMultipartUploadURLParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -3592,68 +2668,6 @@ func (s *Server) handleGetCacheActionItemRequest(args [3]string, argsEscaped boo ID: "getCacheActionItem", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "GetCacheActionItem", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "GetCacheActionItem", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeGetCacheActionItemParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -3774,68 +2788,6 @@ func (s *Server) handleGetDeviceCodeRequest(args [1]string, argsEscaped bool, w ID: "getDeviceCode", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "GetDeviceCode", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "GetDeviceCode", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeGetDeviceCodeParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -3942,74 +2894,8 @@ func (s *Server) handleListOrganizationsRequest(args [0]string, argsEscaped bool span.SetStatus(codes.Error, stage) s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) } - err error - opErrContext = ogenerrors.OperationContext{ - Name: "ListOrganizations", - ID: "listOrganizations", - } + err error ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "ListOrganizations", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "ListOrganizations", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } var response ListOrganizationsRes if m := s.cfg.Middleware; m != nil { @@ -4059,6 +2945,146 @@ func (s *Server) handleListOrganizationsRequest(args [0]string, argsEscaped bool } } +// handleListPreviewsRequest handles listPreviews operation. +// +// This endpoint returns a list of previews for a given project. +// +// GET /api/projects/{account_handle}/{project_handle}/previews +func (s *Server) handleListPreviewsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listPreviews"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/projects/{account_handle}/{project_handle}/previews"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "ListPreviews", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "ListPreviews", + ID: "listPreviews", + } + ) + params, err := decodeListPreviewsParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ListPreviewsRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "ListPreviews", + OperationSummary: "List previews.", + OperationID: "listPreviews", + Body: nil, + Params: middleware.Parameters{ + { + Name: "account_handle", + In: "path", + }: params.AccountHandle, + { + Name: "project_handle", + In: "path", + }: params.ProjectHandle, + { + Name: "display_name", + In: "query", + }: params.DisplayName, + { + Name: "specifier", + In: "query", + }: params.Specifier, + { + Name: "supported_platforms", + In: "query", + }: params.SupportedPlatforms, + { + Name: "page_size", + In: "query", + }: params.PageSize, + { + Name: "page", + In: "query", + }: params.Page, + { + Name: "distinct_field", + In: "query", + }: params.DistinctField, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListPreviewsParams + Response = ListPreviewsRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListPreviewsParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListPreviews(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListPreviews(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeListPreviewsResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + // handleListProjectTokensRequest handles listProjectTokens operation. // // This endpoint returns all tokens for a given project. @@ -4107,68 +3133,6 @@ func (s *Server) handleListProjectTokensRequest(args [2]string, argsEscaped bool ID: "listProjectTokens", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "ListProjectTokens", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "ListProjectTokens", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeListProjectTokensParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -4279,74 +3243,8 @@ func (s *Server) handleListProjectsRequest(args [0]string, argsEscaped bool, w h span.SetStatus(codes.Error, stage) s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) } - err error - opErrContext = ogenerrors.OperationContext{ - Name: "ListProjects", - ID: "listProjects", - } + err error ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "ListProjects", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "ListProjects", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } var response ListProjectsRes if m := s.cfg.Middleware; m != nil { @@ -4396,6 +3294,146 @@ func (s *Server) handleListProjectsRequest(args [0]string, argsEscaped bool, w h } } +// handleListRunsRequest handles listRuns operation. +// +// List runs associated with a given project. +// +// GET /api/projects/{account_handle}/{project_handle}/runs +func (s *Server) handleListRunsRequest(args [2]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("listRuns"), + semconv.HTTPRequestMethodKey.String("GET"), + semconv.HTTPRouteKey.String("/api/projects/{account_handle}/{project_handle}/runs"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "ListRuns", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "ListRuns", + ID: "listRuns", + } + ) + params, err := decodeListRunsParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response ListRunsRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "ListRuns", + OperationSummary: "List runs associated with a given project.", + OperationID: "listRuns", + Body: nil, + Params: middleware.Parameters{ + { + Name: "account_handle", + In: "path", + }: params.AccountHandle, + { + Name: "project_handle", + In: "path", + }: params.ProjectHandle, + { + Name: "name", + In: "query", + }: params.Name, + { + Name: "git_ref", + In: "query", + }: params.GitRef, + { + Name: "git_branch", + In: "query", + }: params.GitBranch, + { + Name: "git_commit_sha", + In: "query", + }: params.GitCommitSha, + { + Name: "page_size", + In: "query", + }: params.PageSize, + { + Name: "page", + In: "query", + }: params.Page, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = ListRunsParams + Response = ListRunsRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackListRunsParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.ListRuns(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.ListRuns(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeListRunsResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + // handleRefreshTokenRequest handles refreshToken operation. // // This endpoint returns new tokens for a given refresh token if the refresh token is valid. @@ -4444,68 +3482,6 @@ func (s *Server) handleRefreshTokenRequest(args [0]string, argsEscaped bool, w h ID: "refreshToken", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "RefreshToken", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "RefreshToken", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } request, close, err := s.decodeRefreshTokenRequest(r) if err != nil { err = &ogenerrors.DecodeRequestError{ @@ -4618,68 +3594,6 @@ func (s *Server) handleRevokeProjectTokenRequest(args [3]string, argsEscaped boo ID: "revokeProjectToken", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "RevokeProjectToken", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "RevokeProjectToken", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeRevokeProjectTokenParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -4800,68 +3714,6 @@ func (s *Server) handleShowOrganizationRequest(args [1]string, argsEscaped bool, ID: "showOrganization", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "ShowOrganization", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "ShowOrganization", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeShowOrganizationParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -4974,68 +3826,6 @@ func (s *Server) handleShowOrganizationUsageRequest(args [1]string, argsEscaped ID: "showOrganizationUsage", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "ShowOrganizationUsage", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "ShowOrganizationUsage", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeShowOrganizationUsageParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -5148,68 +3938,6 @@ func (s *Server) handleShowProjectRequest(args [2]string, argsEscaped bool, w ht ID: "showProject", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "ShowProject", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "ShowProject", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeShowProjectParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -5327,68 +4055,6 @@ func (s *Server) handleStartAnalyticsArtifactMultipartUploadRequest(args [1]stri ID: "startAnalyticsArtifactMultipartUpload", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "StartAnalyticsArtifactMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "StartAnalyticsArtifactMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeStartAnalyticsArtifactMultipartUploadParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -5433,7 +4099,7 @@ func (s *Server) handleStartAnalyticsArtifactMultipartUploadRequest(args [1]stri } type ( - Request = CommandEventArtifact + Request = OptCommandEventArtifact Params = StartAnalyticsArtifactMultipartUploadParams Response = StartAnalyticsArtifactMultipartUploadRes ) @@ -5517,68 +4183,6 @@ func (s *Server) handleStartCacheArtifactMultipartUploadRequest(args [0]string, ID: "startCacheArtifactMultipartUpload", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "StartCacheArtifactMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "StartCacheArtifactMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeStartCacheArtifactMultipartUploadParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -5704,68 +4308,6 @@ func (s *Server) handleStartPreviewsMultipartUploadRequest(args [2]string, argsE ID: "startPreviewsMultipartUpload", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "StartPreviewsMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "StartPreviewsMultipartUpload", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeStartPreviewsMultipartUploadParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -5849,6 +4391,133 @@ func (s *Server) handleStartPreviewsMultipartUploadRequest(args [2]string, argsE } } +// handleUpdateAccountRequest handles updateAccount operation. +// +// Updates the given account. +// +// PATCH /api/accounts/{account_handle} +func (s *Server) handleUpdateAccountRequest(args [1]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("updateAccount"), + semconv.HTTPRequestMethodKey.String("PATCH"), + semconv.HTTPRouteKey.String("/api/accounts/{account_handle}"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "UpdateAccount", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "UpdateAccount", + ID: "updateAccount", + } + ) + params, err := decodeUpdateAccountParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + request, close, err := s.decodeUpdateAccountRequest(r) + if err != nil { + err = &ogenerrors.DecodeRequestError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeRequest", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + defer func() { + if err := close(); err != nil { + recordError("CloseRequest", err) + } + }() + + var response UpdateAccountRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "UpdateAccount", + OperationSummary: "Update account", + OperationID: "updateAccount", + Body: request, + Params: middleware.Parameters{ + { + Name: "account_handle", + In: "path", + }: params.AccountHandle, + }, + Raw: r, + } + + type ( + Request = OptUpdateAccountReq + Params = UpdateAccountParams + Response = UpdateAccountRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackUpdateAccountParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.UpdateAccount(ctx, request, params) + return response, err + }, + ) + } else { + response, err = s.h.UpdateAccount(ctx, request, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeUpdateAccountResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} + // handleUpdateOrganizationRequest handles updateOrganization operation. // // Updates an organization with given parameters. @@ -5897,68 +4566,6 @@ func (s *Server) handleUpdateOrganizationRequest(args [1]string, argsEscaped boo ID: "updateOrganization", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "UpdateOrganization", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "UpdateOrganization", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeUpdateOrganizationParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -6086,68 +4693,6 @@ func (s *Server) handleUpdateOrganization2Request(args [1]string, argsEscaped bo ID: "updateOrganization (2)", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "UpdateOrganization2", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "UpdateOrganization2", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeUpdateOrganization2Params(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -6275,68 +4820,6 @@ func (s *Server) handleUpdateOrganizationMemberRequest(args [2]string, argsEscap ID: "updateOrganizationMember", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "UpdateOrganizationMember", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "UpdateOrganizationMember", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeUpdateOrganizationMemberParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -6468,68 +4951,6 @@ func (s *Server) handleUpdateProjectRequest(args [2]string, argsEscaped bool, w ID: "updateProject", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "UpdateProject", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "UpdateProject", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeUpdateProjectParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -6662,68 +5083,6 @@ func (s *Server) handleUploadCacheActionItemRequest(args [2]string, argsEscaped ID: "uploadCacheActionItem", } ) - { - type bitset = [1]uint8 - var satisfied bitset - { - sctx, ok, err := s.securityAuthorization(ctx, "UploadCacheActionItem", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Authorization", - Err: err, - } - defer recordError("Security:Authorization", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 0 - ctx = sctx - } - } - { - sctx, ok, err := s.securityCookie(ctx, "UploadCacheActionItem", r) - if err != nil { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Security: "Cookie", - Err: err, - } - defer recordError("Security:Cookie", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - if ok { - satisfied[0] |= 1 << 1 - ctx = sctx - } - } - - if ok := func() bool { - nextRequirement: - for _, requirement := range []bitset{ - {0b00000001}, - {0b00000010}, - } { - for i, mask := range requirement { - if satisfied[i]&mask != mask { - continue nextRequirement - } - } - return true - } - return false - }(); !ok { - err = &ogenerrors.SecurityError{ - OperationContext: opErrContext, - Err: ogenerrors.ErrSecurityRequirementIsNotSatisfied, - } - defer recordError("Security", err) - s.cfg.ErrorHandler(ctx, w, r, err) - return - } - } params, err := decodeUploadCacheActionItemParams(args, argsEscaped, r) if err != nil { err = &ogenerrors.DecodeParamsError{ @@ -6806,3 +5165,123 @@ func (s *Server) handleUploadCacheActionItemRequest(args [2]string, argsEscaped return } } + +// handleUploadPreviewIconRequest handles uploadPreviewIcon operation. +// +// The endpoint uploads a preview icon. +// +// POST /api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons +func (s *Server) handleUploadPreviewIconRequest(args [3]string, argsEscaped bool, w http.ResponseWriter, r *http.Request) { + otelAttrs := []attribute.KeyValue{ + otelogen.OperationID("uploadPreviewIcon"), + semconv.HTTPRequestMethodKey.String("POST"), + semconv.HTTPRouteKey.String("/api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons"), + } + + // Start a span for this request. + ctx, span := s.cfg.Tracer.Start(r.Context(), "UploadPreviewIcon", + trace.WithAttributes(otelAttrs...), + serverSpanKind, + ) + defer span.End() + + // Add Labeler to context. + labeler := &Labeler{attrs: otelAttrs} + ctx = contextWithLabeler(ctx, labeler) + + // Run stopwatch. + startTime := time.Now() + defer func() { + elapsedDuration := time.Since(startTime) + attrOpt := metric.WithAttributeSet(labeler.AttributeSet()) + + // Increment request counter. + s.requests.Add(ctx, 1, attrOpt) + + // Use floating point division here for higher precision (instead of Millisecond method). + s.duration.Record(ctx, float64(float64(elapsedDuration)/float64(time.Millisecond)), attrOpt) + }() + + var ( + recordError = func(stage string, err error) { + span.RecordError(err) + span.SetStatus(codes.Error, stage) + s.errors.Add(ctx, 1, metric.WithAttributeSet(labeler.AttributeSet())) + } + err error + opErrContext = ogenerrors.OperationContext{ + Name: "UploadPreviewIcon", + ID: "uploadPreviewIcon", + } + ) + params, err := decodeUploadPreviewIconParams(args, argsEscaped, r) + if err != nil { + err = &ogenerrors.DecodeParamsError{ + OperationContext: opErrContext, + Err: err, + } + defer recordError("DecodeParams", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + var response UploadPreviewIconRes + if m := s.cfg.Middleware; m != nil { + mreq := middleware.Request{ + Context: ctx, + OperationName: "UploadPreviewIcon", + OperationSummary: "Uploads a preview icon.", + OperationID: "uploadPreviewIcon", + Body: nil, + Params: middleware.Parameters{ + { + Name: "account_handle", + In: "path", + }: params.AccountHandle, + { + Name: "project_handle", + In: "path", + }: params.ProjectHandle, + { + Name: "preview_id", + In: "path", + }: params.PreviewID, + }, + Raw: r, + } + + type ( + Request = struct{} + Params = UploadPreviewIconParams + Response = UploadPreviewIconRes + ) + response, err = middleware.HookMiddleware[ + Request, + Params, + Response, + ]( + m, + mreq, + unpackUploadPreviewIconParams, + func(ctx context.Context, request Request, params Params) (response Response, err error) { + response, err = s.h.UploadPreviewIcon(ctx, params) + return response, err + }, + ) + } else { + response, err = s.h.UploadPreviewIcon(ctx, params) + } + if err != nil { + defer recordError("Internal", err) + s.cfg.ErrorHandler(ctx, w, r, err) + return + } + + if err := encodeUploadPreviewIconResponse(response, w, span); err != nil { + defer recordError("EncodeResponse", err) + if !errors.Is(err, ht.ErrInternalServerErrorResponse) { + s.cfg.ErrorHandler(ctx, w, r, err) + } + return + } +} diff --git a/internal/agent/http_cache/tuistcache/api/oas_interfaces_gen.go b/internal/agent/http_cache/tuistcache/api/oas_interfaces_gen.go index f8370a7e..edc1e1d0 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_interfaces_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_interfaces_gen.go @@ -9,6 +9,10 @@ type CacheArtifactExistsRes interface { cacheArtifactExistsRes() } +type CancelInvitationRes interface { + cancelInvitationRes() +} + type CleanCacheRes interface { cleanCacheRes() } @@ -29,6 +33,10 @@ type CompletePreviewsMultipartUploadRes interface { completePreviewsMultipartUploadRes() } +type CreateAccountTokenRes interface { + createAccountTokenRes() +} + type CreateCommandEventRes interface { createCommandEventRes() } @@ -89,6 +97,10 @@ type ListOrganizationsRes interface { listOrganizationsRes() } +type ListPreviewsRes interface { + listPreviewsRes() +} + type ListProjectTokensRes interface { listProjectTokensRes() } @@ -97,6 +109,10 @@ type ListProjectsRes interface { listProjectsRes() } +type ListRunsRes interface { + listRunsRes() +} + type RefreshTokenRes interface { refreshTokenRes() } @@ -129,6 +145,10 @@ type StartPreviewsMultipartUploadRes interface { startPreviewsMultipartUploadRes() } +type UpdateAccountRes interface { + updateAccountRes() +} + type UpdateOrganization2Res interface { updateOrganization2Res() } @@ -148,3 +168,7 @@ type UpdateProjectRes interface { type UploadCacheActionItemRes interface { uploadCacheActionItemRes() } + +type UploadPreviewIconRes interface { + uploadPreviewIconRes() +} diff --git a/internal/agent/http_cache/tuistcache/api/oas_json_gen.go b/internal/agent/http_cache/tuistcache/api/oas_json_gen.go index 96e3d563..148712bc 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_json_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_json_gen.go @@ -14,68 +14,68 @@ import ( ) // Encode implements json.Marshaler. -func (s *ArtifactDownloadURL) Encode(e *jx.Encoder) { +func (s *Account) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *ArtifactDownloadURL) encodeFields(e *jx.Encoder) { +func (s *Account) encodeFields(e *jx.Encoder) { { - e.FieldStart("expires_at") - e.Int(s.ExpiresAt) + e.FieldStart("handle") + e.Str(s.Handle) } { - e.FieldStart("url") - e.Str(s.URL) + e.FieldStart("id") + e.Float64(s.ID) } } -var jsonFieldsNameOfArtifactDownloadURL = [2]string{ - 0: "expires_at", - 1: "url", +var jsonFieldsNameOfAccount = [2]string{ + 0: "handle", + 1: "id", } -// Decode decodes ArtifactDownloadURL from json. -func (s *ArtifactDownloadURL) Decode(d *jx.Decoder) error { +// Decode decodes Account from json. +func (s *Account) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ArtifactDownloadURL to nil") + return errors.New("invalid: unable to decode Account to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "expires_at": + case "handle": requiredBitSet[0] |= 1 << 0 if err := func() error { - v, err := d.Int() - s.ExpiresAt = int(v) + v, err := d.Str() + s.Handle = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"expires_at\"") + return errors.Wrap(err, "decode field \"handle\"") } - case "url": + case "id": requiredBitSet[0] |= 1 << 1 if err := func() error { - v, err := d.Str() - s.URL = string(v) + v, err := d.Float64() + s.ID = float64(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"url\"") + return errors.Wrap(err, "decode field \"id\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode ArtifactDownloadURL") + return errors.Wrap(err, "decode Account") } // Validate required fields. var failures []validate.FieldError @@ -92,8 +92,8 @@ func (s *ArtifactDownloadURL) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfArtifactDownloadURL) { - name = jsonFieldsNameOfArtifactDownloadURL[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfAccount) { + name = jsonFieldsNameOfAccount[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -114,49 +114,137 @@ func (s *ArtifactDownloadURL) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *ArtifactDownloadURL) MarshalJSON() ([]byte, error) { +func (s *Account) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ArtifactDownloadURL) UnmarshalJSON(data []byte) error { +func (s *Account) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ArtifactMultipartUploadPart as json. -func (s ArtifactMultipartUploadPart) Encode(e *jx.Encoder) { - unwrapped := jx.Raw(s) +// Encode implements json.Marshaler. +func (s *ArtifactMultipartUploadPart) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} - if len(unwrapped) != 0 { - e.Raw(unwrapped) +// encodeFields encodes fields. +func (s *ArtifactMultipartUploadPart) encodeFields(e *jx.Encoder) { + { + if s.ContentLength.Set { + e.FieldStart("content_length") + s.ContentLength.Encode(e) + } + } + { + e.FieldStart("part_number") + e.Int(s.PartNumber) + } + { + e.FieldStart("upload_id") + e.Str(s.UploadID) } } +var jsonFieldsNameOfArtifactMultipartUploadPart = [3]string{ + 0: "content_length", + 1: "part_number", + 2: "upload_id", +} + // Decode decodes ArtifactMultipartUploadPart from json. func (s *ArtifactMultipartUploadPart) Decode(d *jx.Decoder) error { if s == nil { return errors.New("invalid: unable to decode ArtifactMultipartUploadPart to nil") } - var unwrapped jx.Raw - if err := func() error { - v, err := d.RawAppend(nil) - unwrapped = jx.Raw(v) - if err != nil { - return err + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "content_length": + if err := func() error { + s.ContentLength.Reset() + if err := s.ContentLength.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"content_length\"") + } + case "part_number": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Int() + s.PartNumber = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"part_number\"") + } + case "upload_id": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + v, err := d.Str() + s.UploadID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"upload_id\"") + } + default: + return d.Skip() } return nil - }(); err != nil { - return errors.Wrap(err, "alias") + }); err != nil { + return errors.Wrap(err, "decode ArtifactMultipartUploadPart") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000110, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfArtifactMultipartUploadPart) { + name = jsonFieldsNameOfArtifactMultipartUploadPart[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } } - *s = ArtifactMultipartUploadPart(unwrapped) + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s ArtifactMultipartUploadPart) MarshalJSON() ([]byte, error) { +func (s *ArtifactMultipartUploadPart) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil @@ -892,6 +980,119 @@ func (s *ArtifactUploadIDStatus) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode implements json.Marshaler. +func (s *ArtifactUploadURL) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ArtifactUploadURL) encodeFields(e *jx.Encoder) { + { + e.FieldStart("expires_at") + e.Int(s.ExpiresAt) + } + { + e.FieldStart("url") + e.Str(s.URL) + } +} + +var jsonFieldsNameOfArtifactUploadURL = [2]string{ + 0: "expires_at", + 1: "url", +} + +// Decode decodes ArtifactUploadURL from json. +func (s *ArtifactUploadURL) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ArtifactUploadURL to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "expires_at": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Int() + s.ExpiresAt = int(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"expires_at\"") + } + case "url": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.URL = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ArtifactUploadURL") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfArtifactUploadURL) { + name = jsonFieldsNameOfArtifactUploadURL[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ArtifactUploadURL) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ArtifactUploadURL) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *AuthenticateReq) Encode(e *jx.Encoder) { e.ObjStart() @@ -1909,17 +2110,17 @@ func (s *CacheArtifactExistsUnauthorized) UnmarshalJSON(data []byte) error { return s.Decode(d) } -// Encode encodes CleanCacheForbidden as json. -func (s *CleanCacheForbidden) Encode(e *jx.Encoder) { +// Encode encodes CancelInvitationForbidden as json. +func (s *CancelInvitationForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CleanCacheForbidden from json. -func (s *CleanCacheForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CancelInvitationForbidden from json. +func (s *CancelInvitationForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CleanCacheForbidden to nil") + return errors.New("invalid: unable to decode CancelInvitationForbidden to nil") } var unwrapped Error if err := func() error { @@ -1930,34 +2131,34 @@ func (s *CleanCacheForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CleanCacheForbidden(unwrapped) + *s = CancelInvitationForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CleanCacheForbidden) MarshalJSON() ([]byte, error) { +func (s *CancelInvitationForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CleanCacheForbidden) UnmarshalJSON(data []byte) error { +func (s *CancelInvitationForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CleanCacheNotFound as json. -func (s *CleanCacheNotFound) Encode(e *jx.Encoder) { +// Encode encodes CancelInvitationNotFound as json. +func (s *CancelInvitationNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CleanCacheNotFound from json. -func (s *CleanCacheNotFound) Decode(d *jx.Decoder) error { +// Decode decodes CancelInvitationNotFound from json. +func (s *CancelInvitationNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CleanCacheNotFound to nil") + return errors.New("invalid: unable to decode CancelInvitationNotFound to nil") } var unwrapped Error if err := func() error { @@ -1968,146 +2169,74 @@ func (s *CleanCacheNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CleanCacheNotFound(unwrapped) + *s = CancelInvitationNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CleanCacheNotFound) MarshalJSON() ([]byte, error) { +func (s *CancelInvitationNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CleanCacheNotFound) UnmarshalJSON(data []byte) error { +func (s *CancelInvitationNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CleanCacheUnauthorized as json. -func (s *CleanCacheUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) +// Encode implements json.Marshaler. +func (s *CancelInvitationReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} - unwrapped.Encode(e) +// encodeFields encodes fields. +func (s *CancelInvitationReq) encodeFields(e *jx.Encoder) { + { + e.FieldStart("invitee_email") + e.Str(s.InviteeEmail) + } } -// Decode decodes CleanCacheUnauthorized from json. -func (s *CleanCacheUnauthorized) Decode(d *jx.Decoder) error { +var jsonFieldsNameOfCancelInvitationReq = [1]string{ + 0: "invitee_email", +} + +// Decode decodes CancelInvitationReq from json. +func (s *CancelInvitationReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CleanCacheUnauthorized to nil") - } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") - } - *s = CleanCacheUnauthorized(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CleanCacheUnauthorized) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CleanCacheUnauthorized) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode implements json.Marshaler. -func (s *CommandEvent) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *CommandEvent) encodeFields(e *jx.Encoder) { - { - e.FieldStart("id") - e.Float64(s.ID) - } - { - e.FieldStart("name") - e.Str(s.Name) - } - { - e.FieldStart("url") - e.Str(s.URL) - } -} - -var jsonFieldsNameOfCommandEvent = [3]string{ - 0: "id", - 1: "name", - 2: "url", -} - -// Decode decodes CommandEvent from json. -func (s *CommandEvent) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CommandEvent to nil") + return errors.New("invalid: unable to decode CancelInvitationReq to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "id": + case "invitee_email": requiredBitSet[0] |= 1 << 0 - if err := func() error { - v, err := d.Float64() - s.ID = float64(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"id\"") - } - case "name": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - v, err := d.Str() - s.Name = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"name\"") - } - case "url": - requiredBitSet[0] |= 1 << 2 if err := func() error { v, err := d.Str() - s.URL = string(v) + s.InviteeEmail = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"url\"") + return errors.Wrap(err, "decode field \"invitee_email\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CommandEvent") + return errors.Wrap(err, "decode CancelInvitationReq") } // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000111, + 0b00000001, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -2119,8 +2248,8 @@ func (s *CommandEvent) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfCommandEvent) { - name = jsonFieldsNameOfCommandEvent[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfCancelInvitationReq) { + name = jsonFieldsNameOfCancelInvitationReq[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -2141,71 +2270,67 @@ func (s *CommandEvent) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *CommandEvent) MarshalJSON() ([]byte, error) { +func (s *CancelInvitationReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CommandEvent) UnmarshalJSON(data []byte) error { +func (s *CancelInvitationReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CommandEventArtifact as json. -func (s CommandEventArtifact) Encode(e *jx.Encoder) { - unwrapped := jx.Raw(s) +// Encode encodes CancelInvitationUnauthorized as json. +func (s *CancelInvitationUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) - if len(unwrapped) != 0 { - e.Raw(unwrapped) - } + unwrapped.Encode(e) } -// Decode decodes CommandEventArtifact from json. -func (s *CommandEventArtifact) Decode(d *jx.Decoder) error { +// Decode decodes CancelInvitationUnauthorized from json. +func (s *CancelInvitationUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CommandEventArtifact to nil") + return errors.New("invalid: unable to decode CancelInvitationUnauthorized to nil") } - var unwrapped jx.Raw + var unwrapped Error if err := func() error { - v, err := d.RawAppend(nil) - unwrapped = jx.Raw(v) - if err != nil { + if err := unwrapped.Decode(d); err != nil { return err } return nil }(); err != nil { return errors.Wrap(err, "alias") } - *s = CommandEventArtifact(unwrapped) + *s = CancelInvitationUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s CommandEventArtifact) MarshalJSON() ([]byte, error) { +func (s *CancelInvitationUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CommandEventArtifact) UnmarshalJSON(data []byte) error { +func (s *CancelInvitationUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteAnalyticsArtifactMultipartUploadForbidden as json. -func (s *CompleteAnalyticsArtifactMultipartUploadForbidden) Encode(e *jx.Encoder) { +// Encode encodes CleanCacheForbidden as json. +func (s *CleanCacheForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CompleteAnalyticsArtifactMultipartUploadForbidden from json. -func (s *CompleteAnalyticsArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CleanCacheForbidden from json. +func (s *CleanCacheForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadForbidden to nil") + return errors.New("invalid: unable to decode CleanCacheForbidden to nil") } var unwrapped Error if err := func() error { @@ -2216,34 +2341,34 @@ func (s *CompleteAnalyticsArtifactMultipartUploadForbidden) Decode(d *jx.Decoder }(); err != nil { return errors.Wrap(err, "alias") } - *s = CompleteAnalyticsArtifactMultipartUploadForbidden(unwrapped) + *s = CleanCacheForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadForbidden) MarshalJSON() ([]byte, error) { +func (s *CleanCacheForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadForbidden) UnmarshalJSON(data []byte) error { +func (s *CleanCacheForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteAnalyticsArtifactMultipartUploadInternalServerError as json. -func (s *CompleteAnalyticsArtifactMultipartUploadInternalServerError) Encode(e *jx.Encoder) { +// Encode encodes CleanCacheNotFound as json. +func (s *CleanCacheNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CompleteAnalyticsArtifactMultipartUploadInternalServerError from json. -func (s *CompleteAnalyticsArtifactMultipartUploadInternalServerError) Decode(d *jx.Decoder) error { +// Decode decodes CleanCacheNotFound from json. +func (s *CleanCacheNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadInternalServerError to nil") + return errors.New("invalid: unable to decode CleanCacheNotFound to nil") } var unwrapped Error if err := func() error { @@ -2254,34 +2379,34 @@ func (s *CompleteAnalyticsArtifactMultipartUploadInternalServerError) Decode(d * }(); err != nil { return errors.Wrap(err, "alias") } - *s = CompleteAnalyticsArtifactMultipartUploadInternalServerError(unwrapped) + *s = CleanCacheNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadInternalServerError) MarshalJSON() ([]byte, error) { +func (s *CleanCacheNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadInternalServerError) UnmarshalJSON(data []byte) error { +func (s *CleanCacheNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteAnalyticsArtifactMultipartUploadNotFound as json. -func (s *CompleteAnalyticsArtifactMultipartUploadNotFound) Encode(e *jx.Encoder) { +// Encode encodes CleanCacheUnauthorized as json. +func (s *CleanCacheUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CompleteAnalyticsArtifactMultipartUploadNotFound from json. -func (s *CompleteAnalyticsArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) error { +// Decode decodes CleanCacheUnauthorized from json. +func (s *CleanCacheUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadNotFound to nil") + return errors.New("invalid: unable to decode CleanCacheUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -2292,87 +2417,108 @@ func (s *CompleteAnalyticsArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) }(); err != nil { return errors.Wrap(err, "alias") } - *s = CompleteAnalyticsArtifactMultipartUploadNotFound(unwrapped) + *s = CleanCacheUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadNotFound) MarshalJSON() ([]byte, error) { +func (s *CleanCacheUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadNotFound) UnmarshalJSON(data []byte) error { +func (s *CleanCacheUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadReq) Encode(e *jx.Encoder) { +func (s *CommandEvent) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *CompleteAnalyticsArtifactMultipartUploadReq) encodeFields(e *jx.Encoder) { +func (s *CommandEvent) encodeFields(e *jx.Encoder) { { - e.FieldStart("command_event_artifact") - s.CommandEventArtifact.Encode(e) + e.FieldStart("id") + e.Float64(s.ID) } { - e.FieldStart("multipart_upload_parts") - s.MultipartUploadParts.Encode(e) + e.FieldStart("name") + e.Str(s.Name) + } + { + e.FieldStart("url") + e.Str(s.URL) } } -var jsonFieldsNameOfCompleteAnalyticsArtifactMultipartUploadReq = [2]string{ - 0: "command_event_artifact", - 1: "multipart_upload_parts", +var jsonFieldsNameOfCommandEvent = [3]string{ + 0: "id", + 1: "name", + 2: "url", } -// Decode decodes CompleteAnalyticsArtifactMultipartUploadReq from json. -func (s *CompleteAnalyticsArtifactMultipartUploadReq) Decode(d *jx.Decoder) error { +// Decode decodes CommandEvent from json. +func (s *CommandEvent) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadReq to nil") + return errors.New("invalid: unable to decode CommandEvent to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "command_event_artifact": + case "id": requiredBitSet[0] |= 1 << 0 if err := func() error { - if err := s.CommandEventArtifact.Decode(d); err != nil { + v, err := d.Float64() + s.ID = float64(v) + if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"command_event_artifact\"") + return errors.Wrap(err, "decode field \"id\"") } - case "multipart_upload_parts": + case "name": requiredBitSet[0] |= 1 << 1 if err := func() error { - if err := s.MultipartUploadParts.Decode(d); err != nil { + v, err := d.Str() + s.Name = string(v) + if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"multipart_upload_parts\"") + return errors.Wrap(err, "decode field \"name\"") + } + case "url": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + v, err := d.Str() + s.URL = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CompleteAnalyticsArtifactMultipartUploadReq") + return errors.Wrap(err, "decode CommandEvent") } // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000011, + 0b00000111, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -2384,8 +2530,8 @@ func (s *CompleteAnalyticsArtifactMultipartUploadReq) Decode(d *jx.Decoder) erro bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfCompleteAnalyticsArtifactMultipartUploadReq) { - name = jsonFieldsNameOfCompleteAnalyticsArtifactMultipartUploadReq[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfCommandEvent) { + name = jsonFieldsNameOfCommandEvent[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -2406,193 +2552,84 @@ func (s *CompleteAnalyticsArtifactMultipartUploadReq) Decode(d *jx.Decoder) erro } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadReq) MarshalJSON() ([]byte, error) { +func (s *CommandEvent) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadReq) UnmarshalJSON(data []byte) error { +func (s *CommandEvent) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteAnalyticsArtifactMultipartUploadUnauthorized as json. -func (s *CompleteAnalyticsArtifactMultipartUploadUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode implements json.Marshaler. +func (s *CommandEventArtifact) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes CompleteAnalyticsArtifactMultipartUploadUnauthorized from json. -func (s *CompleteAnalyticsArtifactMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadUnauthorized to nil") - } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err +// encodeFields encodes fields. +func (s *CommandEventArtifact) encodeFields(e *jx.Encoder) { + { + if s.Name.Set { + e.FieldStart("name") + s.Name.Encode(e) } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") } - *s = CompleteAnalyticsArtifactMultipartUploadUnauthorized(unwrapped) - return nil + { + e.FieldStart("type") + s.Type.Encode(e) + } } -// MarshalJSON implements stdjson.Marshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil +var jsonFieldsNameOfCommandEventArtifact = [2]string{ + 0: "name", + 1: "type", } -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteAnalyticsArtifactMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes CompleteAnalyticsArtifactsUploadsForbidden as json. -func (s *CompleteAnalyticsArtifactsUploadsForbidden) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) -} - -// Decode decodes CompleteAnalyticsArtifactsUploadsForbidden from json. -func (s *CompleteAnalyticsArtifactsUploadsForbidden) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CompleteAnalyticsArtifactsUploadsForbidden to nil") - } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") - } - *s = CompleteAnalyticsArtifactsUploadsForbidden(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CompleteAnalyticsArtifactsUploadsForbidden) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteAnalyticsArtifactsUploadsForbidden) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes CompleteAnalyticsArtifactsUploadsNotFound as json. -func (s *CompleteAnalyticsArtifactsUploadsNotFound) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) -} - -// Decode decodes CompleteAnalyticsArtifactsUploadsNotFound from json. -func (s *CompleteAnalyticsArtifactsUploadsNotFound) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CompleteAnalyticsArtifactsUploadsNotFound to nil") - } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") - } - *s = CompleteAnalyticsArtifactsUploadsNotFound(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CompleteAnalyticsArtifactsUploadsNotFound) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteAnalyticsArtifactsUploadsNotFound) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode implements json.Marshaler. -func (s *CompleteAnalyticsArtifactsUploadsReq) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *CompleteAnalyticsArtifactsUploadsReq) encodeFields(e *jx.Encoder) { - { - e.FieldStart("modules") - e.ArrStart() - for _, elem := range s.Modules { - elem.Encode(e) - } - e.ArrEnd() - } -} - -var jsonFieldsNameOfCompleteAnalyticsArtifactsUploadsReq = [1]string{ - 0: "modules", -} - -// Decode decodes CompleteAnalyticsArtifactsUploadsReq from json. -func (s *CompleteAnalyticsArtifactsUploadsReq) Decode(d *jx.Decoder) error { +// Decode decodes CommandEventArtifact from json. +func (s *CommandEventArtifact) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteAnalyticsArtifactsUploadsReq to nil") + return errors.New("invalid: unable to decode CommandEventArtifact to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "modules": - requiredBitSet[0] |= 1 << 0 + case "name": if err := func() error { - s.Modules = make([]Module, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem Module - if err := elem.Decode(d); err != nil { - return err - } - s.Modules = append(s.Modules, elem) - return nil - }); err != nil { + s.Name.Reset() + if err := s.Name.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"modules\"") + return errors.Wrap(err, "decode field \"name\"") + } + case "type": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CompleteAnalyticsArtifactsUploadsReq") + return errors.Wrap(err, "decode CommandEventArtifact") } // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000010, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -2604,8 +2641,8 @@ func (s *CompleteAnalyticsArtifactsUploadsReq) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfCompleteAnalyticsArtifactsUploadsReq) { - name = jsonFieldsNameOfCompleteAnalyticsArtifactsUploadsReq[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfCommandEventArtifact) { + name = jsonFieldsNameOfCommandEventArtifact[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -2626,29 +2663,71 @@ func (s *CompleteAnalyticsArtifactsUploadsReq) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteAnalyticsArtifactsUploadsReq) MarshalJSON() ([]byte, error) { +func (s *CommandEventArtifact) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteAnalyticsArtifactsUploadsReq) UnmarshalJSON(data []byte) error { +func (s *CommandEventArtifact) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteAnalyticsArtifactsUploadsUnauthorized as json. -func (s *CompleteAnalyticsArtifactsUploadsUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes CommandEventArtifactType as json. +func (s CommandEventArtifactType) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes CommandEventArtifactType from json. +func (s *CommandEventArtifactType) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CommandEventArtifactType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch CommandEventArtifactType(v) { + case CommandEventArtifactTypeResultBundle: + *s = CommandEventArtifactTypeResultBundle + case CommandEventArtifactTypeInvocationRecord: + *s = CommandEventArtifactTypeInvocationRecord + case CommandEventArtifactTypeResultBundleObject: + *s = CommandEventArtifactTypeResultBundleObject + default: + *s = CommandEventArtifactType(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s CommandEventArtifactType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CommandEventArtifactType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CompleteAnalyticsArtifactMultipartUploadForbidden as json. +func (s *CompleteAnalyticsArtifactMultipartUploadForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CompleteAnalyticsArtifactsUploadsUnauthorized from json. -func (s *CompleteAnalyticsArtifactsUploadsUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes CompleteAnalyticsArtifactMultipartUploadForbidden from json. +func (s *CompleteAnalyticsArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteAnalyticsArtifactsUploadsUnauthorized to nil") + return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadForbidden to nil") } var unwrapped Error if err := func() error { @@ -2659,34 +2738,34 @@ func (s *CompleteAnalyticsArtifactsUploadsUnauthorized) Decode(d *jx.Decoder) er }(); err != nil { return errors.Wrap(err, "alias") } - *s = CompleteAnalyticsArtifactsUploadsUnauthorized(unwrapped) + *s = CompleteAnalyticsArtifactMultipartUploadForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteAnalyticsArtifactsUploadsUnauthorized) MarshalJSON() ([]byte, error) { +func (s *CompleteAnalyticsArtifactMultipartUploadForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteAnalyticsArtifactsUploadsUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CompleteAnalyticsArtifactMultipartUploadForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteCacheArtifactMultipartUploadForbidden as json. -func (s *CompleteCacheArtifactMultipartUploadForbidden) Encode(e *jx.Encoder) { +// Encode encodes CompleteAnalyticsArtifactMultipartUploadInternalServerError as json. +func (s *CompleteAnalyticsArtifactMultipartUploadInternalServerError) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CompleteCacheArtifactMultipartUploadForbidden from json. -func (s *CompleteCacheArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CompleteAnalyticsArtifactMultipartUploadInternalServerError from json. +func (s *CompleteAnalyticsArtifactMultipartUploadInternalServerError) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadForbidden to nil") + return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadInternalServerError to nil") } var unwrapped Error if err := func() error { @@ -2697,34 +2776,34 @@ func (s *CompleteCacheArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) er }(); err != nil { return errors.Wrap(err, "alias") } - *s = CompleteCacheArtifactMultipartUploadForbidden(unwrapped) + *s = CompleteAnalyticsArtifactMultipartUploadInternalServerError(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadForbidden) MarshalJSON() ([]byte, error) { +func (s *CompleteAnalyticsArtifactMultipartUploadInternalServerError) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteCacheArtifactMultipartUploadForbidden) UnmarshalJSON(data []byte) error { +func (s *CompleteAnalyticsArtifactMultipartUploadInternalServerError) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteCacheArtifactMultipartUploadNotFound as json. -func (s *CompleteCacheArtifactMultipartUploadNotFound) Encode(e *jx.Encoder) { +// Encode encodes CompleteAnalyticsArtifactMultipartUploadNotFound as json. +func (s *CompleteAnalyticsArtifactMultipartUploadNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CompleteCacheArtifactMultipartUploadNotFound from json. -func (s *CompleteCacheArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) error { +// Decode decodes CompleteAnalyticsArtifactMultipartUploadNotFound from json. +func (s *CompleteAnalyticsArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadNotFound to nil") + return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadNotFound to nil") } var unwrapped Error if err := func() error { @@ -2735,199 +2814,219 @@ func (s *CompleteCacheArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) err }(); err != nil { return errors.Wrap(err, "alias") } - *s = CompleteCacheArtifactMultipartUploadNotFound(unwrapped) + *s = CompleteAnalyticsArtifactMultipartUploadNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadNotFound) MarshalJSON() ([]byte, error) { +func (s *CompleteAnalyticsArtifactMultipartUploadNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteCacheArtifactMultipartUploadNotFound) UnmarshalJSON(data []byte) error { +func (s *CompleteAnalyticsArtifactMultipartUploadNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadOK) Encode(e *jx.Encoder) { +func (s *CompleteAnalyticsArtifactMultipartUploadReq) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *CompleteCacheArtifactMultipartUploadOK) encodeFields(e *jx.Encoder) { +func (s *CompleteAnalyticsArtifactMultipartUploadReq) encodeFields(e *jx.Encoder) { { - if s.Data != nil { - e.FieldStart("data") - s.Data.Encode(e) - } + e.FieldStart("command_event_artifact") + s.CommandEventArtifact.Encode(e) } { - if s.Status.Set { - e.FieldStart("status") - s.Status.Encode(e) - } + e.FieldStart("multipart_upload_parts") + s.MultipartUploadParts.Encode(e) } } -var jsonFieldsNameOfCompleteCacheArtifactMultipartUploadOK = [2]string{ - 0: "data", - 1: "status", +var jsonFieldsNameOfCompleteAnalyticsArtifactMultipartUploadReq = [2]string{ + 0: "command_event_artifact", + 1: "multipart_upload_parts", } -// Decode decodes CompleteCacheArtifactMultipartUploadOK from json. -func (s *CompleteCacheArtifactMultipartUploadOK) Decode(d *jx.Decoder) error { +// Decode decodes CompleteAnalyticsArtifactMultipartUploadReq from json. +func (s *CompleteAnalyticsArtifactMultipartUploadReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadOK to nil") + return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadReq to nil") } - s.setDefaults() + var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "data": + case "command_event_artifact": + requiredBitSet[0] |= 1 << 0 if err := func() error { - s.Data = nil - var elem CompleteCacheArtifactMultipartUploadOKData - if err := elem.Decode(d); err != nil { + if err := s.CommandEventArtifact.Decode(d); err != nil { return err } - s.Data = &elem return nil }(); err != nil { - return errors.Wrap(err, "decode field \"data\"") + return errors.Wrap(err, "decode field \"command_event_artifact\"") } - case "status": + case "multipart_upload_parts": + requiredBitSet[0] |= 1 << 1 if err := func() error { - s.Status.Reset() - if err := s.Status.Decode(d); err != nil { + if err := s.MultipartUploadParts.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"status\"") + return errors.Wrap(err, "decode field \"multipart_upload_parts\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CompleteCacheArtifactMultipartUploadOK") + return errors.Wrap(err, "decode CompleteAnalyticsArtifactMultipartUploadReq") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfCompleteAnalyticsArtifactMultipartUploadReq) { + name = jsonFieldsNameOfCompleteAnalyticsArtifactMultipartUploadReq[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadOK) MarshalJSON() ([]byte, error) { +func (s *CompleteAnalyticsArtifactMultipartUploadReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteCacheArtifactMultipartUploadOK) UnmarshalJSON(data []byte) error { +func (s *CompleteAnalyticsArtifactMultipartUploadReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadOKData) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} +// Encode encodes CompleteAnalyticsArtifactMultipartUploadUnauthorized as json. +func (s *CompleteAnalyticsArtifactMultipartUploadUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) -// encodeFields encodes fields. -func (s *CompleteCacheArtifactMultipartUploadOKData) encodeFields(e *jx.Encoder) { + unwrapped.Encode(e) } -var jsonFieldsNameOfCompleteCacheArtifactMultipartUploadOKData = [0]string{} - -// Decode decodes CompleteCacheArtifactMultipartUploadOKData from json. -func (s *CompleteCacheArtifactMultipartUploadOKData) Decode(d *jx.Decoder) error { +// Decode decodes CompleteAnalyticsArtifactMultipartUploadUnauthorized from json. +func (s *CompleteAnalyticsArtifactMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadOKData to nil") + return errors.New("invalid: unable to decode CompleteAnalyticsArtifactMultipartUploadUnauthorized to nil") } - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } - }); err != nil { - return errors.Wrap(err, "decode CompleteCacheArtifactMultipartUploadOKData") + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = CompleteAnalyticsArtifactMultipartUploadUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadOKData) MarshalJSON() ([]byte, error) { +func (s *CompleteAnalyticsArtifactMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteCacheArtifactMultipartUploadOKData) UnmarshalJSON(data []byte) error { +func (s *CompleteAnalyticsArtifactMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteCacheArtifactMultipartUploadOKStatus as json. -func (s CompleteCacheArtifactMultipartUploadOKStatus) Encode(e *jx.Encoder) { - e.Str(string(s)) +// Encode encodes CompleteAnalyticsArtifactsUploadsForbidden as json. +func (s *CompleteAnalyticsArtifactsUploadsForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes CompleteCacheArtifactMultipartUploadOKStatus from json. -func (s *CompleteCacheArtifactMultipartUploadOKStatus) Decode(d *jx.Decoder) error { +// Decode decodes CompleteAnalyticsArtifactsUploadsForbidden from json. +func (s *CompleteAnalyticsArtifactsUploadsForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadOKStatus to nil") - } - v, err := d.StrBytes() - if err != nil { - return err + return errors.New("invalid: unable to decode CompleteAnalyticsArtifactsUploadsForbidden to nil") } - // Try to use constant string. - switch CompleteCacheArtifactMultipartUploadOKStatus(v) { - case CompleteCacheArtifactMultipartUploadOKStatusSuccess: - *s = CompleteCacheArtifactMultipartUploadOKStatusSuccess - default: - *s = CompleteCacheArtifactMultipartUploadOKStatus(v) + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = CompleteAnalyticsArtifactsUploadsForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s CompleteCacheArtifactMultipartUploadOKStatus) MarshalJSON() ([]byte, error) { +func (s *CompleteAnalyticsArtifactsUploadsForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteCacheArtifactMultipartUploadOKStatus) UnmarshalJSON(data []byte) error { +func (s *CompleteAnalyticsArtifactsUploadsForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteCacheArtifactMultipartUploadPaymentRequired as json. -func (s *CompleteCacheArtifactMultipartUploadPaymentRequired) Encode(e *jx.Encoder) { +// Encode encodes CompleteAnalyticsArtifactsUploadsNotFound as json. +func (s *CompleteAnalyticsArtifactsUploadsNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CompleteCacheArtifactMultipartUploadPaymentRequired from json. -func (s *CompleteCacheArtifactMultipartUploadPaymentRequired) Decode(d *jx.Decoder) error { +// Decode decodes CompleteAnalyticsArtifactsUploadsNotFound from json. +func (s *CompleteAnalyticsArtifactsUploadsNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadPaymentRequired to nil") + return errors.New("invalid: unable to decode CompleteAnalyticsArtifactsUploadsNotFound to nil") } var unwrapped Error if err := func() error { @@ -2938,226 +3037,178 @@ func (s *CompleteCacheArtifactMultipartUploadPaymentRequired) Decode(d *jx.Decod }(); err != nil { return errors.Wrap(err, "alias") } - *s = CompleteCacheArtifactMultipartUploadPaymentRequired(unwrapped) + *s = CompleteAnalyticsArtifactsUploadsNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadPaymentRequired) MarshalJSON() ([]byte, error) { +func (s *CompleteAnalyticsArtifactsUploadsNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteCacheArtifactMultipartUploadPaymentRequired) UnmarshalJSON(data []byte) error { +func (s *CompleteAnalyticsArtifactsUploadsNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadReq) Encode(e *jx.Encoder) { +func (s *CompleteAnalyticsArtifactsUploadsReq) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *CompleteCacheArtifactMultipartUploadReq) encodeFields(e *jx.Encoder) { +func (s *CompleteAnalyticsArtifactsUploadsReq) encodeFields(e *jx.Encoder) { { - if s.Parts != nil { - e.FieldStart("parts") - e.ArrStart() - for _, elem := range s.Parts { - elem.Encode(e) - } - e.ArrEnd() + e.FieldStart("modules") + e.ArrStart() + for _, elem := range s.Modules { + elem.Encode(e) } + e.ArrEnd() } } -var jsonFieldsNameOfCompleteCacheArtifactMultipartUploadReq = [1]string{ - 0: "parts", +var jsonFieldsNameOfCompleteAnalyticsArtifactsUploadsReq = [1]string{ + 0: "modules", } -// Decode decodes CompleteCacheArtifactMultipartUploadReq from json. -func (s *CompleteCacheArtifactMultipartUploadReq) Decode(d *jx.Decoder) error { +// Decode decodes CompleteAnalyticsArtifactsUploadsReq from json. +func (s *CompleteAnalyticsArtifactsUploadsReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadReq to nil") + return errors.New("invalid: unable to decode CompleteAnalyticsArtifactsUploadsReq to nil") } + var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "parts": + case "modules": + requiredBitSet[0] |= 1 << 0 if err := func() error { - s.Parts = make([]CompleteCacheArtifactMultipartUploadReqPartsItem, 0) + s.Modules = make([]Module, 0) if err := d.Arr(func(d *jx.Decoder) error { - var elem CompleteCacheArtifactMultipartUploadReqPartsItem + var elem Module if err := elem.Decode(d); err != nil { return err } - s.Parts = append(s.Parts, elem) + s.Modules = append(s.Modules, elem) return nil }); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"parts\"") + return errors.Wrap(err, "decode field \"modules\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CompleteCacheArtifactMultipartUploadReq") + return errors.Wrap(err, "decode CompleteAnalyticsArtifactsUploadsReq") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfCompleteAnalyticsArtifactsUploadsReq) { + name = jsonFieldsNameOfCompleteAnalyticsArtifactsUploadsReq[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadReq) MarshalJSON() ([]byte, error) { +func (s *CompleteAnalyticsArtifactsUploadsReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteCacheArtifactMultipartUploadReq) UnmarshalJSON(data []byte) error { +func (s *CompleteAnalyticsArtifactsUploadsReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() +// Encode encodes CompleteAnalyticsArtifactsUploadsUnauthorized as json. +func (s *CompleteAnalyticsArtifactsUploadsUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// encodeFields encodes fields. -func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) encodeFields(e *jx.Encoder) { - { - if s.Etag.Set { - e.FieldStart("etag") - s.Etag.Encode(e) - } +// Decode decodes CompleteAnalyticsArtifactsUploadsUnauthorized from json. +func (s *CompleteAnalyticsArtifactsUploadsUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CompleteAnalyticsArtifactsUploadsUnauthorized to nil") } - { - if s.PartNumber.Set { - e.FieldStart("part_number") - s.PartNumber.Encode(e) + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } -} - -var jsonFieldsNameOfCompleteCacheArtifactMultipartUploadReqPartsItem = [2]string{ - 0: "etag", - 1: "part_number", -} - -// Decode decodes CompleteCacheArtifactMultipartUploadReqPartsItem from json. -func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadReqPartsItem to nil") - } - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "etag": - if err := func() error { - s.Etag.Reset() - if err := s.Etag.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"etag\"") - } - case "part_number": - if err := func() error { - s.PartNumber.Reset() - if err := s.PartNumber.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"part_number\"") - } - default: - return d.Skip() - } - return nil - }); err != nil { - return errors.Wrap(err, "decode CompleteCacheArtifactMultipartUploadReqPartsItem") - } - - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes CompleteCacheArtifactMultipartUploadUnauthorized as json. -func (s *CompleteCacheArtifactMultipartUploadUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) -} - -// Decode decodes CompleteCacheArtifactMultipartUploadUnauthorized from json. -func (s *CompleteCacheArtifactMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadUnauthorized to nil") - } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") - } - *s = CompleteCacheArtifactMultipartUploadUnauthorized(unwrapped) - return nil + *s = CompleteAnalyticsArtifactsUploadsUnauthorized(unwrapped) + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompleteCacheArtifactMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { +func (s *CompleteAnalyticsArtifactsUploadsUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompleteCacheArtifactMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CompleteAnalyticsArtifactsUploadsUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompletePreviewsMultipartUploadForbidden as json. -func (s *CompletePreviewsMultipartUploadForbidden) Encode(e *jx.Encoder) { +// Encode encodes CompleteCacheArtifactMultipartUploadForbidden as json. +func (s *CompleteCacheArtifactMultipartUploadForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CompletePreviewsMultipartUploadForbidden from json. -func (s *CompletePreviewsMultipartUploadForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CompleteCacheArtifactMultipartUploadForbidden from json. +func (s *CompleteCacheArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompletePreviewsMultipartUploadForbidden to nil") + return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadForbidden to nil") } var unwrapped Error if err := func() error { @@ -3168,34 +3219,34 @@ func (s *CompletePreviewsMultipartUploadForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CompletePreviewsMultipartUploadForbidden(unwrapped) + *s = CompleteCacheArtifactMultipartUploadForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompletePreviewsMultipartUploadForbidden) MarshalJSON() ([]byte, error) { +func (s *CompleteCacheArtifactMultipartUploadForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompletePreviewsMultipartUploadForbidden) UnmarshalJSON(data []byte) error { +func (s *CompleteCacheArtifactMultipartUploadForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompletePreviewsMultipartUploadNotFound as json. -func (s *CompletePreviewsMultipartUploadNotFound) Encode(e *jx.Encoder) { +// Encode encodes CompleteCacheArtifactMultipartUploadNotFound as json. +func (s *CompleteCacheArtifactMultipartUploadNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CompletePreviewsMultipartUploadNotFound from json. -func (s *CompletePreviewsMultipartUploadNotFound) Decode(d *jx.Decoder) error { +// Decode decodes CompleteCacheArtifactMultipartUploadNotFound from json. +func (s *CompleteCacheArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompletePreviewsMultipartUploadNotFound to nil") + return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadNotFound to nil") } var unwrapped Error if err := func() error { @@ -3206,279 +3257,199 @@ func (s *CompletePreviewsMultipartUploadNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CompletePreviewsMultipartUploadNotFound(unwrapped) + *s = CompleteCacheArtifactMultipartUploadNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompletePreviewsMultipartUploadNotFound) MarshalJSON() ([]byte, error) { +func (s *CompleteCacheArtifactMultipartUploadNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompletePreviewsMultipartUploadNotFound) UnmarshalJSON(data []byte) error { +func (s *CompleteCacheArtifactMultipartUploadNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *CompletePreviewsMultipartUploadOK) Encode(e *jx.Encoder) { +func (s *CompleteCacheArtifactMultipartUploadOK) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *CompletePreviewsMultipartUploadOK) encodeFields(e *jx.Encoder) { +func (s *CompleteCacheArtifactMultipartUploadOK) encodeFields(e *jx.Encoder) { { - e.FieldStart("url") - e.Str(s.URL) + if s.Data != nil { + e.FieldStart("data") + s.Data.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } } } -var jsonFieldsNameOfCompletePreviewsMultipartUploadOK = [1]string{ - 0: "url", +var jsonFieldsNameOfCompleteCacheArtifactMultipartUploadOK = [2]string{ + 0: "data", + 1: "status", } -// Decode decodes CompletePreviewsMultipartUploadOK from json. -func (s *CompletePreviewsMultipartUploadOK) Decode(d *jx.Decoder) error { +// Decode decodes CompleteCacheArtifactMultipartUploadOK from json. +func (s *CompleteCacheArtifactMultipartUploadOK) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompletePreviewsMultipartUploadOK to nil") + return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadOK to nil") } - var requiredBitSet [1]uint8 + s.setDefaults() if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "url": - requiredBitSet[0] |= 1 << 0 + case "data": if err := func() error { - v, err := d.Str() - s.URL = string(v) - if err != nil { + s.Data = nil + var elem CompleteCacheArtifactMultipartUploadOKData + if err := elem.Decode(d); err != nil { return err } + s.Data = &elem return nil }(); err != nil { - return errors.Wrap(err, "decode field \"url\"") + return errors.Wrap(err, "decode field \"data\"") + } + case "status": + if err := func() error { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CompletePreviewsMultipartUploadOK") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000001, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfCompletePreviewsMultipartUploadOK) { - name = jsonFieldsNameOfCompletePreviewsMultipartUploadOK[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + return errors.Wrap(err, "decode CompleteCacheArtifactMultipartUploadOK") } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompletePreviewsMultipartUploadOK) MarshalJSON() ([]byte, error) { +func (s *CompleteCacheArtifactMultipartUploadOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompletePreviewsMultipartUploadOK) UnmarshalJSON(data []byte) error { +func (s *CompleteCacheArtifactMultipartUploadOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *CompletePreviewsMultipartUploadReq) Encode(e *jx.Encoder) { +func (s *CompleteCacheArtifactMultipartUploadOKData) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *CompletePreviewsMultipartUploadReq) encodeFields(e *jx.Encoder) { - { - e.FieldStart("multipart_upload_parts") - s.MultipartUploadParts.Encode(e) - } - { - e.FieldStart("preview_id") - e.Str(s.PreviewID) - } +func (s *CompleteCacheArtifactMultipartUploadOKData) encodeFields(e *jx.Encoder) { } -var jsonFieldsNameOfCompletePreviewsMultipartUploadReq = [2]string{ - 0: "multipart_upload_parts", - 1: "preview_id", -} +var jsonFieldsNameOfCompleteCacheArtifactMultipartUploadOKData = [0]string{} -// Decode decodes CompletePreviewsMultipartUploadReq from json. -func (s *CompletePreviewsMultipartUploadReq) Decode(d *jx.Decoder) error { +// Decode decodes CompleteCacheArtifactMultipartUploadOKData from json. +func (s *CompleteCacheArtifactMultipartUploadOKData) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompletePreviewsMultipartUploadReq to nil") + return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadOKData to nil") } - var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "multipart_upload_parts": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - if err := s.MultipartUploadParts.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"multipart_upload_parts\"") - } - case "preview_id": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - v, err := d.Str() - s.PreviewID = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"preview_id\"") - } default: return d.Skip() } - return nil }); err != nil { - return errors.Wrap(err, "decode CompletePreviewsMultipartUploadReq") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000011, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfCompletePreviewsMultipartUploadReq) { - name = jsonFieldsNameOfCompletePreviewsMultipartUploadReq[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + return errors.Wrap(err, "decode CompleteCacheArtifactMultipartUploadOKData") } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompletePreviewsMultipartUploadReq) MarshalJSON() ([]byte, error) { +func (s *CompleteCacheArtifactMultipartUploadOKData) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompletePreviewsMultipartUploadReq) UnmarshalJSON(data []byte) error { +func (s *CompleteCacheArtifactMultipartUploadOKData) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompletePreviewsMultipartUploadUnauthorized as json. -func (s *CompletePreviewsMultipartUploadUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode encodes CompleteCacheArtifactMultipartUploadOKStatus as json. +func (s CompleteCacheArtifactMultipartUploadOKStatus) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes CompletePreviewsMultipartUploadUnauthorized from json. -func (s *CompletePreviewsMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes CompleteCacheArtifactMultipartUploadOKStatus from json. +func (s *CompleteCacheArtifactMultipartUploadOKStatus) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CompletePreviewsMultipartUploadUnauthorized to nil") + return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadOKStatus to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") + v, err := d.StrBytes() + if err != nil { + return err } - *s = CompletePreviewsMultipartUploadUnauthorized(unwrapped) + // Try to use constant string. + switch CompleteCacheArtifactMultipartUploadOKStatus(v) { + case CompleteCacheArtifactMultipartUploadOKStatusSuccess: + *s = CompleteCacheArtifactMultipartUploadOKStatusSuccess + default: + *s = CompleteCacheArtifactMultipartUploadOKStatus(v) + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CompletePreviewsMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { +func (s CompleteCacheArtifactMultipartUploadOKStatus) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CompletePreviewsMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CompleteCacheArtifactMultipartUploadOKStatus) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateCommandEventForbidden as json. -func (s *CreateCommandEventForbidden) Encode(e *jx.Encoder) { +// Encode encodes CompleteCacheArtifactMultipartUploadPaymentRequired as json. +func (s *CompleteCacheArtifactMultipartUploadPaymentRequired) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CreateCommandEventForbidden from json. -func (s *CreateCommandEventForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CompleteCacheArtifactMultipartUploadPaymentRequired from json. +func (s *CompleteCacheArtifactMultipartUploadPaymentRequired) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateCommandEventForbidden to nil") + return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadPaymentRequired to nil") } var unwrapped Error if err := func() error { @@ -3489,665 +3460,226 @@ func (s *CreateCommandEventForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CreateCommandEventForbidden(unwrapped) + *s = CompleteCacheArtifactMultipartUploadPaymentRequired(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateCommandEventForbidden) MarshalJSON() ([]byte, error) { +func (s *CompleteCacheArtifactMultipartUploadPaymentRequired) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateCommandEventForbidden) UnmarshalJSON(data []byte) error { +func (s *CompleteCacheArtifactMultipartUploadPaymentRequired) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *CreateCommandEventReq) Encode(e *jx.Encoder) { +func (s *CompleteCacheArtifactMultipartUploadReq) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *CreateCommandEventReq) encodeFields(e *jx.Encoder) { - { - e.FieldStart("client_id") - e.Str(s.ClientID) - } +func (s *CompleteCacheArtifactMultipartUploadReq) encodeFields(e *jx.Encoder) { { - if s.CommandArguments != nil { - e.FieldStart("command_arguments") + if s.Parts != nil { + e.FieldStart("parts") e.ArrStart() - for _, elem := range s.CommandArguments { - e.Str(elem) + for _, elem := range s.Parts { + elem.Encode(e) } e.ArrEnd() } } - { - e.FieldStart("duration") - e.Float64(s.Duration) - } - { - if s.ErrorMessage.Set { - e.FieldStart("error_message") - s.ErrorMessage.Encode(e) - } - } - { - if s.GitCommitSha.Set { - e.FieldStart("git_commit_sha") - s.GitCommitSha.Encode(e) - } - } - { - if s.GitRef.Set { - e.FieldStart("git_ref") - s.GitRef.Encode(e) - } - } - { - if s.GitRemoteURLOrigin.Set { - e.FieldStart("git_remote_url_origin") - s.GitRemoteURLOrigin.Encode(e) - } - } - { - e.FieldStart("is_ci") - e.Bool(s.IsCi) - } - { - e.FieldStart("macos_version") - e.Str(s.MacosVersion) - } - { - e.FieldStart("name") - e.Str(s.Name) - } - { - if s.Params.Set { - e.FieldStart("params") - s.Params.Encode(e) - } +} + +var jsonFieldsNameOfCompleteCacheArtifactMultipartUploadReq = [1]string{ + 0: "parts", +} + +// Decode decodes CompleteCacheArtifactMultipartUploadReq from json. +func (s *CompleteCacheArtifactMultipartUploadReq) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadReq to nil") } - { - if s.PreviewID.Set { - e.FieldStart("preview_id") - s.PreviewID.Encode(e) + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "parts": + if err := func() error { + s.Parts = make([]CompleteCacheArtifactMultipartUploadReqPartsItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem CompleteCacheArtifactMultipartUploadReqPartsItem + if err := elem.Decode(d); err != nil { + return err + } + s.Parts = append(s.Parts, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"parts\"") + } + default: + return d.Skip() } + return nil + }); err != nil { + return errors.Wrap(err, "decode CompleteCacheArtifactMultipartUploadReq") } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CompleteCacheArtifactMultipartUploadReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CompleteCacheArtifactMultipartUploadReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) encodeFields(e *jx.Encoder) { { - if s.Status.Set { - e.FieldStart("status") - s.Status.Encode(e) + if s.Etag.Set { + e.FieldStart("etag") + s.Etag.Encode(e) } } { - if s.Subcommand.Set { - e.FieldStart("subcommand") - s.Subcommand.Encode(e) + if s.PartNumber.Set { + e.FieldStart("part_number") + s.PartNumber.Encode(e) } } - { - e.FieldStart("swift_version") - e.Str(s.SwiftVersion) - } - { - e.FieldStart("tuist_version") - e.Str(s.TuistVersion) - } } -var jsonFieldsNameOfCreateCommandEventReq = [16]string{ - 0: "client_id", - 1: "command_arguments", - 2: "duration", - 3: "error_message", - 4: "git_commit_sha", - 5: "git_ref", - 6: "git_remote_url_origin", - 7: "is_ci", - 8: "macos_version", - 9: "name", - 10: "params", - 11: "preview_id", - 12: "status", - 13: "subcommand", - 14: "swift_version", - 15: "tuist_version", +var jsonFieldsNameOfCompleteCacheArtifactMultipartUploadReqPartsItem = [2]string{ + 0: "etag", + 1: "part_number", } -// Decode decodes CreateCommandEventReq from json. -func (s *CreateCommandEventReq) Decode(d *jx.Decoder) error { +// Decode decodes CompleteCacheArtifactMultipartUploadReqPartsItem from json. +func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateCommandEventReq to nil") + return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadReqPartsItem to nil") } - var requiredBitSet [2]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "client_id": - requiredBitSet[0] |= 1 << 0 + case "etag": if err := func() error { - v, err := d.Str() - s.ClientID = string(v) - if err != nil { + s.Etag.Reset() + if err := s.Etag.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"client_id\"") + return errors.Wrap(err, "decode field \"etag\"") } - case "command_arguments": + case "part_number": if err := func() error { - s.CommandArguments = make([]string, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem string - v, err := d.Str() - elem = string(v) - if err != nil { - return err - } - s.CommandArguments = append(s.CommandArguments, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"command_arguments\"") - } - case "duration": - requiredBitSet[0] |= 1 << 2 - if err := func() error { - v, err := d.Float64() - s.Duration = float64(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"duration\"") - } - case "error_message": - if err := func() error { - s.ErrorMessage.Reset() - if err := s.ErrorMessage.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"error_message\"") - } - case "git_commit_sha": - if err := func() error { - s.GitCommitSha.Reset() - if err := s.GitCommitSha.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"git_commit_sha\"") - } - case "git_ref": - if err := func() error { - s.GitRef.Reset() - if err := s.GitRef.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"git_ref\"") - } - case "git_remote_url_origin": - if err := func() error { - s.GitRemoteURLOrigin.Reset() - if err := s.GitRemoteURLOrigin.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"git_remote_url_origin\"") - } - case "is_ci": - requiredBitSet[0] |= 1 << 7 - if err := func() error { - v, err := d.Bool() - s.IsCi = bool(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"is_ci\"") - } - case "macos_version": - requiredBitSet[1] |= 1 << 0 - if err := func() error { - v, err := d.Str() - s.MacosVersion = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"macos_version\"") - } - case "name": - requiredBitSet[1] |= 1 << 1 - if err := func() error { - v, err := d.Str() - s.Name = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"name\"") - } - case "params": - if err := func() error { - s.Params.Reset() - if err := s.Params.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"params\"") - } - case "preview_id": - if err := func() error { - s.PreviewID.Reset() - if err := s.PreviewID.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"preview_id\"") - } - case "status": - if err := func() error { - s.Status.Reset() - if err := s.Status.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"status\"") - } - case "subcommand": - if err := func() error { - s.Subcommand.Reset() - if err := s.Subcommand.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"subcommand\"") - } - case "swift_version": - requiredBitSet[1] |= 1 << 6 - if err := func() error { - v, err := d.Str() - s.SwiftVersion = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"swift_version\"") - } - case "tuist_version": - requiredBitSet[1] |= 1 << 7 - if err := func() error { - v, err := d.Str() - s.TuistVersion = string(v) - if err != nil { + s.PartNumber.Reset() + if err := s.PartNumber.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"tuist_version\"") + return errors.Wrap(err, "decode field \"part_number\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CreateCommandEventReq") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [2]uint8{ - 0b10000101, - 0b11000011, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfCreateCommandEventReq) { - name = jsonFieldsNameOfCreateCommandEventReq[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + return errors.Wrap(err, "decode CompleteCacheArtifactMultipartUploadReqPartsItem") } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateCommandEventReq) MarshalJSON() ([]byte, error) { +func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateCommandEventReq) UnmarshalJSON(data []byte) error { +func (s *CompleteCacheArtifactMultipartUploadReqPartsItem) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *CreateCommandEventReqParams) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() +// Encode encodes CompleteCacheArtifactMultipartUploadUnauthorized as json. +func (s *CompleteCacheArtifactMultipartUploadUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// encodeFields encodes fields. -func (s *CreateCommandEventReqParams) encodeFields(e *jx.Encoder) { - { - if s.CacheableTargets != nil { - e.FieldStart("cacheable_targets") - e.ArrStart() - for _, elem := range s.CacheableTargets { - e.Str(elem) - } - e.ArrEnd() - } - } - { - if s.LocalCacheTargetHits != nil { - e.FieldStart("local_cache_target_hits") - e.ArrStart() - for _, elem := range s.LocalCacheTargetHits { - e.Str(elem) - } - e.ArrEnd() - } - } - { - if s.LocalTestTargetHits != nil { - e.FieldStart("local_test_target_hits") - e.ArrStart() - for _, elem := range s.LocalTestTargetHits { - e.Str(elem) - } - e.ArrEnd() - } +// Decode decodes CompleteCacheArtifactMultipartUploadUnauthorized from json. +func (s *CompleteCacheArtifactMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CompleteCacheArtifactMultipartUploadUnauthorized to nil") } - { - if s.RemoteCacheTargetHits != nil { - e.FieldStart("remote_cache_target_hits") - e.ArrStart() - for _, elem := range s.RemoteCacheTargetHits { - e.Str(elem) - } - e.ArrEnd() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } - { - if s.RemoteTestTargetHits != nil { - e.FieldStart("remote_test_target_hits") - e.ArrStart() - for _, elem := range s.RemoteTestTargetHits { - e.Str(elem) - } - e.ArrEnd() - } - } - { - if s.TestTargets != nil { - e.FieldStart("test_targets") - e.ArrStart() - for _, elem := range s.TestTargets { - e.Str(elem) - } - e.ArrEnd() - } - } -} - -var jsonFieldsNameOfCreateCommandEventReqParams = [6]string{ - 0: "cacheable_targets", - 1: "local_cache_target_hits", - 2: "local_test_target_hits", - 3: "remote_cache_target_hits", - 4: "remote_test_target_hits", - 5: "test_targets", -} - -// Decode decodes CreateCommandEventReqParams from json. -func (s *CreateCommandEventReqParams) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CreateCommandEventReqParams to nil") - } - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "cacheable_targets": - if err := func() error { - s.CacheableTargets = make([]string, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem string - v, err := d.Str() - elem = string(v) - if err != nil { - return err - } - s.CacheableTargets = append(s.CacheableTargets, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"cacheable_targets\"") - } - case "local_cache_target_hits": - if err := func() error { - s.LocalCacheTargetHits = make([]string, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem string - v, err := d.Str() - elem = string(v) - if err != nil { - return err - } - s.LocalCacheTargetHits = append(s.LocalCacheTargetHits, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"local_cache_target_hits\"") - } - case "local_test_target_hits": - if err := func() error { - s.LocalTestTargetHits = make([]string, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem string - v, err := d.Str() - elem = string(v) - if err != nil { - return err - } - s.LocalTestTargetHits = append(s.LocalTestTargetHits, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"local_test_target_hits\"") - } - case "remote_cache_target_hits": - if err := func() error { - s.RemoteCacheTargetHits = make([]string, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem string - v, err := d.Str() - elem = string(v) - if err != nil { - return err - } - s.RemoteCacheTargetHits = append(s.RemoteCacheTargetHits, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"remote_cache_target_hits\"") - } - case "remote_test_target_hits": - if err := func() error { - s.RemoteTestTargetHits = make([]string, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem string - v, err := d.Str() - elem = string(v) - if err != nil { - return err - } - s.RemoteTestTargetHits = append(s.RemoteTestTargetHits, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"remote_test_target_hits\"") - } - case "test_targets": - if err := func() error { - s.TestTargets = make([]string, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem string - v, err := d.Str() - elem = string(v) - if err != nil { - return err - } - s.TestTargets = append(s.TestTargets, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"test_targets\"") - } - default: - return d.Skip() - } - return nil - }); err != nil { - return errors.Wrap(err, "decode CreateCommandEventReqParams") - } - - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CreateCommandEventReqParams) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateCommandEventReqParams) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes CreateCommandEventReqStatus as json. -func (s CreateCommandEventReqStatus) Encode(e *jx.Encoder) { - e.Str(string(s)) -} - -// Decode decodes CreateCommandEventReqStatus from json. -func (s *CreateCommandEventReqStatus) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CreateCommandEventReqStatus to nil") - } - v, err := d.StrBytes() - if err != nil { - return err - } - // Try to use constant string. - switch CreateCommandEventReqStatus(v) { - case CreateCommandEventReqStatusSuccess: - *s = CreateCommandEventReqStatusSuccess - case CreateCommandEventReqStatusFailure: - *s = CreateCommandEventReqStatusFailure - default: - *s = CreateCommandEventReqStatus(v) - } - + *s = CompleteCacheArtifactMultipartUploadUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s CreateCommandEventReqStatus) MarshalJSON() ([]byte, error) { +func (s *CompleteCacheArtifactMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateCommandEventReqStatus) UnmarshalJSON(data []byte) error { +func (s *CompleteCacheArtifactMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateCommandEventUnauthorized as json. -func (s *CreateCommandEventUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes CompletePreviewsMultipartUploadForbidden as json. +func (s *CompletePreviewsMultipartUploadForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CreateCommandEventUnauthorized from json. -func (s *CreateCommandEventUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes CompletePreviewsMultipartUploadForbidden from json. +func (s *CompletePreviewsMultipartUploadForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateCommandEventUnauthorized to nil") + return errors.New("invalid: unable to decode CompletePreviewsMultipartUploadForbidden to nil") } var unwrapped Error if err := func() error { @@ -4158,34 +3690,34 @@ func (s *CreateCommandEventUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CreateCommandEventUnauthorized(unwrapped) + *s = CompletePreviewsMultipartUploadForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateCommandEventUnauthorized) MarshalJSON() ([]byte, error) { +func (s *CompletePreviewsMultipartUploadForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateCommandEventUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CompletePreviewsMultipartUploadForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateInvitationBadRequest as json. -func (s *CreateInvitationBadRequest) Encode(e *jx.Encoder) { +// Encode encodes CompletePreviewsMultipartUploadNotFound as json. +func (s *CompletePreviewsMultipartUploadNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CreateInvitationBadRequest from json. -func (s *CreateInvitationBadRequest) Decode(d *jx.Decoder) error { +// Decode decodes CompletePreviewsMultipartUploadNotFound from json. +func (s *CompletePreviewsMultipartUploadNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateInvitationBadRequest to nil") + return errors.New("invalid: unable to decode CompletePreviewsMultipartUploadNotFound to nil") } var unwrapped Error if err := func() error { @@ -4196,34 +3728,145 @@ func (s *CreateInvitationBadRequest) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CreateInvitationBadRequest(unwrapped) + *s = CompletePreviewsMultipartUploadNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateInvitationBadRequest) MarshalJSON() ([]byte, error) { +func (s *CompletePreviewsMultipartUploadNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateInvitationBadRequest) UnmarshalJSON(data []byte) error { +func (s *CompletePreviewsMultipartUploadNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateInvitationForbidden as json. -func (s *CreateInvitationForbidden) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode implements json.Marshaler. +func (s *CompletePreviewsMultipartUploadReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes CreateInvitationForbidden from json. -func (s *CreateInvitationForbidden) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CreateInvitationForbidden to nil") +// encodeFields encodes fields. +func (s *CompletePreviewsMultipartUploadReq) encodeFields(e *jx.Encoder) { + { + e.FieldStart("multipart_upload_parts") + s.MultipartUploadParts.Encode(e) + } + { + e.FieldStart("preview_id") + e.Str(s.PreviewID) + } +} + +var jsonFieldsNameOfCompletePreviewsMultipartUploadReq = [2]string{ + 0: "multipart_upload_parts", + 1: "preview_id", +} + +// Decode decodes CompletePreviewsMultipartUploadReq from json. +func (s *CompletePreviewsMultipartUploadReq) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CompletePreviewsMultipartUploadReq to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "multipart_upload_parts": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.MultipartUploadParts.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"multipart_upload_parts\"") + } + case "preview_id": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.PreviewID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"preview_id\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode CompletePreviewsMultipartUploadReq") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfCompletePreviewsMultipartUploadReq) { + name = jsonFieldsNameOfCompletePreviewsMultipartUploadReq[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CompletePreviewsMultipartUploadReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CompletePreviewsMultipartUploadReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CompletePreviewsMultipartUploadUnauthorized as json. +func (s *CompletePreviewsMultipartUploadUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes CompletePreviewsMultipartUploadUnauthorized from json. +func (s *CompletePreviewsMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CompletePreviewsMultipartUploadUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -4234,34 +3877,34 @@ func (s *CreateInvitationForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CreateInvitationForbidden(unwrapped) + *s = CompletePreviewsMultipartUploadUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateInvitationForbidden) MarshalJSON() ([]byte, error) { +func (s *CompletePreviewsMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateInvitationForbidden) UnmarshalJSON(data []byte) error { +func (s *CompletePreviewsMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateInvitationNotFound as json. -func (s *CreateInvitationNotFound) Encode(e *jx.Encoder) { +// Encode encodes CreateAccountTokenForbidden as json. +func (s *CreateAccountTokenForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CreateInvitationNotFound from json. -func (s *CreateInvitationNotFound) Decode(d *jx.Decoder) error { +// Decode decodes CreateAccountTokenForbidden from json. +func (s *CreateAccountTokenForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateInvitationNotFound to nil") + return errors.New("invalid: unable to decode CreateAccountTokenForbidden to nil") } var unwrapped Error if err := func() error { @@ -4272,69 +3915,107 @@ func (s *CreateInvitationNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CreateInvitationNotFound(unwrapped) + *s = CreateAccountTokenForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateInvitationNotFound) MarshalJSON() ([]byte, error) { +func (s *CreateAccountTokenForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateInvitationNotFound) UnmarshalJSON(data []byte) error { +func (s *CreateAccountTokenForbidden) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateAccountTokenNotFound as json. +func (s *CreateAccountTokenNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes CreateAccountTokenNotFound from json. +func (s *CreateAccountTokenNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateAccountTokenNotFound to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = CreateAccountTokenNotFound(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CreateAccountTokenNotFound) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CreateAccountTokenNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *CreateInvitationReq) Encode(e *jx.Encoder) { +func (s *CreateAccountTokenOK) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *CreateInvitationReq) encodeFields(e *jx.Encoder) { +func (s *CreateAccountTokenOK) encodeFields(e *jx.Encoder) { { - e.FieldStart("invitee_email") - e.Str(s.InviteeEmail) + e.FieldStart("token") + e.Str(s.Token) } } -var jsonFieldsNameOfCreateInvitationReq = [1]string{ - 0: "invitee_email", +var jsonFieldsNameOfCreateAccountTokenOK = [1]string{ + 0: "token", } -// Decode decodes CreateInvitationReq from json. -func (s *CreateInvitationReq) Decode(d *jx.Decoder) error { +// Decode decodes CreateAccountTokenOK from json. +func (s *CreateAccountTokenOK) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateInvitationReq to nil") + return errors.New("invalid: unable to decode CreateAccountTokenOK to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "invitee_email": + case "token": requiredBitSet[0] |= 1 << 0 if err := func() error { v, err := d.Str() - s.InviteeEmail = string(v) + s.Token = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"invitee_email\"") + return errors.Wrap(err, "decode field \"token\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CreateInvitationReq") + return errors.Wrap(err, "decode CreateAccountTokenOK") } // Validate required fields. var failures []validate.FieldError @@ -4351,8 +4032,8 @@ func (s *CreateInvitationReq) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfCreateInvitationReq) { - name = jsonFieldsNameOfCreateInvitationReq[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfCreateAccountTokenOK) { + name = jsonFieldsNameOfCreateAccountTokenOK[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -4373,102 +4054,74 @@ func (s *CreateInvitationReq) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateInvitationReq) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateInvitationReq) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes CreateInvitationUnauthorized as json. -func (s *CreateInvitationUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) -} - -// Decode decodes CreateInvitationUnauthorized from json. -func (s *CreateInvitationUnauthorized) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CreateInvitationUnauthorized to nil") - } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") - } - *s = CreateInvitationUnauthorized(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CreateInvitationUnauthorized) MarshalJSON() ([]byte, error) { +func (s *CreateAccountTokenOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateInvitationUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CreateAccountTokenOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *CreateOrganizationReq) Encode(e *jx.Encoder) { +func (s *CreateAccountTokenReq) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *CreateOrganizationReq) encodeFields(e *jx.Encoder) { +func (s *CreateAccountTokenReq) encodeFields(e *jx.Encoder) { { - e.FieldStart("name") - e.Str(s.Name) + e.FieldStart("scopes") + e.ArrStart() + for _, elem := range s.Scopes { + elem.Encode(e) + } + e.ArrEnd() } } -var jsonFieldsNameOfCreateOrganizationReq = [1]string{ - 0: "name", +var jsonFieldsNameOfCreateAccountTokenReq = [1]string{ + 0: "scopes", } -// Decode decodes CreateOrganizationReq from json. -func (s *CreateOrganizationReq) Decode(d *jx.Decoder) error { +// Decode decodes CreateAccountTokenReq from json. +func (s *CreateAccountTokenReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateOrganizationReq to nil") + return errors.New("invalid: unable to decode CreateAccountTokenReq to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "name": + case "scopes": requiredBitSet[0] |= 1 << 0 if err := func() error { - v, err := d.Str() - s.Name = string(v) - if err != nil { + s.Scopes = make([]CreateAccountTokenReqScopesItem, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem CreateAccountTokenReqScopesItem + if err := elem.Decode(d); err != nil { + return err + } + s.Scopes = append(s.Scopes, elem) + return nil + }); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"name\"") + return errors.Wrap(err, "decode field \"scopes\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CreateOrganizationReq") + return errors.Wrap(err, "decode CreateAccountTokenReq") } // Validate required fields. var failures []validate.FieldError @@ -4485,8 +4138,8 @@ func (s *CreateOrganizationReq) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfCreateOrganizationReq) { - name = jsonFieldsNameOfCreateOrganizationReq[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfCreateAccountTokenReq) { + name = jsonFieldsNameOfCreateAccountTokenReq[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -4507,67 +4160,105 @@ func (s *CreateOrganizationReq) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateOrganizationReq) MarshalJSON() ([]byte, error) { +func (s *CreateAccountTokenReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateOrganizationReq) UnmarshalJSON(data []byte) error { +func (s *CreateAccountTokenReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateProjectBadRequest as json. -func (s *CreateProjectBadRequest) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode encodes CreateAccountTokenReqScopesItem as json. +func (s CreateAccountTokenReqScopesItem) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes CreateProjectBadRequest from json. -func (s *CreateProjectBadRequest) Decode(d *jx.Decoder) error { +// Decode decodes CreateAccountTokenReqScopesItem from json. +func (s *CreateAccountTokenReqScopesItem) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateProjectBadRequest to nil") + return errors.New("invalid: unable to decode CreateAccountTokenReqScopesItem to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch CreateAccountTokenReqScopesItem(v) { + case CreateAccountTokenReqScopesItemAccountRegistryRead: + *s = CreateAccountTokenReqScopesItemAccountRegistryRead + default: + *s = CreateAccountTokenReqScopesItem(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s CreateAccountTokenReqScopesItem) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *CreateAccountTokenReqScopesItem) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateAccountTokenUnauthorized as json. +func (s *CreateAccountTokenUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes CreateAccountTokenUnauthorized from json. +func (s *CreateAccountTokenUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateAccountTokenUnauthorized to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { return err } return nil }(); err != nil { return errors.Wrap(err, "alias") } - *s = CreateProjectBadRequest(unwrapped) + *s = CreateAccountTokenUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateProjectBadRequest) MarshalJSON() ([]byte, error) { +func (s *CreateAccountTokenUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateProjectBadRequest) UnmarshalJSON(data []byte) error { +func (s *CreateAccountTokenUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateProjectForbidden as json. -func (s *CreateProjectForbidden) Encode(e *jx.Encoder) { +// Encode encodes CreateCommandEventForbidden as json. +func (s *CreateCommandEventForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes CreateProjectForbidden from json. -func (s *CreateProjectForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CreateCommandEventForbidden from json. +func (s *CreateCommandEventForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateProjectForbidden to nil") + return errors.New("invalid: unable to decode CreateCommandEventForbidden to nil") } var unwrapped Error if err := func() error { @@ -4578,246 +4269,360 @@ func (s *CreateProjectForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = CreateProjectForbidden(unwrapped) + *s = CreateCommandEventForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateProjectForbidden) MarshalJSON() ([]byte, error) { +func (s *CreateCommandEventForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateProjectForbidden) UnmarshalJSON(data []byte) error { +func (s *CreateCommandEventForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *CreateProjectReq) Encode(e *jx.Encoder) { +func (s *CreateCommandEventReq) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *CreateProjectReq) encodeFields(e *jx.Encoder) { +func (s *CreateCommandEventReq) encodeFields(e *jx.Encoder) { { - if s.FullHandle.Set { - e.FieldStart("full_handle") - s.FullHandle.Encode(e) + e.FieldStart("client_id") + e.Str(s.ClientID) + } + { + if s.CommandArguments != nil { + e.FieldStart("command_arguments") + e.ArrStart() + for _, elem := range s.CommandArguments { + e.Str(elem) + } + e.ArrEnd() } } { - if s.Name.Set { - e.FieldStart("name") - s.Name.Encode(e) + e.FieldStart("duration") + e.Float64(s.Duration) + } + { + if s.ErrorMessage.Set { + e.FieldStart("error_message") + s.ErrorMessage.Encode(e) } } { - if s.Organization.Set { - e.FieldStart("organization") - s.Organization.Encode(e) + if s.GitBranch.Set { + e.FieldStart("git_branch") + s.GitBranch.Encode(e) + } + } + { + if s.GitCommitSha.Set { + e.FieldStart("git_commit_sha") + s.GitCommitSha.Encode(e) + } + } + { + if s.GitRef.Set { + e.FieldStart("git_ref") + s.GitRef.Encode(e) + } + } + { + if s.GitRemoteURLOrigin.Set { + e.FieldStart("git_remote_url_origin") + s.GitRemoteURLOrigin.Encode(e) + } + } + { + e.FieldStart("is_ci") + e.Bool(s.IsCi) + } + { + e.FieldStart("macos_version") + e.Str(s.MacosVersion) + } + { + e.FieldStart("name") + e.Str(s.Name) + } + { + if s.Params.Set { + e.FieldStart("params") + s.Params.Encode(e) + } + } + { + if s.PreviewID.Set { + e.FieldStart("preview_id") + s.PreviewID.Encode(e) + } + } + { + if s.Status.Set { + e.FieldStart("status") + s.Status.Encode(e) + } + } + { + if s.Subcommand.Set { + e.FieldStart("subcommand") + s.Subcommand.Encode(e) } } + { + e.FieldStart("swift_version") + e.Str(s.SwiftVersion) + } + { + e.FieldStart("tuist_version") + e.Str(s.TuistVersion) + } } -var jsonFieldsNameOfCreateProjectReq = [3]string{ - 0: "full_handle", - 1: "name", - 2: "organization", +var jsonFieldsNameOfCreateCommandEventReq = [17]string{ + 0: "client_id", + 1: "command_arguments", + 2: "duration", + 3: "error_message", + 4: "git_branch", + 5: "git_commit_sha", + 6: "git_ref", + 7: "git_remote_url_origin", + 8: "is_ci", + 9: "macos_version", + 10: "name", + 11: "params", + 12: "preview_id", + 13: "status", + 14: "subcommand", + 15: "swift_version", + 16: "tuist_version", } -// Decode decodes CreateProjectReq from json. -func (s *CreateProjectReq) Decode(d *jx.Decoder) error { +// Decode decodes CreateCommandEventReq from json. +func (s *CreateCommandEventReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateProjectReq to nil") + return errors.New("invalid: unable to decode CreateCommandEventReq to nil") } + var requiredBitSet [3]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "full_handle": + case "client_id": + requiredBitSet[0] |= 1 << 0 if err := func() error { - s.FullHandle.Reset() - if err := s.FullHandle.Decode(d); err != nil { + v, err := d.Str() + s.ClientID = string(v) + if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"full_handle\"") + return errors.Wrap(err, "decode field \"client_id\"") } - case "name": + case "command_arguments": if err := func() error { - s.Name.Reset() - if err := s.Name.Decode(d); err != nil { + s.CommandArguments = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.CommandArguments = append(s.CommandArguments, elem) + return nil + }); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"name\"") + return errors.Wrap(err, "decode field \"command_arguments\"") } - case "organization": + case "duration": + requiredBitSet[0] |= 1 << 2 if err := func() error { - s.Organization.Reset() - if err := s.Organization.Decode(d); err != nil { + v, err := d.Float64() + s.Duration = float64(v) + if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"organization\"") + return errors.Wrap(err, "decode field \"duration\"") } - default: - return d.Skip() - } - return nil - }); err != nil { - return errors.Wrap(err, "decode CreateProjectReq") - } - - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CreateProjectReq) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateProjectReq) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes CreateProjectTokenForbidden as json. -func (s *CreateProjectTokenForbidden) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) -} - -// Decode decodes CreateProjectTokenForbidden from json. -func (s *CreateProjectTokenForbidden) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CreateProjectTokenForbidden to nil") - } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") - } - *s = CreateProjectTokenForbidden(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CreateProjectTokenForbidden) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateProjectTokenForbidden) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes CreateProjectTokenNotFound as json. -func (s *CreateProjectTokenNotFound) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) -} - -// Decode decodes CreateProjectTokenNotFound from json. -func (s *CreateProjectTokenNotFound) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CreateProjectTokenNotFound to nil") - } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") - } - *s = CreateProjectTokenNotFound(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CreateProjectTokenNotFound) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateProjectTokenNotFound) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode implements json.Marshaler. -func (s *CreateProjectTokenOK) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *CreateProjectTokenOK) encodeFields(e *jx.Encoder) { - { - e.FieldStart("token") - e.Str(s.Token) - } -} - -var jsonFieldsNameOfCreateProjectTokenOK = [1]string{ - 0: "token", -} - -// Decode decodes CreateProjectTokenOK from json. -func (s *CreateProjectTokenOK) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CreateProjectTokenOK to nil") - } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "token": - requiredBitSet[0] |= 1 << 0 + case "error_message": + if err := func() error { + s.ErrorMessage.Reset() + if err := s.ErrorMessage.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"error_message\"") + } + case "git_branch": + if err := func() error { + s.GitBranch.Reset() + if err := s.GitBranch.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"git_branch\"") + } + case "git_commit_sha": + if err := func() error { + s.GitCommitSha.Reset() + if err := s.GitCommitSha.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"git_commit_sha\"") + } + case "git_ref": + if err := func() error { + s.GitRef.Reset() + if err := s.GitRef.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"git_ref\"") + } + case "git_remote_url_origin": + if err := func() error { + s.GitRemoteURLOrigin.Reset() + if err := s.GitRemoteURLOrigin.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"git_remote_url_origin\"") + } + case "is_ci": + requiredBitSet[1] |= 1 << 0 + if err := func() error { + v, err := d.Bool() + s.IsCi = bool(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"is_ci\"") + } + case "macos_version": + requiredBitSet[1] |= 1 << 1 if err := func() error { v, err := d.Str() - s.Token = string(v) + s.MacosVersion = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"token\"") + return errors.Wrap(err, "decode field \"macos_version\"") + } + case "name": + requiredBitSet[1] |= 1 << 2 + if err := func() error { + v, err := d.Str() + s.Name = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + case "params": + if err := func() error { + s.Params.Reset() + if err := s.Params.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"params\"") + } + case "preview_id": + if err := func() error { + s.PreviewID.Reset() + if err := s.PreviewID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"preview_id\"") + } + case "status": + if err := func() error { + s.Status.Reset() + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + case "subcommand": + if err := func() error { + s.Subcommand.Reset() + if err := s.Subcommand.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"subcommand\"") + } + case "swift_version": + requiredBitSet[1] |= 1 << 7 + if err := func() error { + v, err := d.Str() + s.SwiftVersion = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"swift_version\"") + } + case "tuist_version": + requiredBitSet[2] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.TuistVersion = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tuist_version\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode CreateProjectTokenOK") + return errors.Wrap(err, "decode CreateCommandEventReq") } // Validate required fields. var failures []validate.FieldError - for i, mask := range [1]uint8{ + for i, mask := range [3]uint8{ + 0b00000101, + 0b10000111, 0b00000001, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { @@ -4830,8 +4635,8 @@ func (s *CreateProjectTokenOK) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfCreateProjectTokenOK) { - name = jsonFieldsNameOfCreateProjectTokenOK[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfCreateCommandEventReq) { + name = jsonFieldsNameOfCreateCommandEventReq[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -4852,105 +4657,295 @@ func (s *CreateProjectTokenOK) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateProjectTokenOK) MarshalJSON() ([]byte, error) { +func (s *CreateCommandEventReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateProjectTokenOK) UnmarshalJSON(data []byte) error { +func (s *CreateCommandEventReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateProjectTokenUnauthorized as json. -func (s *CreateProjectTokenUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode implements json.Marshaler. +func (s *CreateCommandEventReqParams) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes CreateProjectTokenUnauthorized from json. -func (s *CreateProjectTokenUnauthorized) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode CreateProjectTokenUnauthorized to nil") - } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err +// encodeFields encodes fields. +func (s *CreateCommandEventReqParams) encodeFields(e *jx.Encoder) { + { + if s.CacheableTargets != nil { + e.FieldStart("cacheable_targets") + e.ArrStart() + for _, elem := range s.CacheableTargets { + e.Str(elem) + } + e.ArrEnd() } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") } - *s = CreateProjectTokenUnauthorized(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *CreateProjectTokenUnauthorized) MarshalJSON() ([]byte, error) { + { + if s.LocalCacheTargetHits != nil { + e.FieldStart("local_cache_target_hits") + e.ArrStart() + for _, elem := range s.LocalCacheTargetHits { + e.Str(elem) + } + e.ArrEnd() + } + } + { + if s.LocalTestTargetHits != nil { + e.FieldStart("local_test_target_hits") + e.ArrStart() + for _, elem := range s.LocalTestTargetHits { + e.Str(elem) + } + e.ArrEnd() + } + } + { + if s.RemoteCacheTargetHits != nil { + e.FieldStart("remote_cache_target_hits") + e.ArrStart() + for _, elem := range s.RemoteCacheTargetHits { + e.Str(elem) + } + e.ArrEnd() + } + } + { + if s.RemoteTestTargetHits != nil { + e.FieldStart("remote_test_target_hits") + e.ArrStart() + for _, elem := range s.RemoteTestTargetHits { + e.Str(elem) + } + e.ArrEnd() + } + } + { + if s.TestTargets != nil { + e.FieldStart("test_targets") + e.ArrStart() + for _, elem := range s.TestTargets { + e.Str(elem) + } + e.ArrEnd() + } + } +} + +var jsonFieldsNameOfCreateCommandEventReqParams = [6]string{ + 0: "cacheable_targets", + 1: "local_cache_target_hits", + 2: "local_test_target_hits", + 3: "remote_cache_target_hits", + 4: "remote_test_target_hits", + 5: "test_targets", +} + +// Decode decodes CreateCommandEventReqParams from json. +func (s *CreateCommandEventReqParams) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode CreateCommandEventReqParams to nil") + } + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "cacheable_targets": + if err := func() error { + s.CacheableTargets = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.CacheableTargets = append(s.CacheableTargets, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"cacheable_targets\"") + } + case "local_cache_target_hits": + if err := func() error { + s.LocalCacheTargetHits = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.LocalCacheTargetHits = append(s.LocalCacheTargetHits, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"local_cache_target_hits\"") + } + case "local_test_target_hits": + if err := func() error { + s.LocalTestTargetHits = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.LocalTestTargetHits = append(s.LocalTestTargetHits, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"local_test_target_hits\"") + } + case "remote_cache_target_hits": + if err := func() error { + s.RemoteCacheTargetHits = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.RemoteCacheTargetHits = append(s.RemoteCacheTargetHits, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"remote_cache_target_hits\"") + } + case "remote_test_target_hits": + if err := func() error { + s.RemoteTestTargetHits = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.RemoteTestTargetHits = append(s.RemoteTestTargetHits, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"remote_test_target_hits\"") + } + case "test_targets": + if err := func() error { + s.TestTargets = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.TestTargets = append(s.TestTargets, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"test_targets\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode CreateCommandEventReqParams") + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *CreateCommandEventReqParams) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateProjectTokenUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CreateCommandEventReqParams) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateProjectUnauthorized as json. -func (s *CreateProjectUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode encodes CreateCommandEventReqStatus as json. +func (s CreateCommandEventReqStatus) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes CreateProjectUnauthorized from json. -func (s *CreateProjectUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes CreateCommandEventReqStatus from json. +func (s *CreateCommandEventReqStatus) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode CreateProjectUnauthorized to nil") + return errors.New("invalid: unable to decode CreateCommandEventReqStatus to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") + v, err := d.StrBytes() + if err != nil { + return err } - *s = CreateProjectUnauthorized(unwrapped) + // Try to use constant string. + switch CreateCommandEventReqStatus(v) { + case CreateCommandEventReqStatusSuccess: + *s = CreateCommandEventReqStatusSuccess + case CreateCommandEventReqStatusFailure: + *s = CreateCommandEventReqStatusFailure + default: + *s = CreateCommandEventReqStatus(v) + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *CreateProjectUnauthorized) MarshalJSON() ([]byte, error) { +func (s CreateCommandEventReqStatus) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *CreateProjectUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CreateCommandEventReqStatus) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DeleteOrganizationForbidden as json. -func (s *DeleteOrganizationForbidden) Encode(e *jx.Encoder) { +// Encode encodes CreateCommandEventUnauthorized as json. +func (s *CreateCommandEventUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes DeleteOrganizationForbidden from json. -func (s *DeleteOrganizationForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CreateCommandEventUnauthorized from json. +func (s *CreateCommandEventUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DeleteOrganizationForbidden to nil") + return errors.New("invalid: unable to decode CreateCommandEventUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -4961,34 +4956,34 @@ func (s *DeleteOrganizationForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = DeleteOrganizationForbidden(unwrapped) + *s = CreateCommandEventUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DeleteOrganizationForbidden) MarshalJSON() ([]byte, error) { +func (s *CreateCommandEventUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DeleteOrganizationForbidden) UnmarshalJSON(data []byte) error { +func (s *CreateCommandEventUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DeleteOrganizationNotFound as json. -func (s *DeleteOrganizationNotFound) Encode(e *jx.Encoder) { +// Encode encodes CreateInvitationBadRequest as json. +func (s *CreateInvitationBadRequest) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes DeleteOrganizationNotFound from json. -func (s *DeleteOrganizationNotFound) Decode(d *jx.Decoder) error { +// Decode decodes CreateInvitationBadRequest from json. +func (s *CreateInvitationBadRequest) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DeleteOrganizationNotFound to nil") + return errors.New("invalid: unable to decode CreateInvitationBadRequest to nil") } var unwrapped Error if err := func() error { @@ -4999,34 +4994,34 @@ func (s *DeleteOrganizationNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = DeleteOrganizationNotFound(unwrapped) + *s = CreateInvitationBadRequest(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DeleteOrganizationNotFound) MarshalJSON() ([]byte, error) { +func (s *CreateInvitationBadRequest) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DeleteOrganizationNotFound) UnmarshalJSON(data []byte) error { +func (s *CreateInvitationBadRequest) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DeleteOrganizationUnauthorized as json. -func (s *DeleteOrganizationUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes CreateInvitationForbidden as json. +func (s *CreateInvitationForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes DeleteOrganizationUnauthorized from json. -func (s *DeleteOrganizationUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes CreateInvitationForbidden from json. +func (s *CreateInvitationForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DeleteOrganizationUnauthorized to nil") + return errors.New("invalid: unable to decode CreateInvitationForbidden to nil") } var unwrapped Error if err := func() error { @@ -5037,34 +5032,34 @@ func (s *DeleteOrganizationUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = DeleteOrganizationUnauthorized(unwrapped) + *s = CreateInvitationForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DeleteOrganizationUnauthorized) MarshalJSON() ([]byte, error) { +func (s *CreateInvitationForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DeleteOrganizationUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CreateInvitationForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DeleteProjectForbidden as json. -func (s *DeleteProjectForbidden) Encode(e *jx.Encoder) { +// Encode encodes CreateInvitationNotFound as json. +func (s *CreateInvitationNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes DeleteProjectForbidden from json. -func (s *DeleteProjectForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CreateInvitationNotFound from json. +func (s *CreateInvitationNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DeleteProjectForbidden to nil") + return errors.New("invalid: unable to decode CreateInvitationNotFound to nil") } var unwrapped Error if err := func() error { @@ -5075,72 +5070,130 @@ func (s *DeleteProjectForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = DeleteProjectForbidden(unwrapped) + *s = CreateInvitationNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DeleteProjectForbidden) MarshalJSON() ([]byte, error) { +func (s *CreateInvitationNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DeleteProjectForbidden) UnmarshalJSON(data []byte) error { +func (s *CreateInvitationNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DeleteProjectNotFound as json. -func (s *DeleteProjectNotFound) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) +// Encode implements json.Marshaler. +func (s *CreateInvitationReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} - unwrapped.Encode(e) +// encodeFields encodes fields. +func (s *CreateInvitationReq) encodeFields(e *jx.Encoder) { + { + e.FieldStart("invitee_email") + e.Str(s.InviteeEmail) + } } -// Decode decodes DeleteProjectNotFound from json. -func (s *DeleteProjectNotFound) Decode(d *jx.Decoder) error { +var jsonFieldsNameOfCreateInvitationReq = [1]string{ + 0: "invitee_email", +} + +// Decode decodes CreateInvitationReq from json. +func (s *CreateInvitationReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DeleteProjectNotFound to nil") + return errors.New("invalid: unable to decode CreateInvitationReq to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "invitee_email": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.InviteeEmail = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"invitee_email\"") + } + default: + return d.Skip() } return nil - }(); err != nil { - return errors.Wrap(err, "alias") + }); err != nil { + return errors.Wrap(err, "decode CreateInvitationReq") } - *s = DeleteProjectNotFound(unwrapped) + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfCreateInvitationReq) { + name = jsonFieldsNameOfCreateInvitationReq[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DeleteProjectNotFound) MarshalJSON() ([]byte, error) { +func (s *CreateInvitationReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DeleteProjectNotFound) UnmarshalJSON(data []byte) error { +func (s *CreateInvitationReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DeleteProjectUnauthorized as json. -func (s *DeleteProjectUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes CreateInvitationUnauthorized as json. +func (s *CreateInvitationUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes DeleteProjectUnauthorized from json. -func (s *DeleteProjectUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes CreateInvitationUnauthorized from json. +func (s *CreateInvitationUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DeleteProjectUnauthorized to nil") + return errors.New("invalid: unable to decode CreateInvitationUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -5151,72 +5204,130 @@ func (s *DeleteProjectUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = DeleteProjectUnauthorized(unwrapped) + *s = CreateInvitationUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DeleteProjectUnauthorized) MarshalJSON() ([]byte, error) { +func (s *CreateInvitationUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DeleteProjectUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CreateInvitationUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DownloadCacheArtifactForbidden as json. -func (s *DownloadCacheArtifactForbidden) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) +// Encode implements json.Marshaler. +func (s *CreateOrganizationReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} - unwrapped.Encode(e) +// encodeFields encodes fields. +func (s *CreateOrganizationReq) encodeFields(e *jx.Encoder) { + { + e.FieldStart("name") + e.Str(s.Name) + } } -// Decode decodes DownloadCacheArtifactForbidden from json. -func (s *DownloadCacheArtifactForbidden) Decode(d *jx.Decoder) error { +var jsonFieldsNameOfCreateOrganizationReq = [1]string{ + 0: "name", +} + +// Decode decodes CreateOrganizationReq from json. +func (s *CreateOrganizationReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DownloadCacheArtifactForbidden to nil") + return errors.New("invalid: unable to decode CreateOrganizationReq to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "name": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.Name = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + default: + return d.Skip() } return nil - }(); err != nil { - return errors.Wrap(err, "alias") + }); err != nil { + return errors.Wrap(err, "decode CreateOrganizationReq") } - *s = DownloadCacheArtifactForbidden(unwrapped) + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfCreateOrganizationReq) { + name = jsonFieldsNameOfCreateOrganizationReq[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DownloadCacheArtifactForbidden) MarshalJSON() ([]byte, error) { +func (s *CreateOrganizationReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DownloadCacheArtifactForbidden) UnmarshalJSON(data []byte) error { +func (s *CreateOrganizationReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DownloadCacheArtifactNotFound as json. -func (s *DownloadCacheArtifactNotFound) Encode(e *jx.Encoder) { +// Encode encodes CreateProjectBadRequest as json. +func (s *CreateProjectBadRequest) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes DownloadCacheArtifactNotFound from json. -func (s *DownloadCacheArtifactNotFound) Decode(d *jx.Decoder) error { +// Decode decodes CreateProjectBadRequest from json. +func (s *CreateProjectBadRequest) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DownloadCacheArtifactNotFound to nil") + return errors.New("invalid: unable to decode CreateProjectBadRequest to nil") } var unwrapped Error if err := func() error { @@ -5227,34 +5338,34 @@ func (s *DownloadCacheArtifactNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = DownloadCacheArtifactNotFound(unwrapped) + *s = CreateProjectBadRequest(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DownloadCacheArtifactNotFound) MarshalJSON() ([]byte, error) { +func (s *CreateProjectBadRequest) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DownloadCacheArtifactNotFound) UnmarshalJSON(data []byte) error { +func (s *CreateProjectBadRequest) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DownloadCacheArtifactPaymentRequired as json. -func (s *DownloadCacheArtifactPaymentRequired) Encode(e *jx.Encoder) { +// Encode encodes CreateProjectForbidden as json. +func (s *CreateProjectForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes DownloadCacheArtifactPaymentRequired from json. -func (s *DownloadCacheArtifactPaymentRequired) Decode(d *jx.Decoder) error { +// Decode decodes CreateProjectForbidden from json. +func (s *CreateProjectForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DownloadCacheArtifactPaymentRequired to nil") + return errors.New("invalid: unable to decode CreateProjectForbidden to nil") } var unwrapped Error if err := func() error { @@ -5265,110 +5376,131 @@ func (s *DownloadCacheArtifactPaymentRequired) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = DownloadCacheArtifactPaymentRequired(unwrapped) + *s = CreateProjectForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DownloadCacheArtifactPaymentRequired) MarshalJSON() ([]byte, error) { +func (s *CreateProjectForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DownloadCacheArtifactPaymentRequired) UnmarshalJSON(data []byte) error { +func (s *CreateProjectForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DownloadCacheArtifactUnauthorized as json. -func (s *DownloadCacheArtifactUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode implements json.Marshaler. +func (s *CreateProjectReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes DownloadCacheArtifactUnauthorized from json. -func (s *DownloadCacheArtifactUnauthorized) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode DownloadCacheArtifactUnauthorized to nil") +// encodeFields encodes fields. +func (s *CreateProjectReq) encodeFields(e *jx.Encoder) { + { + if s.FullHandle.Set { + e.FieldStart("full_handle") + s.FullHandle.Encode(e) + } } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err + { + if s.Name.Set { + e.FieldStart("name") + s.Name.Encode(e) + } + } + { + if s.Organization.Set { + e.FieldStart("organization") + s.Organization.Encode(e) } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") } - *s = DownloadCacheArtifactUnauthorized(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *DownloadCacheArtifactUnauthorized) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DownloadCacheArtifactUnauthorized) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) } -// Encode encodes DownloadPreviewForbidden as json. -func (s *DownloadPreviewForbidden) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +var jsonFieldsNameOfCreateProjectReq = [3]string{ + 0: "full_handle", + 1: "name", + 2: "organization", } -// Decode decodes DownloadPreviewForbidden from json. -func (s *DownloadPreviewForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CreateProjectReq from json. +func (s *CreateProjectReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DownloadPreviewForbidden to nil") + return errors.New("invalid: unable to decode CreateProjectReq to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "full_handle": + if err := func() error { + s.FullHandle.Reset() + if err := s.FullHandle.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"full_handle\"") + } + case "name": + if err := func() error { + s.Name.Reset() + if err := s.Name.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + case "organization": + if err := func() error { + s.Organization.Reset() + if err := s.Organization.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"organization\"") + } + default: + return d.Skip() } return nil - }(); err != nil { - return errors.Wrap(err, "alias") + }); err != nil { + return errors.Wrap(err, "decode CreateProjectReq") } - *s = DownloadPreviewForbidden(unwrapped) + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DownloadPreviewForbidden) MarshalJSON() ([]byte, error) { +func (s *CreateProjectReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DownloadPreviewForbidden) UnmarshalJSON(data []byte) error { +func (s *CreateProjectReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DownloadPreviewNotFound as json. -func (s *DownloadPreviewNotFound) Encode(e *jx.Encoder) { +// Encode encodes CreateProjectTokenForbidden as json. +func (s *CreateProjectTokenForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes DownloadPreviewNotFound from json. -func (s *DownloadPreviewNotFound) Decode(d *jx.Decoder) error { +// Decode decodes CreateProjectTokenForbidden from json. +func (s *CreateProjectTokenForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DownloadPreviewNotFound to nil") + return errors.New("invalid: unable to decode CreateProjectTokenForbidden to nil") } var unwrapped Error if err := func() error { @@ -5379,34 +5511,34 @@ func (s *DownloadPreviewNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = DownloadPreviewNotFound(unwrapped) + *s = CreateProjectTokenForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DownloadPreviewNotFound) MarshalJSON() ([]byte, error) { +func (s *CreateProjectTokenForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DownloadPreviewNotFound) UnmarshalJSON(data []byte) error { +func (s *CreateProjectTokenForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes DownloadPreviewUnauthorized as json. -func (s *DownloadPreviewUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes CreateProjectTokenNotFound as json. +func (s *CreateProjectTokenNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes DownloadPreviewUnauthorized from json. -func (s *DownloadPreviewUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes CreateProjectTokenNotFound from json. +func (s *CreateProjectTokenNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode DownloadPreviewUnauthorized to nil") + return errors.New("invalid: unable to decode CreateProjectTokenNotFound to nil") } var unwrapped Error if err := func() error { @@ -5417,69 +5549,69 @@ func (s *DownloadPreviewUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = DownloadPreviewUnauthorized(unwrapped) + *s = CreateProjectTokenNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *DownloadPreviewUnauthorized) MarshalJSON() ([]byte, error) { +func (s *CreateProjectTokenNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *DownloadPreviewUnauthorized) UnmarshalJSON(data []byte) error { +func (s *CreateProjectTokenNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *Error) Encode(e *jx.Encoder) { +func (s *CreateProjectTokenOK) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *Error) encodeFields(e *jx.Encoder) { +func (s *CreateProjectTokenOK) encodeFields(e *jx.Encoder) { { - e.FieldStart("message") - e.Str(s.Message) + e.FieldStart("token") + e.Str(s.Token) } } -var jsonFieldsNameOfError = [1]string{ - 0: "message", +var jsonFieldsNameOfCreateProjectTokenOK = [1]string{ + 0: "token", } -// Decode decodes Error from json. -func (s *Error) Decode(d *jx.Decoder) error { +// Decode decodes CreateProjectTokenOK from json. +func (s *CreateProjectTokenOK) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode Error to nil") + return errors.New("invalid: unable to decode CreateProjectTokenOK to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "message": + case "token": requiredBitSet[0] |= 1 << 0 if err := func() error { v, err := d.Str() - s.Message = string(v) + s.Token = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"message\"") + return errors.Wrap(err, "decode field \"token\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode Error") + return errors.Wrap(err, "decode CreateProjectTokenOK") } // Validate required fields. var failures []validate.FieldError @@ -5496,8 +5628,8 @@ func (s *Error) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfError) { - name = jsonFieldsNameOfError[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfCreateProjectTokenOK) { + name = jsonFieldsNameOfCreateProjectTokenOK[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -5518,29 +5650,29 @@ func (s *Error) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *Error) MarshalJSON() ([]byte, error) { +func (s *CreateProjectTokenOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *Error) UnmarshalJSON(data []byte) error { +func (s *CreateProjectTokenOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GenerateAnalyticsArtifactMultipartUploadURLForbidden as json. -func (s *GenerateAnalyticsArtifactMultipartUploadURLForbidden) Encode(e *jx.Encoder) { +// Encode encodes CreateProjectTokenUnauthorized as json. +func (s *CreateProjectTokenUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLForbidden from json. -func (s *GenerateAnalyticsArtifactMultipartUploadURLForbidden) Decode(d *jx.Decoder) error { +// Decode decodes CreateProjectTokenUnauthorized from json. +func (s *CreateProjectTokenUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GenerateAnalyticsArtifactMultipartUploadURLForbidden to nil") + return errors.New("invalid: unable to decode CreateProjectTokenUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -5551,34 +5683,34 @@ func (s *GenerateAnalyticsArtifactMultipartUploadURLForbidden) Decode(d *jx.Deco }(); err != nil { return errors.Wrap(err, "alias") } - *s = GenerateAnalyticsArtifactMultipartUploadURLForbidden(unwrapped) + *s = CreateProjectTokenUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GenerateAnalyticsArtifactMultipartUploadURLForbidden) MarshalJSON() ([]byte, error) { +func (s *CreateProjectTokenUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GenerateAnalyticsArtifactMultipartUploadURLForbidden) UnmarshalJSON(data []byte) error { +func (s *CreateProjectTokenUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GenerateAnalyticsArtifactMultipartUploadURLNotFound as json. -func (s *GenerateAnalyticsArtifactMultipartUploadURLNotFound) Encode(e *jx.Encoder) { +// Encode encodes CreateProjectUnauthorized as json. +func (s *CreateProjectUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLNotFound from json. -func (s *GenerateAnalyticsArtifactMultipartUploadURLNotFound) Decode(d *jx.Decoder) error { +// Decode decodes CreateProjectUnauthorized from json. +func (s *CreateProjectUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GenerateAnalyticsArtifactMultipartUploadURLNotFound to nil") + return errors.New("invalid: unable to decode CreateProjectUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -5589,143 +5721,72 @@ func (s *GenerateAnalyticsArtifactMultipartUploadURLNotFound) Decode(d *jx.Decod }(); err != nil { return errors.Wrap(err, "alias") } - *s = GenerateAnalyticsArtifactMultipartUploadURLNotFound(unwrapped) + *s = CreateProjectUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GenerateAnalyticsArtifactMultipartUploadURLNotFound) MarshalJSON() ([]byte, error) { +func (s *CreateProjectUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GenerateAnalyticsArtifactMultipartUploadURLNotFound) UnmarshalJSON(data []byte) error { +func (s *CreateProjectUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} +// Encode encodes DeleteOrganizationForbidden as json. +func (s *DeleteOrganizationForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) -// encodeFields encodes fields. -func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) encodeFields(e *jx.Encoder) { - { - e.FieldStart("command_event_artifact") - s.CommandEventArtifact.Encode(e) - } - { - e.FieldStart("multipart_upload_part") - s.MultipartUploadPart.Encode(e) - } + unwrapped.Encode(e) } -var jsonFieldsNameOfGenerateAnalyticsArtifactMultipartUploadURLReq = [2]string{ - 0: "command_event_artifact", - 1: "multipart_upload_part", -} - -// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLReq from json. -func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) Decode(d *jx.Decoder) error { +// Decode decodes DeleteOrganizationForbidden from json. +func (s *DeleteOrganizationForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GenerateAnalyticsArtifactMultipartUploadURLReq to nil") + return errors.New("invalid: unable to decode DeleteOrganizationForbidden to nil") } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "command_event_artifact": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - if err := s.CommandEventArtifact.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"command_event_artifact\"") - } - case "multipart_upload_part": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - if err := s.MultipartUploadPart.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"multipart_upload_part\"") - } - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } return nil - }); err != nil { - return errors.Wrap(err, "decode GenerateAnalyticsArtifactMultipartUploadURLReq") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000011, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfGenerateAnalyticsArtifactMultipartUploadURLReq) { - name = jsonFieldsNameOfGenerateAnalyticsArtifactMultipartUploadURLReq[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = DeleteOrganizationForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) MarshalJSON() ([]byte, error) { +func (s *DeleteOrganizationForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) UnmarshalJSON(data []byte) error { +func (s *DeleteOrganizationForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GenerateAnalyticsArtifactMultipartUploadURLUnauthorized as json. -func (s *GenerateAnalyticsArtifactMultipartUploadURLUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes DeleteOrganizationNotFound as json. +func (s *DeleteOrganizationNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLUnauthorized from json. -func (s *GenerateAnalyticsArtifactMultipartUploadURLUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes DeleteOrganizationNotFound from json. +func (s *DeleteOrganizationNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GenerateAnalyticsArtifactMultipartUploadURLUnauthorized to nil") + return errors.New("invalid: unable to decode DeleteOrganizationNotFound to nil") } var unwrapped Error if err := func() error { @@ -5736,34 +5797,34 @@ func (s *GenerateAnalyticsArtifactMultipartUploadURLUnauthorized) Decode(d *jx.D }(); err != nil { return errors.Wrap(err, "alias") } - *s = GenerateAnalyticsArtifactMultipartUploadURLUnauthorized(unwrapped) + *s = DeleteOrganizationNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GenerateAnalyticsArtifactMultipartUploadURLUnauthorized) MarshalJSON() ([]byte, error) { +func (s *DeleteOrganizationNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GenerateAnalyticsArtifactMultipartUploadURLUnauthorized) UnmarshalJSON(data []byte) error { +func (s *DeleteOrganizationNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GenerateCacheArtifactMultipartUploadURLForbidden as json. -func (s *GenerateCacheArtifactMultipartUploadURLForbidden) Encode(e *jx.Encoder) { +// Encode encodes DeleteOrganizationUnauthorized as json. +func (s *DeleteOrganizationUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GenerateCacheArtifactMultipartUploadURLForbidden from json. -func (s *GenerateCacheArtifactMultipartUploadURLForbidden) Decode(d *jx.Decoder) error { +// Decode decodes DeleteOrganizationUnauthorized from json. +func (s *DeleteOrganizationUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GenerateCacheArtifactMultipartUploadURLForbidden to nil") + return errors.New("invalid: unable to decode DeleteOrganizationUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -5774,34 +5835,34 @@ func (s *GenerateCacheArtifactMultipartUploadURLForbidden) Decode(d *jx.Decoder) }(); err != nil { return errors.Wrap(err, "alias") } - *s = GenerateCacheArtifactMultipartUploadURLForbidden(unwrapped) + *s = DeleteOrganizationUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GenerateCacheArtifactMultipartUploadURLForbidden) MarshalJSON() ([]byte, error) { +func (s *DeleteOrganizationUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GenerateCacheArtifactMultipartUploadURLForbidden) UnmarshalJSON(data []byte) error { +func (s *DeleteOrganizationUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GenerateCacheArtifactMultipartUploadURLNotFound as json. -func (s *GenerateCacheArtifactMultipartUploadURLNotFound) Encode(e *jx.Encoder) { +// Encode encodes DeleteProjectForbidden as json. +func (s *DeleteProjectForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GenerateCacheArtifactMultipartUploadURLNotFound from json. -func (s *GenerateCacheArtifactMultipartUploadURLNotFound) Decode(d *jx.Decoder) error { +// Decode decodes DeleteProjectForbidden from json. +func (s *DeleteProjectForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GenerateCacheArtifactMultipartUploadURLNotFound to nil") + return errors.New("invalid: unable to decode DeleteProjectForbidden to nil") } var unwrapped Error if err := func() error { @@ -5812,34 +5873,34 @@ func (s *GenerateCacheArtifactMultipartUploadURLNotFound) Decode(d *jx.Decoder) }(); err != nil { return errors.Wrap(err, "alias") } - *s = GenerateCacheArtifactMultipartUploadURLNotFound(unwrapped) + *s = DeleteProjectForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GenerateCacheArtifactMultipartUploadURLNotFound) MarshalJSON() ([]byte, error) { +func (s *DeleteProjectForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GenerateCacheArtifactMultipartUploadURLNotFound) UnmarshalJSON(data []byte) error { +func (s *DeleteProjectForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GenerateCacheArtifactMultipartUploadURLPaymentRequired as json. -func (s *GenerateCacheArtifactMultipartUploadURLPaymentRequired) Encode(e *jx.Encoder) { +// Encode encodes DeleteProjectNotFound as json. +func (s *DeleteProjectNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GenerateCacheArtifactMultipartUploadURLPaymentRequired from json. -func (s *GenerateCacheArtifactMultipartUploadURLPaymentRequired) Decode(d *jx.Decoder) error { +// Decode decodes DeleteProjectNotFound from json. +func (s *DeleteProjectNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GenerateCacheArtifactMultipartUploadURLPaymentRequired to nil") + return errors.New("invalid: unable to decode DeleteProjectNotFound to nil") } var unwrapped Error if err := func() error { @@ -5850,34 +5911,34 @@ func (s *GenerateCacheArtifactMultipartUploadURLPaymentRequired) Decode(d *jx.De }(); err != nil { return errors.Wrap(err, "alias") } - *s = GenerateCacheArtifactMultipartUploadURLPaymentRequired(unwrapped) + *s = DeleteProjectNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GenerateCacheArtifactMultipartUploadURLPaymentRequired) MarshalJSON() ([]byte, error) { +func (s *DeleteProjectNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GenerateCacheArtifactMultipartUploadURLPaymentRequired) UnmarshalJSON(data []byte) error { +func (s *DeleteProjectNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GenerateCacheArtifactMultipartUploadURLUnauthorized as json. -func (s *GenerateCacheArtifactMultipartUploadURLUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes DeleteProjectUnauthorized as json. +func (s *DeleteProjectUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GenerateCacheArtifactMultipartUploadURLUnauthorized from json. -func (s *GenerateCacheArtifactMultipartUploadURLUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes DeleteProjectUnauthorized from json. +func (s *DeleteProjectUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GenerateCacheArtifactMultipartUploadURLUnauthorized to nil") + return errors.New("invalid: unable to decode DeleteProjectUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -5888,34 +5949,34 @@ func (s *GenerateCacheArtifactMultipartUploadURLUnauthorized) Decode(d *jx.Decod }(); err != nil { return errors.Wrap(err, "alias") } - *s = GenerateCacheArtifactMultipartUploadURLUnauthorized(unwrapped) + *s = DeleteProjectUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GenerateCacheArtifactMultipartUploadURLUnauthorized) MarshalJSON() ([]byte, error) { +func (s *DeleteProjectUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GenerateCacheArtifactMultipartUploadURLUnauthorized) UnmarshalJSON(data []byte) error { +func (s *DeleteProjectUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GeneratePreviewsMultipartUploadURLForbidden as json. -func (s *GeneratePreviewsMultipartUploadURLForbidden) Encode(e *jx.Encoder) { +// Encode encodes DownloadCacheArtifactForbidden as json. +func (s *DownloadCacheArtifactForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GeneratePreviewsMultipartUploadURLForbidden from json. -func (s *GeneratePreviewsMultipartUploadURLForbidden) Decode(d *jx.Decoder) error { +// Decode decodes DownloadCacheArtifactForbidden from json. +func (s *DownloadCacheArtifactForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GeneratePreviewsMultipartUploadURLForbidden to nil") + return errors.New("invalid: unable to decode DownloadCacheArtifactForbidden to nil") } var unwrapped Error if err := func() error { @@ -5926,34 +5987,34 @@ func (s *GeneratePreviewsMultipartUploadURLForbidden) Decode(d *jx.Decoder) erro }(); err != nil { return errors.Wrap(err, "alias") } - *s = GeneratePreviewsMultipartUploadURLForbidden(unwrapped) + *s = DownloadCacheArtifactForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GeneratePreviewsMultipartUploadURLForbidden) MarshalJSON() ([]byte, error) { +func (s *DownloadCacheArtifactForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GeneratePreviewsMultipartUploadURLForbidden) UnmarshalJSON(data []byte) error { +func (s *DownloadCacheArtifactForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GeneratePreviewsMultipartUploadURLNotFound as json. -func (s *GeneratePreviewsMultipartUploadURLNotFound) Encode(e *jx.Encoder) { +// Encode encodes DownloadCacheArtifactNotFound as json. +func (s *DownloadCacheArtifactNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GeneratePreviewsMultipartUploadURLNotFound from json. -func (s *GeneratePreviewsMultipartUploadURLNotFound) Decode(d *jx.Decoder) error { +// Decode decodes DownloadCacheArtifactNotFound from json. +func (s *DownloadCacheArtifactNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GeneratePreviewsMultipartUploadURLNotFound to nil") + return errors.New("invalid: unable to decode DownloadCacheArtifactNotFound to nil") } var unwrapped Error if err := func() error { @@ -5964,145 +6025,110 @@ func (s *GeneratePreviewsMultipartUploadURLNotFound) Decode(d *jx.Decoder) error }(); err != nil { return errors.Wrap(err, "alias") } - *s = GeneratePreviewsMultipartUploadURLNotFound(unwrapped) + *s = DownloadCacheArtifactNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GeneratePreviewsMultipartUploadURLNotFound) MarshalJSON() ([]byte, error) { +func (s *DownloadCacheArtifactNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GeneratePreviewsMultipartUploadURLNotFound) UnmarshalJSON(data []byte) error { +func (s *DownloadCacheArtifactNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *GeneratePreviewsMultipartUploadURLReq) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() +// Encode encodes DownloadCacheArtifactPaymentRequired as json. +func (s *DownloadCacheArtifactPaymentRequired) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// encodeFields encodes fields. -func (s *GeneratePreviewsMultipartUploadURLReq) encodeFields(e *jx.Encoder) { - { - e.FieldStart("multipart_upload_part") - s.MultipartUploadPart.Encode(e) +// Decode decodes DownloadCacheArtifactPaymentRequired from json. +func (s *DownloadCacheArtifactPaymentRequired) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode DownloadCacheArtifactPaymentRequired to nil") } - { - e.FieldStart("preview_id") - e.Str(s.PreviewID) + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = DownloadCacheArtifactPaymentRequired(unwrapped) + return nil } -var jsonFieldsNameOfGeneratePreviewsMultipartUploadURLReq = [2]string{ - 0: "multipart_upload_part", - 1: "preview_id", +// MarshalJSON implements stdjson.Marshaler. +func (s *DownloadCacheArtifactPaymentRequired) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil } -// Decode decodes GeneratePreviewsMultipartUploadURLReq from json. -func (s *GeneratePreviewsMultipartUploadURLReq) Decode(d *jx.Decoder) error { +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *DownloadCacheArtifactPaymentRequired) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes DownloadCacheArtifactUnauthorized as json. +func (s *DownloadCacheArtifactUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes DownloadCacheArtifactUnauthorized from json. +func (s *DownloadCacheArtifactUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GeneratePreviewsMultipartUploadURLReq to nil") + return errors.New("invalid: unable to decode DownloadCacheArtifactUnauthorized to nil") } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "multipart_upload_part": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - if err := s.MultipartUploadPart.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"multipart_upload_part\"") - } - case "preview_id": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - v, err := d.Str() - s.PreviewID = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"preview_id\"") - } - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } return nil - }); err != nil { - return errors.Wrap(err, "decode GeneratePreviewsMultipartUploadURLReq") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000011, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfGeneratePreviewsMultipartUploadURLReq) { - name = jsonFieldsNameOfGeneratePreviewsMultipartUploadURLReq[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = DownloadCacheArtifactUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GeneratePreviewsMultipartUploadURLReq) MarshalJSON() ([]byte, error) { +func (s *DownloadCacheArtifactUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GeneratePreviewsMultipartUploadURLReq) UnmarshalJSON(data []byte) error { +func (s *DownloadCacheArtifactUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GeneratePreviewsMultipartUploadURLUnauthorized as json. -func (s *GeneratePreviewsMultipartUploadURLUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes DownloadPreviewForbidden as json. +func (s *DownloadPreviewForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GeneratePreviewsMultipartUploadURLUnauthorized from json. -func (s *GeneratePreviewsMultipartUploadURLUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes DownloadPreviewForbidden from json. +func (s *DownloadPreviewForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GeneratePreviewsMultipartUploadURLUnauthorized to nil") + return errors.New("invalid: unable to decode DownloadPreviewForbidden to nil") } var unwrapped Error if err := func() error { @@ -6113,34 +6139,34 @@ func (s *GeneratePreviewsMultipartUploadURLUnauthorized) Decode(d *jx.Decoder) e }(); err != nil { return errors.Wrap(err, "alias") } - *s = GeneratePreviewsMultipartUploadURLUnauthorized(unwrapped) + *s = DownloadPreviewForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GeneratePreviewsMultipartUploadURLUnauthorized) MarshalJSON() ([]byte, error) { +func (s *DownloadPreviewForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GeneratePreviewsMultipartUploadURLUnauthorized) UnmarshalJSON(data []byte) error { +func (s *DownloadPreviewForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GetCacheActionItemForbidden as json. -func (s *GetCacheActionItemForbidden) Encode(e *jx.Encoder) { +// Encode encodes DownloadPreviewNotFound as json. +func (s *DownloadPreviewNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GetCacheActionItemForbidden from json. -func (s *GetCacheActionItemForbidden) Decode(d *jx.Decoder) error { +// Decode decodes DownloadPreviewNotFound from json. +func (s *DownloadPreviewNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GetCacheActionItemForbidden to nil") + return errors.New("invalid: unable to decode DownloadPreviewNotFound to nil") } var unwrapped Error if err := func() error { @@ -6151,34 +6177,34 @@ func (s *GetCacheActionItemForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = GetCacheActionItemForbidden(unwrapped) + *s = DownloadPreviewNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GetCacheActionItemForbidden) MarshalJSON() ([]byte, error) { +func (s *DownloadPreviewNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GetCacheActionItemForbidden) UnmarshalJSON(data []byte) error { +func (s *DownloadPreviewNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GetCacheActionItemNotFound as json. -func (s *GetCacheActionItemNotFound) Encode(e *jx.Encoder) { +// Encode encodes DownloadPreviewUnauthorized as json. +func (s *DownloadPreviewUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GetCacheActionItemNotFound from json. -func (s *GetCacheActionItemNotFound) Decode(d *jx.Decoder) error { +// Decode decodes DownloadPreviewUnauthorized from json. +func (s *DownloadPreviewUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GetCacheActionItemNotFound to nil") + return errors.New("invalid: unable to decode DownloadPreviewUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -6189,34 +6215,130 @@ func (s *GetCacheActionItemNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = GetCacheActionItemNotFound(unwrapped) + *s = DownloadPreviewUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GetCacheActionItemNotFound) MarshalJSON() ([]byte, error) { +func (s *DownloadPreviewUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GetCacheActionItemNotFound) UnmarshalJSON(data []byte) error { +func (s *DownloadPreviewUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GetCacheActionItemPaymentRequired as json. -func (s *GetCacheActionItemPaymentRequired) Encode(e *jx.Encoder) { +// Encode implements json.Marshaler. +func (s *Error) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Error) encodeFields(e *jx.Encoder) { + { + e.FieldStart("message") + e.Str(s.Message) + } +} + +var jsonFieldsNameOfError = [1]string{ + 0: "message", +} + +// Decode decodes Error from json. +func (s *Error) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Error to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "message": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.Message = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"message\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Error") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfError) { + name = jsonFieldsNameOfError[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Error) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Error) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes GenerateAnalyticsArtifactMultipartUploadURLForbidden as json. +func (s *GenerateAnalyticsArtifactMultipartUploadURLForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GetCacheActionItemPaymentRequired from json. -func (s *GetCacheActionItemPaymentRequired) Decode(d *jx.Decoder) error { +// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLForbidden from json. +func (s *GenerateAnalyticsArtifactMultipartUploadURLForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GetCacheActionItemPaymentRequired to nil") + return errors.New("invalid: unable to decode GenerateAnalyticsArtifactMultipartUploadURLForbidden to nil") } var unwrapped Error if err := func() error { @@ -6227,34 +6349,34 @@ func (s *GetCacheActionItemPaymentRequired) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = GetCacheActionItemPaymentRequired(unwrapped) + *s = GenerateAnalyticsArtifactMultipartUploadURLForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GetCacheActionItemPaymentRequired) MarshalJSON() ([]byte, error) { +func (s *GenerateAnalyticsArtifactMultipartUploadURLForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GetCacheActionItemPaymentRequired) UnmarshalJSON(data []byte) error { +func (s *GenerateAnalyticsArtifactMultipartUploadURLForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GetCacheActionItemUnauthorized as json. -func (s *GetCacheActionItemUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes GenerateAnalyticsArtifactMultipartUploadURLNotFound as json. +func (s *GenerateAnalyticsArtifactMultipartUploadURLNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes GetCacheActionItemUnauthorized from json. -func (s *GetCacheActionItemUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLNotFound from json. +func (s *GenerateAnalyticsArtifactMultipartUploadURLNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode GetCacheActionItemUnauthorized to nil") + return errors.New("invalid: unable to decode GenerateAnalyticsArtifactMultipartUploadURLNotFound to nil") } var unwrapped Error if err := func() error { @@ -6265,281 +6387,87 @@ func (s *GetCacheActionItemUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = GetCacheActionItemUnauthorized(unwrapped) + *s = GenerateAnalyticsArtifactMultipartUploadURLNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *GetCacheActionItemUnauthorized) MarshalJSON() ([]byte, error) { +func (s *GenerateAnalyticsArtifactMultipartUploadURLNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GetCacheActionItemUnauthorized) UnmarshalJSON(data []byte) error { +func (s *GenerateAnalyticsArtifactMultipartUploadURLNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *GetDeviceCodeAccepted) Encode(e *jx.Encoder) { +func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *GetDeviceCodeAccepted) encodeFields(e *jx.Encoder) { -} - -var jsonFieldsNameOfGetDeviceCodeAccepted = [0]string{} - -// Decode decodes GetDeviceCodeAccepted from json. -func (s *GetDeviceCodeAccepted) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode GetDeviceCodeAccepted to nil") - } - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - default: - return d.Skip() - } - }); err != nil { - return errors.Wrap(err, "decode GetDeviceCodeAccepted") - } - - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *GetDeviceCodeAccepted) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GetDeviceCodeAccepted) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode implements json.Marshaler. -func (s *GetDeviceCodeOK) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *GetDeviceCodeOK) encodeFields(e *jx.Encoder) { - { - if s.AccessToken.Set { - e.FieldStart("access_token") - s.AccessToken.Encode(e) - } - } - { - if s.RefreshToken.Set { - e.FieldStart("refresh_token") - s.RefreshToken.Encode(e) - } - } - { - if s.Token.Set { - e.FieldStart("token") - s.Token.Encode(e) - } - } -} - -var jsonFieldsNameOfGetDeviceCodeOK = [3]string{ - 0: "access_token", - 1: "refresh_token", - 2: "token", -} - -// Decode decodes GetDeviceCodeOK from json. -func (s *GetDeviceCodeOK) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode GetDeviceCodeOK to nil") - } - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "access_token": - if err := func() error { - s.AccessToken.Reset() - if err := s.AccessToken.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"access_token\"") - } - case "refresh_token": - if err := func() error { - s.RefreshToken.Reset() - if err := s.RefreshToken.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"refresh_token\"") - } - case "token": - if err := func() error { - s.Token.Reset() - if err := s.Token.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"token\"") - } - default: - return d.Skip() - } - return nil - }); err != nil { - return errors.Wrap(err, "decode GetDeviceCodeOK") - } - - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *GetDeviceCodeOK) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *GetDeviceCodeOK) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode implements json.Marshaler. -func (s *Invitation) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *Invitation) encodeFields(e *jx.Encoder) { - { - e.FieldStart("id") - e.Float64(s.ID) - } - { - e.FieldStart("invitee_email") - e.Str(s.InviteeEmail) - } - { - e.FieldStart("inviter") - s.Inviter.Encode(e) - } +func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) encodeFields(e *jx.Encoder) { { - e.FieldStart("organization_id") - e.Float64(s.OrganizationID) + e.FieldStart("command_event_artifact") + s.CommandEventArtifact.Encode(e) } { - e.FieldStart("token") - e.Str(s.Token) + e.FieldStart("multipart_upload_part") + s.MultipartUploadPart.Encode(e) } } -var jsonFieldsNameOfInvitation = [5]string{ - 0: "id", - 1: "invitee_email", - 2: "inviter", - 3: "organization_id", - 4: "token", +var jsonFieldsNameOfGenerateAnalyticsArtifactMultipartUploadURLReq = [2]string{ + 0: "command_event_artifact", + 1: "multipart_upload_part", } -// Decode decodes Invitation from json. -func (s *Invitation) Decode(d *jx.Decoder) error { +// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLReq from json. +func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode Invitation to nil") + return errors.New("invalid: unable to decode GenerateAnalyticsArtifactMultipartUploadURLReq to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "id": + case "command_event_artifact": requiredBitSet[0] |= 1 << 0 if err := func() error { - v, err := d.Float64() - s.ID = float64(v) - if err != nil { + if err := s.CommandEventArtifact.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"id\"") + return errors.Wrap(err, "decode field \"command_event_artifact\"") } - case "invitee_email": + case "multipart_upload_part": requiredBitSet[0] |= 1 << 1 if err := func() error { - v, err := d.Str() - s.InviteeEmail = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"invitee_email\"") - } - case "inviter": - requiredBitSet[0] |= 1 << 2 - if err := func() error { - if err := s.Inviter.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"inviter\"") - } - case "organization_id": - requiredBitSet[0] |= 1 << 3 - if err := func() error { - v, err := d.Float64() - s.OrganizationID = float64(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"organization_id\"") - } - case "token": - requiredBitSet[0] |= 1 << 4 - if err := func() error { - v, err := d.Str() - s.Token = string(v) - if err != nil { + if err := s.MultipartUploadPart.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"token\"") + return errors.Wrap(err, "decode field \"multipart_upload_part\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode Invitation") + return errors.Wrap(err, "decode GenerateAnalyticsArtifactMultipartUploadURLReq") } // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00011111, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -6551,8 +6479,8 @@ func (s *Invitation) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfInvitation) { - name = jsonFieldsNameOfInvitation[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfGenerateAnalyticsArtifactMultipartUploadURLReq) { + name = jsonFieldsNameOfGenerateAnalyticsArtifactMultipartUploadURLReq[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -6573,29 +6501,29 @@ func (s *Invitation) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *Invitation) MarshalJSON() ([]byte, error) { +func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *Invitation) UnmarshalJSON(data []byte) error { +func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ListOrganizationsForbidden as json. -func (s *ListOrganizationsForbidden) Encode(e *jx.Encoder) { +// Encode encodes GenerateAnalyticsArtifactMultipartUploadURLUnauthorized as json. +func (s *GenerateAnalyticsArtifactMultipartUploadURLUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ListOrganizationsForbidden from json. -func (s *ListOrganizationsForbidden) Decode(d *jx.Decoder) error { +// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLUnauthorized from json. +func (s *GenerateAnalyticsArtifactMultipartUploadURLUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ListOrganizationsForbidden to nil") + return errors.New("invalid: unable to decode GenerateAnalyticsArtifactMultipartUploadURLUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -6606,140 +6534,72 @@ func (s *ListOrganizationsForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ListOrganizationsForbidden(unwrapped) + *s = GenerateAnalyticsArtifactMultipartUploadURLUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ListOrganizationsForbidden) MarshalJSON() ([]byte, error) { +func (s *GenerateAnalyticsArtifactMultipartUploadURLUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ListOrganizationsForbidden) UnmarshalJSON(data []byte) error { +func (s *GenerateAnalyticsArtifactMultipartUploadURLUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *ListOrganizationsOK) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} +// Encode encodes GenerateCacheArtifactMultipartUploadURLForbidden as json. +func (s *GenerateCacheArtifactMultipartUploadURLForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) -// encodeFields encodes fields. -func (s *ListOrganizationsOK) encodeFields(e *jx.Encoder) { - { - e.FieldStart("organizations") - e.ArrStart() - for _, elem := range s.Organizations { - elem.Encode(e) - } - e.ArrEnd() - } -} - -var jsonFieldsNameOfListOrganizationsOK = [1]string{ - 0: "organizations", + unwrapped.Encode(e) } -// Decode decodes ListOrganizationsOK from json. -func (s *ListOrganizationsOK) Decode(d *jx.Decoder) error { +// Decode decodes GenerateCacheArtifactMultipartUploadURLForbidden from json. +func (s *GenerateCacheArtifactMultipartUploadURLForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ListOrganizationsOK to nil") + return errors.New("invalid: unable to decode GenerateCacheArtifactMultipartUploadURLForbidden to nil") } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "organizations": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - s.Organizations = make([]Organization, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem Organization - if err := elem.Decode(d); err != nil { - return err - } - s.Organizations = append(s.Organizations, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"organizations\"") - } - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } return nil - }); err != nil { - return errors.Wrap(err, "decode ListOrganizationsOK") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000001, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfListOrganizationsOK) { - name = jsonFieldsNameOfListOrganizationsOK[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = GenerateCacheArtifactMultipartUploadURLForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ListOrganizationsOK) MarshalJSON() ([]byte, error) { +func (s *GenerateCacheArtifactMultipartUploadURLForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ListOrganizationsOK) UnmarshalJSON(data []byte) error { +func (s *GenerateCacheArtifactMultipartUploadURLForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ListOrganizationsUnauthorized as json. -func (s *ListOrganizationsUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes GenerateCacheArtifactMultipartUploadURLNotFound as json. +func (s *GenerateCacheArtifactMultipartUploadURLNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ListOrganizationsUnauthorized from json. -func (s *ListOrganizationsUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes GenerateCacheArtifactMultipartUploadURLNotFound from json. +func (s *GenerateCacheArtifactMultipartUploadURLNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ListOrganizationsUnauthorized to nil") + return errors.New("invalid: unable to decode GenerateCacheArtifactMultipartUploadURLNotFound to nil") } var unwrapped Error if err := func() error { @@ -6750,34 +6610,34 @@ func (s *ListOrganizationsUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ListOrganizationsUnauthorized(unwrapped) + *s = GenerateCacheArtifactMultipartUploadURLNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ListOrganizationsUnauthorized) MarshalJSON() ([]byte, error) { +func (s *GenerateCacheArtifactMultipartUploadURLNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ListOrganizationsUnauthorized) UnmarshalJSON(data []byte) error { +func (s *GenerateCacheArtifactMultipartUploadURLNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ListProjectTokensForbidden as json. -func (s *ListProjectTokensForbidden) Encode(e *jx.Encoder) { +// Encode encodes GenerateCacheArtifactMultipartUploadURLPaymentRequired as json. +func (s *GenerateCacheArtifactMultipartUploadURLPaymentRequired) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ListProjectTokensForbidden from json. -func (s *ListProjectTokensForbidden) Decode(d *jx.Decoder) error { +// Decode decodes GenerateCacheArtifactMultipartUploadURLPaymentRequired from json. +func (s *GenerateCacheArtifactMultipartUploadURLPaymentRequired) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ListProjectTokensForbidden to nil") + return errors.New("invalid: unable to decode GenerateCacheArtifactMultipartUploadURLPaymentRequired to nil") } var unwrapped Error if err := func() error { @@ -6788,34 +6648,34 @@ func (s *ListProjectTokensForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ListProjectTokensForbidden(unwrapped) + *s = GenerateCacheArtifactMultipartUploadURLPaymentRequired(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ListProjectTokensForbidden) MarshalJSON() ([]byte, error) { +func (s *GenerateCacheArtifactMultipartUploadURLPaymentRequired) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ListProjectTokensForbidden) UnmarshalJSON(data []byte) error { +func (s *GenerateCacheArtifactMultipartUploadURLPaymentRequired) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ListProjectTokensNotFound as json. -func (s *ListProjectTokensNotFound) Encode(e *jx.Encoder) { +// Encode encodes GenerateCacheArtifactMultipartUploadURLUnauthorized as json. +func (s *GenerateCacheArtifactMultipartUploadURLUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ListProjectTokensNotFound from json. -func (s *ListProjectTokensNotFound) Decode(d *jx.Decoder) error { +// Decode decodes GenerateCacheArtifactMultipartUploadURLUnauthorized from json. +func (s *GenerateCacheArtifactMultipartUploadURLUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ListProjectTokensNotFound to nil") + return errors.New("invalid: unable to decode GenerateCacheArtifactMultipartUploadURLUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -6826,140 +6686,72 @@ func (s *ListProjectTokensNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ListProjectTokensNotFound(unwrapped) + *s = GenerateCacheArtifactMultipartUploadURLUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ListProjectTokensNotFound) MarshalJSON() ([]byte, error) { +func (s *GenerateCacheArtifactMultipartUploadURLUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ListProjectTokensNotFound) UnmarshalJSON(data []byte) error { +func (s *GenerateCacheArtifactMultipartUploadURLUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *ListProjectTokensOK) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *ListProjectTokensOK) encodeFields(e *jx.Encoder) { - { - e.FieldStart("tokens") - e.ArrStart() - for _, elem := range s.Tokens { - elem.Encode(e) - } - e.ArrEnd() - } -} +// Encode encodes GeneratePreviewsMultipartUploadURLForbidden as json. +func (s *GeneratePreviewsMultipartUploadURLForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) -var jsonFieldsNameOfListProjectTokensOK = [1]string{ - 0: "tokens", + unwrapped.Encode(e) } -// Decode decodes ListProjectTokensOK from json. -func (s *ListProjectTokensOK) Decode(d *jx.Decoder) error { +// Decode decodes GeneratePreviewsMultipartUploadURLForbidden from json. +func (s *GeneratePreviewsMultipartUploadURLForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ListProjectTokensOK to nil") + return errors.New("invalid: unable to decode GeneratePreviewsMultipartUploadURLForbidden to nil") } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "tokens": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - s.Tokens = make([]ProjectToken, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem ProjectToken - if err := elem.Decode(d); err != nil { - return err - } - s.Tokens = append(s.Tokens, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"tokens\"") - } - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } return nil - }); err != nil { - return errors.Wrap(err, "decode ListProjectTokensOK") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000001, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfListProjectTokensOK) { - name = jsonFieldsNameOfListProjectTokensOK[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = GeneratePreviewsMultipartUploadURLForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ListProjectTokensOK) MarshalJSON() ([]byte, error) { +func (s *GeneratePreviewsMultipartUploadURLForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ListProjectTokensOK) UnmarshalJSON(data []byte) error { +func (s *GeneratePreviewsMultipartUploadURLForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ListProjectTokensUnauthorized as json. -func (s *ListProjectTokensUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes GeneratePreviewsMultipartUploadURLNotFound as json. +func (s *GeneratePreviewsMultipartUploadURLNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ListProjectTokensUnauthorized from json. -func (s *ListProjectTokensUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes GeneratePreviewsMultipartUploadURLNotFound from json. +func (s *GeneratePreviewsMultipartUploadURLNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ListProjectTokensUnauthorized to nil") + return errors.New("invalid: unable to decode GeneratePreviewsMultipartUploadURLNotFound to nil") } var unwrapped Error if err := func() error { @@ -6970,84 +6762,89 @@ func (s *ListProjectTokensUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ListProjectTokensUnauthorized(unwrapped) + *s = GeneratePreviewsMultipartUploadURLNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ListProjectTokensUnauthorized) MarshalJSON() ([]byte, error) { +func (s *GeneratePreviewsMultipartUploadURLNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ListProjectTokensUnauthorized) UnmarshalJSON(data []byte) error { +func (s *GeneratePreviewsMultipartUploadURLNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *ListProjectsOK) Encode(e *jx.Encoder) { +func (s *GeneratePreviewsMultipartUploadURLReq) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *ListProjectsOK) encodeFields(e *jx.Encoder) { +func (s *GeneratePreviewsMultipartUploadURLReq) encodeFields(e *jx.Encoder) { { - e.FieldStart("projects") - e.ArrStart() - for _, elem := range s.Projects { - elem.Encode(e) - } - e.ArrEnd() + e.FieldStart("multipart_upload_part") + s.MultipartUploadPart.Encode(e) + } + { + e.FieldStart("preview_id") + e.Str(s.PreviewID) } } -var jsonFieldsNameOfListProjectsOK = [1]string{ - 0: "projects", +var jsonFieldsNameOfGeneratePreviewsMultipartUploadURLReq = [2]string{ + 0: "multipart_upload_part", + 1: "preview_id", } -// Decode decodes ListProjectsOK from json. -func (s *ListProjectsOK) Decode(d *jx.Decoder) error { +// Decode decodes GeneratePreviewsMultipartUploadURLReq from json. +func (s *GeneratePreviewsMultipartUploadURLReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ListProjectsOK to nil") + return errors.New("invalid: unable to decode GeneratePreviewsMultipartUploadURLReq to nil") } var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "projects": + case "multipart_upload_part": requiredBitSet[0] |= 1 << 0 if err := func() error { - s.Projects = make([]Project, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem Project - if err := elem.Decode(d); err != nil { - return err - } - s.Projects = append(s.Projects, elem) - return nil - }); err != nil { + if err := s.MultipartUploadPart.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"projects\"") + return errors.Wrap(err, "decode field \"multipart_upload_part\"") + } + case "preview_id": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.PreviewID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"preview_id\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode ListProjectsOK") + return errors.Wrap(err, "decode GeneratePreviewsMultipartUploadURLReq") } // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00000001, + 0b00000011, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -7059,8 +6856,8 @@ func (s *ListProjectsOK) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfListProjectsOK) { - name = jsonFieldsNameOfListProjectsOK[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfGeneratePreviewsMultipartUploadURLReq) { + name = jsonFieldsNameOfGeneratePreviewsMultipartUploadURLReq[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -7081,1247 +6878,1359 @@ func (s *ListProjectsOK) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *ListProjectsOK) MarshalJSON() ([]byte, error) { +func (s *GeneratePreviewsMultipartUploadURLReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ListProjectsOK) UnmarshalJSON(data []byte) error { +func (s *GeneratePreviewsMultipartUploadURLReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *Module) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *Module) encodeFields(e *jx.Encoder) { - { - e.FieldStart("hash") - e.Str(s.Hash) - } - { - e.FieldStart("name") - e.Str(s.Name) - } - { - e.FieldStart("project_identifier") - e.Str(s.ProjectIdentifier) - } -} +// Encode encodes GeneratePreviewsMultipartUploadURLUnauthorized as json. +func (s *GeneratePreviewsMultipartUploadURLUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) -var jsonFieldsNameOfModule = [3]string{ - 0: "hash", - 1: "name", - 2: "project_identifier", + unwrapped.Encode(e) } -// Decode decodes Module from json. -func (s *Module) Decode(d *jx.Decoder) error { +// Decode decodes GeneratePreviewsMultipartUploadURLUnauthorized from json. +func (s *GeneratePreviewsMultipartUploadURLUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode Module to nil") + return errors.New("invalid: unable to decode GeneratePreviewsMultipartUploadURLUnauthorized to nil") } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "hash": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - v, err := d.Str() - s.Hash = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"hash\"") - } - case "name": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - v, err := d.Str() - s.Name = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"name\"") - } - case "project_identifier": - requiredBitSet[0] |= 1 << 2 - if err := func() error { - v, err := d.Str() - s.ProjectIdentifier = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"project_identifier\"") - } - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } return nil - }); err != nil { - return errors.Wrap(err, "decode Module") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000111, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfModule) { - name = jsonFieldsNameOfModule[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = GeneratePreviewsMultipartUploadURLUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *Module) MarshalJSON() ([]byte, error) { +func (s *GeneratePreviewsMultipartUploadURLUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *Module) UnmarshalJSON(data []byte) error { +func (s *GeneratePreviewsMultipartUploadURLUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes AuthenticateReq as json. -func (o OptAuthenticateReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode encodes GetCacheActionItemForbidden as json. +func (s *GetCacheActionItemForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes AuthenticateReq from json. -func (o *OptAuthenticateReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptAuthenticateReq to nil") +// Decode decodes GetCacheActionItemForbidden from json. +func (s *GetCacheActionItemForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetCacheActionItemForbidden to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = GetCacheActionItemForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptAuthenticateReq) MarshalJSON() ([]byte, error) { +func (s *GetCacheActionItemForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptAuthenticateReq) UnmarshalJSON(data []byte) error { +func (s *GetCacheActionItemForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CacheArtifactExistsOKStatus as json. -func (o OptCacheArtifactExistsOKStatus) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode encodes GetCacheActionItemNotFound as json. +func (s *GetCacheActionItemNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes CacheArtifactExistsOKStatus from json. -func (o *OptCacheArtifactExistsOKStatus) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCacheArtifactExistsOKStatus to nil") +// Decode decodes GetCacheActionItemNotFound from json. +func (s *GetCacheActionItemNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetCacheActionItemNotFound to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = GetCacheActionItemNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptCacheArtifactExistsOKStatus) MarshalJSON() ([]byte, error) { +func (s *GetCacheActionItemNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCacheArtifactExistsOKStatus) UnmarshalJSON(data []byte) error { +func (s *GetCacheActionItemNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteAnalyticsArtifactMultipartUploadReq as json. -func (o OptCompleteAnalyticsArtifactMultipartUploadReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode encodes GetCacheActionItemPaymentRequired as json. +func (s *GetCacheActionItemPaymentRequired) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes CompleteAnalyticsArtifactMultipartUploadReq from json. -func (o *OptCompleteAnalyticsArtifactMultipartUploadReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCompleteAnalyticsArtifactMultipartUploadReq to nil") +// Decode decodes GetCacheActionItemPaymentRequired from json. +func (s *GetCacheActionItemPaymentRequired) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetCacheActionItemPaymentRequired to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = GetCacheActionItemPaymentRequired(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptCompleteAnalyticsArtifactMultipartUploadReq) MarshalJSON() ([]byte, error) { +func (s *GetCacheActionItemPaymentRequired) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCompleteAnalyticsArtifactMultipartUploadReq) UnmarshalJSON(data []byte) error { +func (s *GetCacheActionItemPaymentRequired) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteAnalyticsArtifactsUploadsReq as json. -func (o OptCompleteAnalyticsArtifactsUploadsReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode encodes GetCacheActionItemUnauthorized as json. +func (s *GetCacheActionItemUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes CompleteAnalyticsArtifactsUploadsReq from json. -func (o *OptCompleteAnalyticsArtifactsUploadsReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCompleteAnalyticsArtifactsUploadsReq to nil") +// Decode decodes GetCacheActionItemUnauthorized from json. +func (s *GetCacheActionItemUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetCacheActionItemUnauthorized to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = GetCacheActionItemUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptCompleteAnalyticsArtifactsUploadsReq) MarshalJSON() ([]byte, error) { +func (s *GetCacheActionItemUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCompleteAnalyticsArtifactsUploadsReq) UnmarshalJSON(data []byte) error { +func (s *GetCacheActionItemUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompleteCacheArtifactMultipartUploadOKStatus as json. -func (o OptCompleteCacheArtifactMultipartUploadOKStatus) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) -} - -// Decode decodes CompleteCacheArtifactMultipartUploadOKStatus from json. -func (o *OptCompleteCacheArtifactMultipartUploadOKStatus) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCompleteCacheArtifactMultipartUploadOKStatus to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err - } - return nil +// Encode implements json.Marshaler. +func (s *GetDeviceCodeAccepted) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// MarshalJSON implements stdjson.Marshaler. -func (s OptCompleteCacheArtifactMultipartUploadOKStatus) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil +// encodeFields encodes fields. +func (s *GetDeviceCodeAccepted) encodeFields(e *jx.Encoder) { } -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCompleteCacheArtifactMultipartUploadOKStatus) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} +var jsonFieldsNameOfGetDeviceCodeAccepted = [0]string{} -// Encode encodes CompleteCacheArtifactMultipartUploadReq as json. -func (o OptCompleteCacheArtifactMultipartUploadReq) Encode(e *jx.Encoder) { - if !o.Set { - return +// Decode decodes GetDeviceCodeAccepted from json. +func (s *GetDeviceCodeAccepted) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetDeviceCodeAccepted to nil") } - o.Value.Encode(e) -} -// Decode decodes CompleteCacheArtifactMultipartUploadReq from json. -func (o *OptCompleteCacheArtifactMultipartUploadReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCompleteCacheArtifactMultipartUploadReq to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + default: + return d.Skip() + } + }); err != nil { + return errors.Wrap(err, "decode GetDeviceCodeAccepted") } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptCompleteCacheArtifactMultipartUploadReq) MarshalJSON() ([]byte, error) { +func (s *GetDeviceCodeAccepted) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCompleteCacheArtifactMultipartUploadReq) UnmarshalJSON(data []byte) error { +func (s *GetDeviceCodeAccepted) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CompletePreviewsMultipartUploadReq as json. -func (o OptCompletePreviewsMultipartUploadReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode implements json.Marshaler. +func (s *GetDeviceCodeOK) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes CompletePreviewsMultipartUploadReq from json. -func (o *OptCompletePreviewsMultipartUploadReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCompletePreviewsMultipartUploadReq to nil") +// encodeFields encodes fields. +func (s *GetDeviceCodeOK) encodeFields(e *jx.Encoder) { + { + if s.AccessToken.Set { + e.FieldStart("access_token") + s.AccessToken.Encode(e) + } } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + { + if s.RefreshToken.Set { + e.FieldStart("refresh_token") + s.RefreshToken.Encode(e) + } + } + { + if s.Token.Set { + e.FieldStart("token") + s.Token.Encode(e) + } } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptCompletePreviewsMultipartUploadReq) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil } -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCompletePreviewsMultipartUploadReq) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) +var jsonFieldsNameOfGetDeviceCodeOK = [3]string{ + 0: "access_token", + 1: "refresh_token", + 2: "token", } -// Encode encodes CreateCommandEventReq as json. -func (o OptCreateCommandEventReq) Encode(e *jx.Encoder) { - if !o.Set { - return +// Decode decodes GetDeviceCodeOK from json. +func (s *GetDeviceCodeOK) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode GetDeviceCodeOK to nil") } - o.Value.Encode(e) -} -// Decode decodes CreateCommandEventReq from json. -func (o *OptCreateCommandEventReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCreateCommandEventReq to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "access_token": + if err := func() error { + s.AccessToken.Reset() + if err := s.AccessToken.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"access_token\"") + } + case "refresh_token": + if err := func() error { + s.RefreshToken.Reset() + if err := s.RefreshToken.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"refresh_token\"") + } + case "token": + if err := func() error { + s.Token.Reset() + if err := s.Token.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"token\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode GetDeviceCodeOK") } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptCreateCommandEventReq) MarshalJSON() ([]byte, error) { +func (s *GetDeviceCodeOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCreateCommandEventReq) UnmarshalJSON(data []byte) error { +func (s *GetDeviceCodeOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateCommandEventReqParams as json. -func (o OptCreateCommandEventReqParams) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode implements json.Marshaler. +func (s *Invitation) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes CreateCommandEventReqParams from json. -func (o *OptCreateCommandEventReqParams) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCreateCommandEventReqParams to nil") +// encodeFields encodes fields. +func (s *Invitation) encodeFields(e *jx.Encoder) { + { + e.FieldStart("id") + e.Float64(s.ID) } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + { + e.FieldStart("invitee_email") + e.Str(s.InviteeEmail) + } + { + e.FieldStart("inviter") + s.Inviter.Encode(e) + } + { + e.FieldStart("organization_id") + e.Float64(s.OrganizationID) + } + { + e.FieldStart("token") + e.Str(s.Token) } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptCreateCommandEventReqParams) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil } -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCreateCommandEventReqParams) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) +var jsonFieldsNameOfInvitation = [5]string{ + 0: "id", + 1: "invitee_email", + 2: "inviter", + 3: "organization_id", + 4: "token", } -// Encode encodes CreateCommandEventReqStatus as json. -func (o OptCreateCommandEventReqStatus) Encode(e *jx.Encoder) { - if !o.Set { - return +// Decode decodes Invitation from json. +func (s *Invitation) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Invitation to nil") } - e.Str(string(o.Value)) -} + var requiredBitSet [1]uint8 -// Decode decodes CreateCommandEventReqStatus from json. -func (o *OptCreateCommandEventReqStatus) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCreateCommandEventReqStatus to nil") + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Float64() + s.ID = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "invitee_email": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.InviteeEmail = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"invitee_email\"") + } + case "inviter": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + if err := s.Inviter.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"inviter\"") + } + case "organization_id": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + v, err := d.Float64() + s.OrganizationID = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"organization_id\"") + } + case "token": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + v, err := d.Str() + s.Token = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"token\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Invitation") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00011111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfInvitation) { + name = jsonFieldsNameOfInvitation[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptCreateCommandEventReqStatus) MarshalJSON() ([]byte, error) { +func (s *Invitation) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCreateCommandEventReqStatus) UnmarshalJSON(data []byte) error { +func (s *Invitation) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateInvitationReq as json. -func (o OptCreateInvitationReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode encodes ListOrganizationsForbidden as json. +func (s *ListOrganizationsForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes CreateInvitationReq from json. -func (o *OptCreateInvitationReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCreateInvitationReq to nil") +// Decode decodes ListOrganizationsForbidden from json. +func (s *ListOrganizationsForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListOrganizationsForbidden to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = ListOrganizationsForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptCreateInvitationReq) MarshalJSON() ([]byte, error) { +func (s *ListOrganizationsForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCreateInvitationReq) UnmarshalJSON(data []byte) error { +func (s *ListOrganizationsForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes CreateOrganizationReq as json. -func (o OptCreateOrganizationReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode implements json.Marshaler. +func (s *ListOrganizationsOK) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes CreateOrganizationReq from json. -func (o *OptCreateOrganizationReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCreateOrganizationReq to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err +// encodeFields encodes fields. +func (s *ListOrganizationsOK) encodeFields(e *jx.Encoder) { + { + e.FieldStart("organizations") + e.ArrStart() + for _, elem := range s.Organizations { + elem.Encode(e) + } + e.ArrEnd() } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptCreateOrganizationReq) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil } -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCreateOrganizationReq) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) +var jsonFieldsNameOfListOrganizationsOK = [1]string{ + 0: "organizations", } -// Encode encodes CreateProjectReq as json. -func (o OptCreateProjectReq) Encode(e *jx.Encoder) { - if !o.Set { - return +// Decode decodes ListOrganizationsOK from json. +func (s *ListOrganizationsOK) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListOrganizationsOK to nil") } - o.Value.Encode(e) -} + var requiredBitSet [1]uint8 -// Decode decodes CreateProjectReq from json. -func (o *OptCreateProjectReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptCreateProjectReq to nil") + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "organizations": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + s.Organizations = make([]Organization, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem Organization + if err := elem.Decode(d); err != nil { + return err + } + s.Organizations = append(s.Organizations, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"organizations\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ListOrganizationsOK") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfListOrganizationsOK) { + name = jsonFieldsNameOfListOrganizationsOK[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptCreateProjectReq) MarshalJSON() ([]byte, error) { +func (s *ListOrganizationsOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptCreateProjectReq) UnmarshalJSON(data []byte) error { +func (s *ListOrganizationsOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GenerateAnalyticsArtifactMultipartUploadURLReq as json. -func (o OptGenerateAnalyticsArtifactMultipartUploadURLReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode encodes ListOrganizationsUnauthorized as json. +func (s *ListOrganizationsUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLReq from json. -func (o *OptGenerateAnalyticsArtifactMultipartUploadURLReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptGenerateAnalyticsArtifactMultipartUploadURLReq to nil") +// Decode decodes ListOrganizationsUnauthorized from json. +func (s *ListOrganizationsUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListOrganizationsUnauthorized to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = ListOrganizationsUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptGenerateAnalyticsArtifactMultipartUploadURLReq) MarshalJSON() ([]byte, error) { +func (s *ListOrganizationsUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptGenerateAnalyticsArtifactMultipartUploadURLReq) UnmarshalJSON(data []byte) error { +func (s *ListOrganizationsUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes GeneratePreviewsMultipartUploadURLReq as json. -func (o OptGeneratePreviewsMultipartUploadURLReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode encodes ListPreviewsForbidden as json. +func (s *ListPreviewsForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes GeneratePreviewsMultipartUploadURLReq from json. -func (o *OptGeneratePreviewsMultipartUploadURLReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptGeneratePreviewsMultipartUploadURLReq to nil") +// Decode decodes ListPreviewsForbidden from json. +func (s *ListPreviewsForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListPreviewsForbidden to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = ListPreviewsForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptGeneratePreviewsMultipartUploadURLReq) MarshalJSON() ([]byte, error) { +func (s *ListPreviewsForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptGeneratePreviewsMultipartUploadURLReq) UnmarshalJSON(data []byte) error { +func (s *ListPreviewsForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes int as json. -func (o OptInt) Encode(e *jx.Encoder) { - if !o.Set { - return +// Encode implements json.Marshaler. +func (s *ListPreviewsOK) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ListPreviewsOK) encodeFields(e *jx.Encoder) { + { + e.FieldStart("previews") + e.ArrStart() + for _, elem := range s.Previews { + elem.Encode(e) + } + e.ArrEnd() } - e.Int(int(o.Value)) } -// Decode decodes int from json. -func (o *OptInt) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptInt to nil") +var jsonFieldsNameOfListPreviewsOK = [1]string{ + 0: "previews", +} + +// Decode decodes ListPreviewsOK from json. +func (s *ListPreviewsOK) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListPreviewsOK to nil") } - o.Set = true - v, err := d.Int() - if err != nil { - return err + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "previews": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + s.Previews = make([]Preview, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem Preview + if err := elem.Decode(d); err != nil { + return err + } + s.Previews = append(s.Previews, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"previews\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ListPreviewsOK") } - o.Value = int(v) + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfListPreviewsOK) { + name = jsonFieldsNameOfListPreviewsOK[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptInt) MarshalJSON() ([]byte, error) { +func (s *ListPreviewsOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptInt) UnmarshalJSON(data []byte) error { +func (s *ListPreviewsOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes string as json. -func (o OptNilString) Encode(e *jx.Encoder) { - if !o.Set { - return - } - if o.Null { - e.Null() - return - } - e.Str(string(o.Value)) +// Encode encodes ListPreviewsUnauthorized as json. +func (s *ListPreviewsUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes string from json. -func (o *OptNilString) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptNilString to nil") +// Decode decodes ListPreviewsUnauthorized from json. +func (s *ListPreviewsUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListPreviewsUnauthorized to nil") } - if d.Next() == jx.Null { - if err := d.Null(); err != nil { + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { return err } - - var v string - o.Value = v - o.Set = true - o.Null = true return nil + }(); err != nil { + return errors.Wrap(err, "alias") } - o.Set = true - o.Null = false - v, err := d.Str() - if err != nil { - return err - } - o.Value = string(v) + *s = ListPreviewsUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptNilString) MarshalJSON() ([]byte, error) { +func (s *ListPreviewsUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptNilString) UnmarshalJSON(data []byte) error { +func (s *ListPreviewsUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes OrganizationSSOProvider as json. -func (o OptOrganizationSSOProvider) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode encodes ListProjectTokensForbidden as json. +func (s *ListProjectTokensForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes OrganizationSSOProvider from json. -func (o *OptOrganizationSSOProvider) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptOrganizationSSOProvider to nil") +// Decode decodes ListProjectTokensForbidden from json. +func (s *ListProjectTokensForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListProjectTokensForbidden to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = ListProjectTokensForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptOrganizationSSOProvider) MarshalJSON() ([]byte, error) { +func (s *ListProjectTokensForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptOrganizationSSOProvider) UnmarshalJSON(data []byte) error { +func (s *ListProjectTokensForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes RefreshTokenReq as json. -func (o OptRefreshTokenReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode encodes ListProjectTokensNotFound as json. +func (s *ListProjectTokensNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes RefreshTokenReq from json. -func (o *OptRefreshTokenReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptRefreshTokenReq to nil") +// Decode decodes ListProjectTokensNotFound from json. +func (s *ListProjectTokensNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListProjectTokensNotFound to nil") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = ListProjectTokensNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptRefreshTokenReq) MarshalJSON() ([]byte, error) { +func (s *ListProjectTokensNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptRefreshTokenReq) UnmarshalJSON(data []byte) error { +func (s *ListProjectTokensNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartPreviewsMultipartUploadReq as json. -func (o OptStartPreviewsMultipartUploadReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode implements json.Marshaler. +func (s *ListProjectTokensOK) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes StartPreviewsMultipartUploadReq from json. -func (o *OptStartPreviewsMultipartUploadReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptStartPreviewsMultipartUploadReq to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err +// encodeFields encodes fields. +func (s *ListProjectTokensOK) encodeFields(e *jx.Encoder) { + { + e.FieldStart("tokens") + e.ArrStart() + for _, elem := range s.Tokens { + elem.Encode(e) + } + e.ArrEnd() } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptStartPreviewsMultipartUploadReq) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil } -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptStartPreviewsMultipartUploadReq) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) +var jsonFieldsNameOfListProjectTokensOK = [1]string{ + 0: "tokens", } -// Encode encodes StartPreviewsMultipartUploadReqType as json. -func (o OptStartPreviewsMultipartUploadReqType) Encode(e *jx.Encoder) { - if !o.Set { - return +// Decode decodes ListProjectTokensOK from json. +func (s *ListProjectTokensOK) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListProjectTokensOK to nil") } - e.Str(string(o.Value)) -} + var requiredBitSet [1]uint8 -// Decode decodes StartPreviewsMultipartUploadReqType from json. -func (o *OptStartPreviewsMultipartUploadReqType) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptStartPreviewsMultipartUploadReqType to nil") + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "tokens": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + s.Tokens = make([]ProjectToken, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem ProjectToken + if err := elem.Decode(d); err != nil { + return err + } + s.Tokens = append(s.Tokens, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"tokens\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ListProjectTokensOK") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfListProjectTokensOK) { + name = jsonFieldsNameOfListProjectTokensOK[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptStartPreviewsMultipartUploadReqType) MarshalJSON() ([]byte, error) { +func (s *ListProjectTokensOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptStartPreviewsMultipartUploadReqType) UnmarshalJSON(data []byte) error { +func (s *ListProjectTokensOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes string as json. -func (o OptString) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode encodes ListProjectTokensUnauthorized as json. +func (s *ListProjectTokensUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// Decode decodes string from json. -func (o *OptString) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptString to nil") +// Decode decodes ListProjectTokensUnauthorized from json. +func (s *ListProjectTokensUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListProjectTokensUnauthorized to nil") } - o.Set = true - v, err := d.Str() - if err != nil { - return err + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } - o.Value = string(v) + *s = ListProjectTokensUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptString) MarshalJSON() ([]byte, error) { +func (s *ListProjectTokensUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptString) UnmarshalJSON(data []byte) error { +func (s *ListProjectTokensUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes UpdateOrganization2Req as json. -func (o OptUpdateOrganization2Req) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode implements json.Marshaler. +func (s *ListProjectsOK) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes UpdateOrganization2Req from json. -func (o *OptUpdateOrganization2Req) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptUpdateOrganization2Req to nil") +// encodeFields encodes fields. +func (s *ListProjectsOK) encodeFields(e *jx.Encoder) { + { + e.FieldStart("projects") + e.ArrStart() + for _, elem := range s.Projects { + elem.Encode(e) + } + e.ArrEnd() } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err - } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptUpdateOrganization2Req) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil } -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptUpdateOrganization2Req) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) +var jsonFieldsNameOfListProjectsOK = [1]string{ + 0: "projects", } -// Encode encodes UpdateOrganization2ReqSSOProvider as json. -func (o OptUpdateOrganization2ReqSSOProvider) Encode(e *jx.Encoder) { - if !o.Set { - return +// Decode decodes ListProjectsOK from json. +func (s *ListProjectsOK) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListProjectsOK to nil") } - e.Str(string(o.Value)) -} + var requiredBitSet [1]uint8 -// Decode decodes UpdateOrganization2ReqSSOProvider from json. -func (o *OptUpdateOrganization2ReqSSOProvider) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptUpdateOrganization2ReqSSOProvider to nil") + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "projects": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + s.Projects = make([]Project, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem Project + if err := elem.Decode(d); err != nil { + return err + } + s.Projects = append(s.Projects, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"projects\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ListProjectsOK") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfListProjectsOK) { + name = jsonFieldsNameOfListProjectsOK[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptUpdateOrganization2ReqSSOProvider) MarshalJSON() ([]byte, error) { +func (s *ListProjectsOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptUpdateOrganization2ReqSSOProvider) UnmarshalJSON(data []byte) error { +func (s *ListProjectsOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes UpdateOrganizationMemberReq as json. -func (o OptUpdateOrganizationMemberReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) +// Encode implements json.Marshaler. +func (s *ListRunsOK) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes UpdateOrganizationMemberReq from json. -func (o *OptUpdateOrganizationMemberReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptUpdateOrganizationMemberReq to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err +// encodeFields encodes fields. +func (s *ListRunsOK) encodeFields(e *jx.Encoder) { + { + e.FieldStart("runs") + e.ArrStart() + for _, elem := range s.Runs { + elem.Encode(e) + } + e.ArrEnd() } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptUpdateOrganizationMemberReq) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil } -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptUpdateOrganizationMemberReq) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) +var jsonFieldsNameOfListRunsOK = [1]string{ + 0: "runs", } -// Encode encodes UpdateOrganizationReq as json. -func (o OptUpdateOrganizationReq) Encode(e *jx.Encoder) { - if !o.Set { - return +// Decode decodes ListRunsOK from json. +func (s *ListRunsOK) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ListRunsOK to nil") } - o.Value.Encode(e) -} + var requiredBitSet [1]uint8 -// Decode decodes UpdateOrganizationReq from json. -func (o *OptUpdateOrganizationReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptUpdateOrganizationReq to nil") + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "runs": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + s.Runs = make([]Run, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem Run + if err := elem.Decode(d); err != nil { + return err + } + s.Runs = append(s.Runs, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"runs\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ListRunsOK") } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfListRunsOK) { + name = jsonFieldsNameOfListRunsOK[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OptUpdateOrganizationReq) MarshalJSON() ([]byte, error) { +func (s *ListRunsOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptUpdateOrganizationReq) UnmarshalJSON(data []byte) error { +func (s *ListRunsOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes UpdateOrganizationReqSSOProvider as json. -func (o OptUpdateOrganizationReqSSOProvider) Encode(e *jx.Encoder) { - if !o.Set { - return - } - e.Str(string(o.Value)) +// Encode implements json.Marshaler. +func (s *Module) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes UpdateOrganizationReqSSOProvider from json. -func (o *OptUpdateOrganizationReqSSOProvider) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptUpdateOrganizationReqSSOProvider to nil") +// encodeFields encodes fields. +func (s *Module) encodeFields(e *jx.Encoder) { + { + e.FieldStart("hash") + e.Str(s.Hash) } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err + { + e.FieldStart("name") + e.Str(s.Name) + } + { + e.FieldStart("project_identifier") + e.Str(s.ProjectIdentifier) } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptUpdateOrganizationReqSSOProvider) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil } -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptUpdateOrganizationReqSSOProvider) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) +var jsonFieldsNameOfModule = [3]string{ + 0: "hash", + 1: "name", + 2: "project_identifier", } -// Encode encodes UpdateProjectReq as json. -func (o OptUpdateProjectReq) Encode(e *jx.Encoder) { - if !o.Set { - return +// Decode decodes Module from json. +func (s *Module) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Module to nil") } - o.Value.Encode(e) -} - -// Decode decodes UpdateProjectReq from json. -func (o *OptUpdateProjectReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptUpdateProjectReq to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err - } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptUpdateProjectReq) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptUpdateProjectReq) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes UploadCacheActionItemReq as json. -func (o OptUploadCacheActionItemReq) Encode(e *jx.Encoder) { - if !o.Set { - return - } - o.Value.Encode(e) -} - -// Decode decodes UploadCacheActionItemReq from json. -func (o *OptUploadCacheActionItemReq) Decode(d *jx.Decoder) error { - if o == nil { - return errors.New("invalid: unable to decode OptUploadCacheActionItemReq to nil") - } - o.Set = true - if err := o.Value.Decode(d); err != nil { - return err - } - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s OptUploadCacheActionItemReq) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OptUploadCacheActionItemReq) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode implements json.Marshaler. -func (s *Organization) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *Organization) encodeFields(e *jx.Encoder) { - { - e.FieldStart("id") - e.Float64(s.ID) - } - { - e.FieldStart("invitations") - e.ArrStart() - for _, elem := range s.Invitations { - elem.Encode(e) - } - e.ArrEnd() - } - { - e.FieldStart("members") - e.ArrStart() - for _, elem := range s.Members { - elem.Encode(e) - } - e.ArrEnd() - } - { - e.FieldStart("name") - e.Str(s.Name) - } - { - e.FieldStart("plan") - s.Plan.Encode(e) - } - { - if s.SSOOrganizationID.Set { - e.FieldStart("sso_organization_id") - s.SSOOrganizationID.Encode(e) - } - } - { - if s.SSOProvider.Set { - e.FieldStart("sso_provider") - s.SSOProvider.Encode(e) - } - } -} - -var jsonFieldsNameOfOrganization = [7]string{ - 0: "id", - 1: "invitations", - 2: "members", - 3: "name", - 4: "plan", - 5: "sso_organization_id", - 6: "sso_provider", -} - -// Decode decodes Organization from json. -func (s *Organization) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode Organization to nil") - } - var requiredBitSet [1]uint8 + var requiredBitSet [1]uint8 if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "id": + case "hash": requiredBitSet[0] |= 1 << 0 if err := func() error { - v, err := d.Float64() - s.ID = float64(v) + v, err := d.Str() + s.Hash = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"id\"") - } - case "invitations": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - s.Invitations = make([]Invitation, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem Invitation - if err := elem.Decode(d); err != nil { - return err - } - s.Invitations = append(s.Invitations, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"invitations\"") - } - case "members": - requiredBitSet[0] |= 1 << 2 - if err := func() error { - s.Members = make([]OrganizationMember, 0) - if err := d.Arr(func(d *jx.Decoder) error { - var elem OrganizationMember - if err := elem.Decode(d); err != nil { - return err - } - s.Members = append(s.Members, elem) - return nil - }); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"members\"") + return errors.Wrap(err, "decode field \"hash\"") } case "name": - requiredBitSet[0] |= 1 << 3 + requiredBitSet[0] |= 1 << 1 if err := func() error { v, err := d.Str() s.Name = string(v) @@ -8332,47 +8241,29 @@ func (s *Organization) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"name\"") } - case "plan": - requiredBitSet[0] |= 1 << 4 - if err := func() error { - if err := s.Plan.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"plan\"") - } - case "sso_organization_id": - if err := func() error { - s.SSOOrganizationID.Reset() - if err := s.SSOOrganizationID.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"sso_organization_id\"") - } - case "sso_provider": + case "project_identifier": + requiredBitSet[0] |= 1 << 2 if err := func() error { - s.SSOProvider.Reset() - if err := s.SSOProvider.Decode(d); err != nil { + v, err := d.Str() + s.ProjectIdentifier = string(v) + if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"sso_provider\"") + return errors.Wrap(err, "decode field \"project_identifier\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode Organization") + return errors.Wrap(err, "decode Module") } // Validate required fields. var failures []validate.FieldError for i, mask := range [1]uint8{ - 0b00011111, + 0b00000111, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -8384,8 +8275,8 @@ func (s *Organization) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfOrganization) { - name = jsonFieldsNameOfOrganization[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfModule) { + name = jsonFieldsNameOfModule[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -8406,500 +8297,3058 @@ func (s *Organization) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *Organization) MarshalJSON() ([]byte, error) { +func (s *Module) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *Organization) UnmarshalJSON(data []byte) error { +func (s *Module) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *OrganizationMember) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() +// Encode encodes AuthenticateReq as json. +func (o OptAuthenticateReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) } -// encodeFields encodes fields. -func (s *OrganizationMember) encodeFields(e *jx.Encoder) { - { - e.FieldStart("email") - e.Str(s.Email) - } - { - e.FieldStart("id") - e.Float64(s.ID) - } - { - e.FieldStart("name") - e.Str(s.Name) +// Decode decodes AuthenticateReq from json. +func (o *OptAuthenticateReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptAuthenticateReq to nil") } - { - e.FieldStart("role") - s.Role.Encode(e) + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err } + return nil } -var jsonFieldsNameOfOrganizationMember = [4]string{ - 0: "email", - 1: "id", - 2: "name", - 3: "role", -} - -// Decode decodes OrganizationMember from json. -func (s *OrganizationMember) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode OrganizationMember to nil") - } - var requiredBitSet [1]uint8 +// MarshalJSON implements stdjson.Marshaler. +func (s OptAuthenticateReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "email": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - v, err := d.Str() - s.Email = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"email\"") - } - case "id": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - v, err := d.Float64() - s.ID = float64(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"id\"") - } - case "name": - requiredBitSet[0] |= 1 << 2 - if err := func() error { - v, err := d.Str() - s.Name = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"name\"") - } - case "role": - requiredBitSet[0] |= 1 << 3 - if err := func() error { - if err := s.Role.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"role\"") - } - default: - return d.Skip() - } - return nil - }); err != nil { - return errors.Wrap(err, "decode OrganizationMember") +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptAuthenticateReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CacheArtifactExistsOKStatus as json. +func (o OptCacheArtifactExistsOKStatus) Encode(e *jx.Encoder) { + if !o.Set { + return } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00001111, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfOrganizationMember) { - name = jsonFieldsNameOfOrganizationMember[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } + e.Str(string(o.Value)) +} + +// Decode decodes CacheArtifactExistsOKStatus from json. +func (o *OptCacheArtifactExistsOKStatus) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCacheArtifactExistsOKStatus to nil") } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err } - return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *OrganizationMember) MarshalJSON() ([]byte, error) { +func (s OptCacheArtifactExistsOKStatus) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OrganizationMember) UnmarshalJSON(data []byte) error { +func (s *OptCacheArtifactExistsOKStatus) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes OrganizationMemberRole as json. -func (s OrganizationMemberRole) Encode(e *jx.Encoder) { - e.Str(string(s)) +// Encode encodes CancelInvitationReq as json. +func (o OptCancelInvitationReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) } -// Decode decodes OrganizationMemberRole from json. -func (s *OrganizationMemberRole) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode OrganizationMemberRole to nil") +// Decode decodes CancelInvitationReq from json. +func (o *OptCancelInvitationReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCancelInvitationReq to nil") } - v, err := d.StrBytes() - if err != nil { + o.Set = true + if err := o.Value.Decode(d); err != nil { return err } - // Try to use constant string. - switch OrganizationMemberRole(v) { - case OrganizationMemberRoleAdmin: - *s = OrganizationMemberRoleAdmin - case OrganizationMemberRoleUser: - *s = OrganizationMemberRoleUser - default: - *s = OrganizationMemberRole(v) - } - return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OrganizationMemberRole) MarshalJSON() ([]byte, error) { +func (s OptCancelInvitationReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OrganizationMemberRole) UnmarshalJSON(data []byte) error { +func (s *OptCancelInvitationReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes OrganizationPlan as json. -func (s OrganizationPlan) Encode(e *jx.Encoder) { - e.Str(string(s)) +// Encode encodes CommandEventArtifact as json. +func (o OptCommandEventArtifact) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) } -// Decode decodes OrganizationPlan from json. -func (s *OrganizationPlan) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode OrganizationPlan to nil") +// Decode decodes CommandEventArtifact from json. +func (o *OptCommandEventArtifact) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCommandEventArtifact to nil") } - v, err := d.StrBytes() - if err != nil { + o.Set = true + if err := o.Value.Decode(d); err != nil { return err } - // Try to use constant string. - switch OrganizationPlan(v) { - case OrganizationPlanAir: - *s = OrganizationPlanAir - case OrganizationPlanPro: - *s = OrganizationPlanPro - case OrganizationPlanEnterprise: - *s = OrganizationPlanEnterprise - case OrganizationPlanNone: - *s = OrganizationPlanNone - default: - *s = OrganizationPlan(v) - } - return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OrganizationPlan) MarshalJSON() ([]byte, error) { +func (s OptCommandEventArtifact) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OrganizationPlan) UnmarshalJSON(data []byte) error { +func (s *OptCommandEventArtifact) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes OrganizationSSOProvider as json. -func (s OrganizationSSOProvider) Encode(e *jx.Encoder) { - e.Str(string(s)) +// Encode encodes CompleteAnalyticsArtifactMultipartUploadReq as json. +func (o OptCompleteAnalyticsArtifactMultipartUploadReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) } -// Decode decodes OrganizationSSOProvider from json. -func (s *OrganizationSSOProvider) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode OrganizationSSOProvider to nil") +// Decode decodes CompleteAnalyticsArtifactMultipartUploadReq from json. +func (o *OptCompleteAnalyticsArtifactMultipartUploadReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCompleteAnalyticsArtifactMultipartUploadReq to nil") } - v, err := d.StrBytes() - if err != nil { + o.Set = true + if err := o.Value.Decode(d); err != nil { return err } - // Try to use constant string. - switch OrganizationSSOProvider(v) { - case OrganizationSSOProviderGoogle: - *s = OrganizationSSOProviderGoogle - default: - *s = OrganizationSSOProvider(v) - } - return nil } // MarshalJSON implements stdjson.Marshaler. -func (s OrganizationSSOProvider) MarshalJSON() ([]byte, error) { +func (s OptCompleteAnalyticsArtifactMultipartUploadReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OrganizationSSOProvider) UnmarshalJSON(data []byte) error { +func (s *OptCompleteAnalyticsArtifactMultipartUploadReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *OrganizationUsage) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() +// Encode encodes CompleteAnalyticsArtifactsUploadsReq as json. +func (o OptCompleteAnalyticsArtifactsUploadsReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) } -// encodeFields encodes fields. -func (s *OrganizationUsage) encodeFields(e *jx.Encoder) { - { - e.FieldStart("current_month_remote_cache_hits") - e.Float64(s.CurrentMonthRemoteCacheHits) +// Decode decodes CompleteAnalyticsArtifactsUploadsReq from json. +func (o *OptCompleteAnalyticsArtifactsUploadsReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCompleteAnalyticsArtifactsUploadsReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err } + return nil } -var jsonFieldsNameOfOrganizationUsage = [1]string{ - 0: "current_month_remote_cache_hits", +// MarshalJSON implements stdjson.Marshaler. +func (s OptCompleteAnalyticsArtifactsUploadsReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil } -// Decode decodes OrganizationUsage from json. -func (s *OrganizationUsage) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode OrganizationUsage to nil") - } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "current_month_remote_cache_hits": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - v, err := d.Float64() - s.CurrentMonthRemoteCacheHits = float64(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"current_month_remote_cache_hits\"") - } - default: - return d.Skip() - } - return nil - }); err != nil { - return errors.Wrap(err, "decode OrganizationUsage") +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCompleteAnalyticsArtifactsUploadsReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CompleteCacheArtifactMultipartUploadOKStatus as json. +func (o OptCompleteCacheArtifactMultipartUploadOKStatus) Encode(e *jx.Encoder) { + if !o.Set { + return } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000001, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfOrganizationUsage) { - name = jsonFieldsNameOfOrganizationUsage[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } + e.Str(string(o.Value)) +} + +// Decode decodes CompleteCacheArtifactMultipartUploadOKStatus from json. +func (o *OptCompleteCacheArtifactMultipartUploadOKStatus) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCompleteCacheArtifactMultipartUploadOKStatus to nil") } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCompleteCacheArtifactMultipartUploadOKStatus) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCompleteCacheArtifactMultipartUploadOKStatus) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CompleteCacheArtifactMultipartUploadReq as json. +func (o OptCompleteCacheArtifactMultipartUploadReq) Encode(e *jx.Encoder) { + if !o.Set { + return } + o.Value.Encode(e) +} +// Decode decodes CompleteCacheArtifactMultipartUploadReq from json. +func (o *OptCompleteCacheArtifactMultipartUploadReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCompleteCacheArtifactMultipartUploadReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *OrganizationUsage) MarshalJSON() ([]byte, error) { +func (s OptCompleteCacheArtifactMultipartUploadReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *OrganizationUsage) UnmarshalJSON(data []byte) error { +func (s *OptCompleteCacheArtifactMultipartUploadReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *Project) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() +// Encode encodes CompletePreviewsMultipartUploadReq as json. +func (o OptCompletePreviewsMultipartUploadReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) } -// encodeFields encodes fields. -func (s *Project) encodeFields(e *jx.Encoder) { - { - e.FieldStart("default_branch") - e.Str(s.DefaultBranch) +// Decode decodes CompletePreviewsMultipartUploadReq from json. +func (o *OptCompletePreviewsMultipartUploadReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCompletePreviewsMultipartUploadReq to nil") } - { - e.FieldStart("full_name") - e.Str(s.FullName) + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err } - { - e.FieldStart("id") - e.Float64(s.ID) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCompletePreviewsMultipartUploadReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCompletePreviewsMultipartUploadReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateAccountTokenReq as json. +func (o OptCreateAccountTokenReq) Encode(e *jx.Encoder) { + if !o.Set { + return } - { - if s.RepositoryURL.Set { - e.FieldStart("repository_url") - s.RepositoryURL.Encode(e) - } + o.Value.Encode(e) +} + +// Decode decodes CreateAccountTokenReq from json. +func (o *OptCreateAccountTokenReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCreateAccountTokenReq to nil") } - { - e.FieldStart("token") - e.Str(s.Token) + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err } + return nil } -var jsonFieldsNameOfProject = [5]string{ - 0: "default_branch", - 1: "full_name", - 2: "id", - 3: "repository_url", - 4: "token", +// MarshalJSON implements stdjson.Marshaler. +func (s OptCreateAccountTokenReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil } -// Decode decodes Project from json. -func (s *Project) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode Project to nil") +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCreateAccountTokenReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateCommandEventReq as json. +func (o OptCreateCommandEventReq) Encode(e *jx.Encoder) { + if !o.Set { + return } - var requiredBitSet [1]uint8 + o.Value.Encode(e) +} - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "default_branch": - requiredBitSet[0] |= 1 << 0 +// Decode decodes CreateCommandEventReq from json. +func (o *OptCreateCommandEventReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCreateCommandEventReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCreateCommandEventReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCreateCommandEventReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateCommandEventReqParams as json. +func (o OptCreateCommandEventReqParams) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes CreateCommandEventReqParams from json. +func (o *OptCreateCommandEventReqParams) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCreateCommandEventReqParams to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCreateCommandEventReqParams) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCreateCommandEventReqParams) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateCommandEventReqStatus as json. +func (o OptCreateCommandEventReqStatus) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes CreateCommandEventReqStatus from json. +func (o *OptCreateCommandEventReqStatus) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCreateCommandEventReqStatus to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCreateCommandEventReqStatus) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCreateCommandEventReqStatus) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateInvitationReq as json. +func (o OptCreateInvitationReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes CreateInvitationReq from json. +func (o *OptCreateInvitationReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCreateInvitationReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCreateInvitationReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCreateInvitationReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateOrganizationReq as json. +func (o OptCreateOrganizationReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes CreateOrganizationReq from json. +func (o *OptCreateOrganizationReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCreateOrganizationReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCreateOrganizationReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCreateOrganizationReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes CreateProjectReq as json. +func (o OptCreateProjectReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes CreateProjectReq from json. +func (o *OptCreateProjectReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptCreateProjectReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptCreateProjectReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptCreateProjectReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes GenerateAnalyticsArtifactMultipartUploadURLReq as json. +func (o OptGenerateAnalyticsArtifactMultipartUploadURLReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes GenerateAnalyticsArtifactMultipartUploadURLReq from json. +func (o *OptGenerateAnalyticsArtifactMultipartUploadURLReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptGenerateAnalyticsArtifactMultipartUploadURLReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptGenerateAnalyticsArtifactMultipartUploadURLReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptGenerateAnalyticsArtifactMultipartUploadURLReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes GeneratePreviewsMultipartUploadURLReq as json. +func (o OptGeneratePreviewsMultipartUploadURLReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes GeneratePreviewsMultipartUploadURLReq from json. +func (o *OptGeneratePreviewsMultipartUploadURLReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptGeneratePreviewsMultipartUploadURLReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptGeneratePreviewsMultipartUploadURLReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptGeneratePreviewsMultipartUploadURLReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes int as json. +func (o OptInt) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Int(int(o.Value)) +} + +// Decode decodes int from json. +func (o *OptInt) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptInt to nil") + } + o.Set = true + v, err := d.Int() + if err != nil { + return err + } + o.Value = int(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptInt) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptInt) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes string as json. +func (o OptNilString) Encode(e *jx.Encoder) { + if !o.Set { + return + } + if o.Null { + e.Null() + return + } + e.Str(string(o.Value)) +} + +// Decode decodes string from json. +func (o *OptNilString) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptNilString to nil") + } + if d.Next() == jx.Null { + if err := d.Null(); err != nil { + return err + } + + var v string + o.Value = v + o.Set = true + o.Null = true + return nil + } + o.Set = true + o.Null = false + v, err := d.Str() + if err != nil { + return err + } + o.Value = string(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptNilString) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptNilString) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes OrganizationSSOProvider as json. +func (o OptOrganizationSSOProvider) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes OrganizationSSOProvider from json. +func (o *OptOrganizationSSOProvider) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptOrganizationSSOProvider to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptOrganizationSSOProvider) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptOrganizationSSOProvider) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes RefreshTokenReq as json. +func (o OptRefreshTokenReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes RefreshTokenReq from json. +func (o *OptRefreshTokenReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptRefreshTokenReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptRefreshTokenReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptRefreshTokenReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes StartPreviewsMultipartUploadReq as json. +func (o OptStartPreviewsMultipartUploadReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes StartPreviewsMultipartUploadReq from json. +func (o *OptStartPreviewsMultipartUploadReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptStartPreviewsMultipartUploadReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptStartPreviewsMultipartUploadReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptStartPreviewsMultipartUploadReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes StartPreviewsMultipartUploadReqType as json. +func (o OptStartPreviewsMultipartUploadReqType) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes StartPreviewsMultipartUploadReqType from json. +func (o *OptStartPreviewsMultipartUploadReqType) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptStartPreviewsMultipartUploadReqType to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptStartPreviewsMultipartUploadReqType) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptStartPreviewsMultipartUploadReqType) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes string as json. +func (o OptString) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes string from json. +func (o *OptString) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptString to nil") + } + o.Set = true + v, err := d.Str() + if err != nil { + return err + } + o.Value = string(v) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptString) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptString) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateAccountReq as json. +func (o OptUpdateAccountReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes UpdateAccountReq from json. +func (o *OptUpdateAccountReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptUpdateAccountReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptUpdateAccountReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptUpdateAccountReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateOrganization2Req as json. +func (o OptUpdateOrganization2Req) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes UpdateOrganization2Req from json. +func (o *OptUpdateOrganization2Req) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptUpdateOrganization2Req to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptUpdateOrganization2Req) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptUpdateOrganization2Req) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateOrganization2ReqSSOProvider as json. +func (o OptUpdateOrganization2ReqSSOProvider) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes UpdateOrganization2ReqSSOProvider from json. +func (o *OptUpdateOrganization2ReqSSOProvider) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptUpdateOrganization2ReqSSOProvider to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptUpdateOrganization2ReqSSOProvider) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptUpdateOrganization2ReqSSOProvider) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateOrganizationMemberReq as json. +func (o OptUpdateOrganizationMemberReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes UpdateOrganizationMemberReq from json. +func (o *OptUpdateOrganizationMemberReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptUpdateOrganizationMemberReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptUpdateOrganizationMemberReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptUpdateOrganizationMemberReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateOrganizationReq as json. +func (o OptUpdateOrganizationReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes UpdateOrganizationReq from json. +func (o *OptUpdateOrganizationReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptUpdateOrganizationReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptUpdateOrganizationReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptUpdateOrganizationReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateOrganizationReqSSOProvider as json. +func (o OptUpdateOrganizationReqSSOProvider) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes UpdateOrganizationReqSSOProvider from json. +func (o *OptUpdateOrganizationReqSSOProvider) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptUpdateOrganizationReqSSOProvider to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptUpdateOrganizationReqSSOProvider) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptUpdateOrganizationReqSSOProvider) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateProjectReq as json. +func (o OptUpdateProjectReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes UpdateProjectReq from json. +func (o *OptUpdateProjectReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptUpdateProjectReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptUpdateProjectReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptUpdateProjectReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UpdateProjectReqVisibility as json. +func (o OptUpdateProjectReqVisibility) Encode(e *jx.Encoder) { + if !o.Set { + return + } + e.Str(string(o.Value)) +} + +// Decode decodes UpdateProjectReqVisibility from json. +func (o *OptUpdateProjectReqVisibility) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptUpdateProjectReqVisibility to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptUpdateProjectReqVisibility) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptUpdateProjectReqVisibility) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UploadCacheActionItemReq as json. +func (o OptUploadCacheActionItemReq) Encode(e *jx.Encoder) { + if !o.Set { + return + } + o.Value.Encode(e) +} + +// Decode decodes UploadCacheActionItemReq from json. +func (o *OptUploadCacheActionItemReq) Decode(d *jx.Decoder) error { + if o == nil { + return errors.New("invalid: unable to decode OptUploadCacheActionItemReq to nil") + } + o.Set = true + if err := o.Value.Decode(d); err != nil { + return err + } + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OptUploadCacheActionItemReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OptUploadCacheActionItemReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Organization) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Organization) encodeFields(e *jx.Encoder) { + { + e.FieldStart("id") + e.Float64(s.ID) + } + { + e.FieldStart("invitations") + e.ArrStart() + for _, elem := range s.Invitations { + elem.Encode(e) + } + e.ArrEnd() + } + { + e.FieldStart("members") + e.ArrStart() + for _, elem := range s.Members { + elem.Encode(e) + } + e.ArrEnd() + } + { + e.FieldStart("name") + e.Str(s.Name) + } + { + e.FieldStart("plan") + s.Plan.Encode(e) + } + { + if s.SSOOrganizationID.Set { + e.FieldStart("sso_organization_id") + s.SSOOrganizationID.Encode(e) + } + } + { + if s.SSOProvider.Set { + e.FieldStart("sso_provider") + s.SSOProvider.Encode(e) + } + } +} + +var jsonFieldsNameOfOrganization = [7]string{ + 0: "id", + 1: "invitations", + 2: "members", + 3: "name", + 4: "plan", + 5: "sso_organization_id", + 6: "sso_provider", +} + +// Decode decodes Organization from json. +func (s *Organization) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Organization to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Float64() + s.ID = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "invitations": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + s.Invitations = make([]Invitation, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem Invitation + if err := elem.Decode(d); err != nil { + return err + } + s.Invitations = append(s.Invitations, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"invitations\"") + } + case "members": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + s.Members = make([]OrganizationMember, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem OrganizationMember + if err := elem.Decode(d); err != nil { + return err + } + s.Members = append(s.Members, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"members\"") + } + case "name": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + v, err := d.Str() + s.Name = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + case "plan": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + if err := s.Plan.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"plan\"") + } + case "sso_organization_id": + if err := func() error { + s.SSOOrganizationID.Reset() + if err := s.SSOOrganizationID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sso_organization_id\"") + } + case "sso_provider": + if err := func() error { + s.SSOProvider.Reset() + if err := s.SSOProvider.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"sso_provider\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Organization") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00011111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfOrganization) { + name = jsonFieldsNameOfOrganization[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Organization) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Organization) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *OrganizationMember) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *OrganizationMember) encodeFields(e *jx.Encoder) { + { + e.FieldStart("email") + e.Str(s.Email) + } + { + e.FieldStart("id") + e.Float64(s.ID) + } + { + e.FieldStart("name") + e.Str(s.Name) + } + { + e.FieldStart("role") + s.Role.Encode(e) + } +} + +var jsonFieldsNameOfOrganizationMember = [4]string{ + 0: "email", + 1: "id", + 2: "name", + 3: "role", +} + +// Decode decodes OrganizationMember from json. +func (s *OrganizationMember) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode OrganizationMember to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "email": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.Email = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"email\"") + } + case "id": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Float64() + s.ID = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "name": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + v, err := d.Str() + s.Name = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + case "role": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + if err := s.Role.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"role\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode OrganizationMember") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00001111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfOrganizationMember) { + name = jsonFieldsNameOfOrganizationMember[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *OrganizationMember) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OrganizationMember) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes OrganizationMemberRole as json. +func (s OrganizationMemberRole) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes OrganizationMemberRole from json. +func (s *OrganizationMemberRole) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode OrganizationMemberRole to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch OrganizationMemberRole(v) { + case OrganizationMemberRoleAdmin: + *s = OrganizationMemberRoleAdmin + case OrganizationMemberRoleUser: + *s = OrganizationMemberRoleUser + default: + *s = OrganizationMemberRole(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OrganizationMemberRole) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OrganizationMemberRole) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes OrganizationPlan as json. +func (s OrganizationPlan) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes OrganizationPlan from json. +func (s *OrganizationPlan) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode OrganizationPlan to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch OrganizationPlan(v) { + case OrganizationPlanAir: + *s = OrganizationPlanAir + case OrganizationPlanPro: + *s = OrganizationPlanPro + case OrganizationPlanEnterprise: + *s = OrganizationPlanEnterprise + case OrganizationPlanNone: + *s = OrganizationPlanNone + default: + *s = OrganizationPlan(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OrganizationPlan) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OrganizationPlan) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes OrganizationSSOProvider as json. +func (s OrganizationSSOProvider) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes OrganizationSSOProvider from json. +func (s *OrganizationSSOProvider) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode OrganizationSSOProvider to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch OrganizationSSOProvider(v) { + case OrganizationSSOProviderGoogle: + *s = OrganizationSSOProviderGoogle + case OrganizationSSOProviderOkta: + *s = OrganizationSSOProviderOkta + default: + *s = OrganizationSSOProvider(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s OrganizationSSOProvider) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OrganizationSSOProvider) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *OrganizationUsage) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *OrganizationUsage) encodeFields(e *jx.Encoder) { + { + e.FieldStart("current_month_remote_cache_hits") + e.Float64(s.CurrentMonthRemoteCacheHits) + } +} + +var jsonFieldsNameOfOrganizationUsage = [1]string{ + 0: "current_month_remote_cache_hits", +} + +// Decode decodes OrganizationUsage from json. +func (s *OrganizationUsage) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode OrganizationUsage to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "current_month_remote_cache_hits": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Float64() + s.CurrentMonthRemoteCacheHits = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"current_month_remote_cache_hits\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode OrganizationUsage") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfOrganizationUsage) { + name = jsonFieldsNameOfOrganizationUsage[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *OrganizationUsage) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *OrganizationUsage) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Preview) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Preview) encodeFields(e *jx.Encoder) { + { + if s.BundleIdentifier.Set { + e.FieldStart("bundle_identifier") + s.BundleIdentifier.Encode(e) + } + } + { + if s.DisplayName.Set { + e.FieldStart("display_name") + s.DisplayName.Encode(e) + } + } + { + if s.GitBranch.Set { + e.FieldStart("git_branch") + s.GitBranch.Encode(e) + } + } + { + if s.GitCommitSha.Set { + e.FieldStart("git_commit_sha") + s.GitCommitSha.Encode(e) + } + } + { + e.FieldStart("icon_url") + e.Str(s.IconURL) + } + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("qr_code_url") + e.Str(s.QrCodeURL) + } + { + e.FieldStart("url") + e.Str(s.URL) + } +} + +var jsonFieldsNameOfPreview = [8]string{ + 0: "bundle_identifier", + 1: "display_name", + 2: "git_branch", + 3: "git_commit_sha", + 4: "icon_url", + 5: "id", + 6: "qr_code_url", + 7: "url", +} + +// Decode decodes Preview from json. +func (s *Preview) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Preview to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "bundle_identifier": + if err := func() error { + s.BundleIdentifier.Reset() + if err := s.BundleIdentifier.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"bundle_identifier\"") + } + case "display_name": + if err := func() error { + s.DisplayName.Reset() + if err := s.DisplayName.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"display_name\"") + } + case "git_branch": + if err := func() error { + s.GitBranch.Reset() + if err := s.GitBranch.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"git_branch\"") + } + case "git_commit_sha": + if err := func() error { + s.GitCommitSha.Reset() + if err := s.GitCommitSha.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"git_commit_sha\"") + } + case "icon_url": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + v, err := d.Str() + s.IconURL = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"icon_url\"") + } + case "id": + requiredBitSet[0] |= 1 << 5 + if err := func() error { + v, err := d.Str() + s.ID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "qr_code_url": + requiredBitSet[0] |= 1 << 6 + if err := func() error { + v, err := d.Str() + s.QrCodeURL = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"qr_code_url\"") + } + case "url": + requiredBitSet[0] |= 1 << 7 + if err := func() error { + v, err := d.Str() + s.URL = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Preview") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b11110000, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfPreview) { + name = jsonFieldsNameOfPreview[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Preview) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Preview) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes PreviewSupportedPlatform as json. +func (s PreviewSupportedPlatform) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes PreviewSupportedPlatform from json. +func (s *PreviewSupportedPlatform) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode PreviewSupportedPlatform to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch PreviewSupportedPlatform(v) { + case PreviewSupportedPlatformIos: + *s = PreviewSupportedPlatformIos + case PreviewSupportedPlatformIosSimulator: + *s = PreviewSupportedPlatformIosSimulator + case PreviewSupportedPlatformTvos: + *s = PreviewSupportedPlatformTvos + case PreviewSupportedPlatformTvosSimulator: + *s = PreviewSupportedPlatformTvosSimulator + case PreviewSupportedPlatformWatchos: + *s = PreviewSupportedPlatformWatchos + case PreviewSupportedPlatformWatchosSimulator: + *s = PreviewSupportedPlatformWatchosSimulator + case PreviewSupportedPlatformVisionos: + *s = PreviewSupportedPlatformVisionos + case PreviewSupportedPlatformVisionosSimulator: + *s = PreviewSupportedPlatformVisionosSimulator + case PreviewSupportedPlatformMacos: + *s = PreviewSupportedPlatformMacos + default: + *s = PreviewSupportedPlatform(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s PreviewSupportedPlatform) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *PreviewSupportedPlatform) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Project) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Project) encodeFields(e *jx.Encoder) { + { + e.FieldStart("default_branch") + e.Str(s.DefaultBranch) + } + { + e.FieldStart("full_name") + e.Str(s.FullName) + } + { + e.FieldStart("id") + e.Float64(s.ID) + } + { + if s.RepositoryURL.Set { + e.FieldStart("repository_url") + s.RepositoryURL.Encode(e) + } + } + { + e.FieldStart("token") + e.Str(s.Token) + } + { + e.FieldStart("visibility") + s.Visibility.Encode(e) + } +} + +var jsonFieldsNameOfProject = [6]string{ + 0: "default_branch", + 1: "full_name", + 2: "id", + 3: "repository_url", + 4: "token", + 5: "visibility", +} + +// Decode decodes Project from json. +func (s *Project) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Project to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "default_branch": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.DefaultBranch = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"default_branch\"") + } + case "full_name": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.FullName = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"full_name\"") + } + case "id": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + v, err := d.Float64() + s.ID = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "repository_url": + if err := func() error { + s.RepositoryURL.Reset() + if err := s.RepositoryURL.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"repository_url\"") + } + case "token": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + v, err := d.Str() + s.Token = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"token\"") + } + case "visibility": + requiredBitSet[0] |= 1 << 5 + if err := func() error { + if err := s.Visibility.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"visibility\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode Project") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00110111, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfProject) { + name = jsonFieldsNameOfProject[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *Project) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *Project) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *ProjectToken) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *ProjectToken) encodeFields(e *jx.Encoder) { + { + e.FieldStart("id") + e.Str(s.ID) + } + { + e.FieldStart("inserted_at") + json.EncodeDateTime(e, s.InsertedAt) + } +} + +var jsonFieldsNameOfProjectToken = [2]string{ + 0: "id", + 1: "inserted_at", +} + +// Decode decodes ProjectToken from json. +func (s *ProjectToken) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ProjectToken to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.ID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "inserted_at": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := json.DecodeDateTime(d) + s.InsertedAt = v + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"inserted_at\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode ProjectToken") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfProjectToken) { + name = jsonFieldsNameOfProjectToken[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ProjectToken) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ProjectToken) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ProjectVisibility as json. +func (s ProjectVisibility) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes ProjectVisibility from json. +func (s *ProjectVisibility) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ProjectVisibility to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch ProjectVisibility(v) { + case ProjectVisibilityPrivate: + *s = ProjectVisibilityPrivate + case ProjectVisibilityPublic: + *s = ProjectVisibilityPublic + default: + *s = ProjectVisibility(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s ProjectVisibility) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ProjectVisibility) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *RefreshTokenReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *RefreshTokenReq) encodeFields(e *jx.Encoder) { + { + e.FieldStart("refresh_token") + e.Str(s.RefreshToken) + } +} + +var jsonFieldsNameOfRefreshTokenReq = [1]string{ + 0: "refresh_token", +} + +// Decode decodes RefreshTokenReq from json. +func (s *RefreshTokenReq) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode RefreshTokenReq to nil") + } + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "refresh_token": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.RefreshToken = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"refresh_token\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode RefreshTokenReq") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000001, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfRefreshTokenReq) { + name = jsonFieldsNameOfRefreshTokenReq[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *RefreshTokenReq) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *RefreshTokenReq) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes RevokeProjectTokenBadRequest as json. +func (s *RevokeProjectTokenBadRequest) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes RevokeProjectTokenBadRequest from json. +func (s *RevokeProjectTokenBadRequest) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode RevokeProjectTokenBadRequest to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = RevokeProjectTokenBadRequest(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *RevokeProjectTokenBadRequest) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *RevokeProjectTokenBadRequest) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes RevokeProjectTokenForbidden as json. +func (s *RevokeProjectTokenForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes RevokeProjectTokenForbidden from json. +func (s *RevokeProjectTokenForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode RevokeProjectTokenForbidden to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = RevokeProjectTokenForbidden(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *RevokeProjectTokenForbidden) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *RevokeProjectTokenForbidden) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes RevokeProjectTokenNotFound as json. +func (s *RevokeProjectTokenNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes RevokeProjectTokenNotFound from json. +func (s *RevokeProjectTokenNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode RevokeProjectTokenNotFound to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = RevokeProjectTokenNotFound(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *RevokeProjectTokenNotFound) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *RevokeProjectTokenNotFound) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes RevokeProjectTokenUnauthorized as json. +func (s *RevokeProjectTokenUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes RevokeProjectTokenUnauthorized from json. +func (s *RevokeProjectTokenUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode RevokeProjectTokenUnauthorized to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = RevokeProjectTokenUnauthorized(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *RevokeProjectTokenUnauthorized) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *RevokeProjectTokenUnauthorized) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode implements json.Marshaler. +func (s *Run) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} + +// encodeFields encodes fields. +func (s *Run) encodeFields(e *jx.Encoder) { + { + if s.CacheableTargets != nil { + e.FieldStart("cacheable_targets") + e.ArrStart() + for _, elem := range s.CacheableTargets { + e.Str(elem) + } + e.ArrEnd() + } + } + { + e.FieldStart("command_arguments") + e.ArrStart() + for _, elem := range s.CommandArguments { + e.Str(elem) + } + e.ArrEnd() + } + { + e.FieldStart("duration") + e.Float64(s.Duration) + } + { + e.FieldStart("git_branch") + e.Str(s.GitBranch) + } + { + e.FieldStart("git_commit_sha") + e.Str(s.GitCommitSha) + } + { + e.FieldStart("git_ref") + e.Str(s.GitRef) + } + { + e.FieldStart("id") + e.Float64(s.ID) + } + { + if s.LocalCacheTargetHits != nil { + e.FieldStart("local_cache_target_hits") + e.ArrStart() + for _, elem := range s.LocalCacheTargetHits { + e.Str(elem) + } + e.ArrEnd() + } + } + { + if s.LocalTestTargetHits != nil { + e.FieldStart("local_test_target_hits") + e.ArrStart() + for _, elem := range s.LocalTestTargetHits { + e.Str(elem) + } + e.ArrEnd() + } + } + { + e.FieldStart("macos_version") + e.Str(s.MacosVersion) + } + { + e.FieldStart("name") + e.Str(s.Name) + } + { + if s.PreviewID.Set { + e.FieldStart("preview_id") + s.PreviewID.Encode(e) + } + } + { + if s.RemoteCacheTargetHits != nil { + e.FieldStart("remote_cache_target_hits") + e.ArrStart() + for _, elem := range s.RemoteCacheTargetHits { + e.Str(elem) + } + e.ArrEnd() + } + } + { + if s.RemoteTestTargetHits != nil { + e.FieldStart("remote_test_target_hits") + e.ArrStart() + for _, elem := range s.RemoteTestTargetHits { + e.Str(elem) + } + e.ArrEnd() + } + } + { + e.FieldStart("status") + e.Str(s.Status) + } + { + e.FieldStart("subcommand") + e.Str(s.Subcommand) + } + { + e.FieldStart("swift_version") + e.Str(s.SwiftVersion) + } + { + if s.TestTargets != nil { + e.FieldStart("test_targets") + e.ArrStart() + for _, elem := range s.TestTargets { + e.Str(elem) + } + e.ArrEnd() + } + } + { + e.FieldStart("tuist_version") + e.Str(s.TuistVersion) + } + { + e.FieldStart("url") + e.Str(s.URL) + } +} + +var jsonFieldsNameOfRun = [20]string{ + 0: "cacheable_targets", + 1: "command_arguments", + 2: "duration", + 3: "git_branch", + 4: "git_commit_sha", + 5: "git_ref", + 6: "id", + 7: "local_cache_target_hits", + 8: "local_test_target_hits", + 9: "macos_version", + 10: "name", + 11: "preview_id", + 12: "remote_cache_target_hits", + 13: "remote_test_target_hits", + 14: "status", + 15: "subcommand", + 16: "swift_version", + 17: "test_targets", + 18: "tuist_version", + 19: "url", +} + +// Decode decodes Run from json. +func (s *Run) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode Run to nil") + } + var requiredBitSet [3]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "cacheable_targets": + if err := func() error { + s.CacheableTargets = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.CacheableTargets = append(s.CacheableTargets, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"cacheable_targets\"") + } + case "command_arguments": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + s.CommandArguments = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.CommandArguments = append(s.CommandArguments, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"command_arguments\"") + } + case "duration": + requiredBitSet[0] |= 1 << 2 + if err := func() error { + v, err := d.Float64() + s.Duration = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"duration\"") + } + case "git_branch": + requiredBitSet[0] |= 1 << 3 + if err := func() error { + v, err := d.Str() + s.GitBranch = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"git_branch\"") + } + case "git_commit_sha": + requiredBitSet[0] |= 1 << 4 + if err := func() error { + v, err := d.Str() + s.GitCommitSha = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"git_commit_sha\"") + } + case "git_ref": + requiredBitSet[0] |= 1 << 5 + if err := func() error { + v, err := d.Str() + s.GitRef = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"git_ref\"") + } + case "id": + requiredBitSet[0] |= 1 << 6 + if err := func() error { + v, err := d.Float64() + s.ID = float64(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"id\"") + } + case "local_cache_target_hits": + if err := func() error { + s.LocalCacheTargetHits = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.LocalCacheTargetHits = append(s.LocalCacheTargetHits, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"local_cache_target_hits\"") + } + case "local_test_target_hits": + if err := func() error { + s.LocalTestTargetHits = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.LocalTestTargetHits = append(s.LocalTestTargetHits, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"local_test_target_hits\"") + } + case "macos_version": + requiredBitSet[1] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.MacosVersion = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"macos_version\"") + } + case "name": + requiredBitSet[1] |= 1 << 2 + if err := func() error { + v, err := d.Str() + s.Name = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"name\"") + } + case "preview_id": + if err := func() error { + s.PreviewID.Reset() + if err := s.PreviewID.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"preview_id\"") + } + case "remote_cache_target_hits": + if err := func() error { + s.RemoteCacheTargetHits = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.RemoteCacheTargetHits = append(s.RemoteCacheTargetHits, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"remote_cache_target_hits\"") + } + case "remote_test_target_hits": + if err := func() error { + s.RemoteTestTargetHits = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.RemoteTestTargetHits = append(s.RemoteTestTargetHits, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"remote_test_target_hits\"") + } + case "status": + requiredBitSet[1] |= 1 << 6 if err := func() error { v, err := d.Str() - s.DefaultBranch = string(v) + s.Status = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"default_branch\"") + return errors.Wrap(err, "decode field \"status\"") } - case "full_name": - requiredBitSet[0] |= 1 << 1 + case "subcommand": + requiredBitSet[1] |= 1 << 7 if err := func() error { v, err := d.Str() - s.FullName = string(v) + s.Subcommand = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"full_name\"") + return errors.Wrap(err, "decode field \"subcommand\"") } - case "id": - requiredBitSet[0] |= 1 << 2 + case "swift_version": + requiredBitSet[2] |= 1 << 0 if err := func() error { - v, err := d.Float64() - s.ID = float64(v) + v, err := d.Str() + s.SwiftVersion = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"id\"") + return errors.Wrap(err, "decode field \"swift_version\"") } - case "repository_url": + case "test_targets": if err := func() error { - s.RepositoryURL.Reset() - if err := s.RepositoryURL.Decode(d); err != nil { + s.TestTargets = make([]string, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem string + v, err := d.Str() + elem = string(v) + if err != nil { + return err + } + s.TestTargets = append(s.TestTargets, elem) + return nil + }); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"repository_url\"") + return errors.Wrap(err, "decode field \"test_targets\"") } - case "token": - requiredBitSet[0] |= 1 << 4 + case "tuist_version": + requiredBitSet[2] |= 1 << 2 if err := func() error { v, err := d.Str() - s.Token = string(v) + s.TuistVersion = string(v) if err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"token\"") + return errors.Wrap(err, "decode field \"tuist_version\"") + } + case "url": + requiredBitSet[2] |= 1 << 3 + if err := func() error { + v, err := d.Str() + s.URL = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"url\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode Project") + return errors.Wrap(err, "decode Run") } // Validate required fields. var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00010111, + for i, mask := range [3]uint8{ + 0b01111110, + 0b11000110, + 0b00001101, } { if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { // Mask only required fields and check equality to mask using XOR. @@ -8911,8 +11360,8 @@ func (s *Project) Decode(d *jx.Decoder) error { bitIdx := bits.TrailingZeros8(result) fieldIdx := i*8 + bitIdx var name string - if fieldIdx < len(jsonFieldsNameOfProject) { - name = jsonFieldsNameOfProject[fieldIdx] + if fieldIdx < len(jsonFieldsNameOfRun) { + name = jsonFieldsNameOfRun[fieldIdx] } else { name = strconv.Itoa(fieldIdx) } @@ -8933,238 +11382,181 @@ func (s *Project) Decode(d *jx.Decoder) error { } // MarshalJSON implements stdjson.Marshaler. -func (s *Project) MarshalJSON() ([]byte, error) { +func (s *Run) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *Project) UnmarshalJSON(data []byte) error { +func (s *Run) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *ProjectToken) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() +// Encode encodes ShowOrganizationForbidden as json. +func (s *ShowOrganizationForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) } -// encodeFields encodes fields. -func (s *ProjectToken) encodeFields(e *jx.Encoder) { - { - e.FieldStart("id") - e.Str(s.ID) +// Decode decodes ShowOrganizationForbidden from json. +func (s *ShowOrganizationForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ShowOrganizationForbidden to nil") } - { - e.FieldStart("inserted_at") - json.EncodeDateTime(e, s.InsertedAt) + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } + *s = ShowOrganizationForbidden(unwrapped) + return nil } -var jsonFieldsNameOfProjectToken = [2]string{ - 0: "id", - 1: "inserted_at", +// MarshalJSON implements stdjson.Marshaler. +func (s *ShowOrganizationForbidden) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil } -// Decode decodes ProjectToken from json. -func (s *ProjectToken) Decode(d *jx.Decoder) error { +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ShowOrganizationForbidden) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ShowOrganizationNotFound as json. +func (s *ShowOrganizationNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes ShowOrganizationNotFound from json. +func (s *ShowOrganizationNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ProjectToken to nil") + return errors.New("invalid: unable to decode ShowOrganizationNotFound to nil") } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "id": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - v, err := d.Str() - s.ID = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"id\"") - } - case "inserted_at": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - v, err := json.DecodeDateTime(d) - s.InsertedAt = v - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"inserted_at\"") - } - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } return nil - }); err != nil { - return errors.Wrap(err, "decode ProjectToken") + }(); err != nil { + return errors.Wrap(err, "alias") } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000011, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfProjectToken) { - name = jsonFieldsNameOfProjectToken[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } + *s = ShowOrganizationNotFound(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *ShowOrganizationNotFound) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *ShowOrganizationNotFound) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes ShowOrganizationUnauthorized as json. +func (s *ShowOrganizationUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes ShowOrganizationUnauthorized from json. +func (s *ShowOrganizationUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode ShowOrganizationUnauthorized to nil") } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = ShowOrganizationUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ProjectToken) MarshalJSON() ([]byte, error) { +func (s *ShowOrganizationUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ProjectToken) UnmarshalJSON(data []byte) error { +func (s *ShowOrganizationUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *RefreshTokenReq) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *RefreshTokenReq) encodeFields(e *jx.Encoder) { - { - e.FieldStart("refresh_token") - e.Str(s.RefreshToken) - } -} +// Encode encodes ShowOrganizationUsageForbidden as json. +func (s *ShowOrganizationUsageForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) -var jsonFieldsNameOfRefreshTokenReq = [1]string{ - 0: "refresh_token", + unwrapped.Encode(e) } -// Decode decodes RefreshTokenReq from json. -func (s *RefreshTokenReq) Decode(d *jx.Decoder) error { +// Decode decodes ShowOrganizationUsageForbidden from json. +func (s *ShowOrganizationUsageForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode RefreshTokenReq to nil") + return errors.New("invalid: unable to decode ShowOrganizationUsageForbidden to nil") } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "refresh_token": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - v, err := d.Str() - s.RefreshToken = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"refresh_token\"") - } - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } return nil - }); err != nil { - return errors.Wrap(err, "decode RefreshTokenReq") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000001, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfRefreshTokenReq) { - name = jsonFieldsNameOfRefreshTokenReq[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = ShowOrganizationUsageForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *RefreshTokenReq) MarshalJSON() ([]byte, error) { +func (s *ShowOrganizationUsageForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *RefreshTokenReq) UnmarshalJSON(data []byte) error { +func (s *ShowOrganizationUsageForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes RevokeProjectTokenBadRequest as json. -func (s *RevokeProjectTokenBadRequest) Encode(e *jx.Encoder) { +// Encode encodes ShowOrganizationUsageNotFound as json. +func (s *ShowOrganizationUsageNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes RevokeProjectTokenBadRequest from json. -func (s *RevokeProjectTokenBadRequest) Decode(d *jx.Decoder) error { +// Decode decodes ShowOrganizationUsageNotFound from json. +func (s *ShowOrganizationUsageNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode RevokeProjectTokenBadRequest to nil") + return errors.New("invalid: unable to decode ShowOrganizationUsageNotFound to nil") } var unwrapped Error if err := func() error { @@ -9175,34 +11567,34 @@ func (s *RevokeProjectTokenBadRequest) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = RevokeProjectTokenBadRequest(unwrapped) + *s = ShowOrganizationUsageNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *RevokeProjectTokenBadRequest) MarshalJSON() ([]byte, error) { +func (s *ShowOrganizationUsageNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *RevokeProjectTokenBadRequest) UnmarshalJSON(data []byte) error { +func (s *ShowOrganizationUsageNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes RevokeProjectTokenForbidden as json. -func (s *RevokeProjectTokenForbidden) Encode(e *jx.Encoder) { +// Encode encodes ShowOrganizationUsageUnauthorized as json. +func (s *ShowOrganizationUsageUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes RevokeProjectTokenForbidden from json. -func (s *RevokeProjectTokenForbidden) Decode(d *jx.Decoder) error { +// Decode decodes ShowOrganizationUsageUnauthorized from json. +func (s *ShowOrganizationUsageUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode RevokeProjectTokenForbidden to nil") + return errors.New("invalid: unable to decode ShowOrganizationUsageUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -9213,34 +11605,34 @@ func (s *RevokeProjectTokenForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = RevokeProjectTokenForbidden(unwrapped) + *s = ShowOrganizationUsageUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *RevokeProjectTokenForbidden) MarshalJSON() ([]byte, error) { +func (s *ShowOrganizationUsageUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *RevokeProjectTokenForbidden) UnmarshalJSON(data []byte) error { +func (s *ShowOrganizationUsageUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes RevokeProjectTokenNotFound as json. -func (s *RevokeProjectTokenNotFound) Encode(e *jx.Encoder) { +// Encode encodes ShowProjectForbidden as json. +func (s *ShowProjectForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes RevokeProjectTokenNotFound from json. -func (s *RevokeProjectTokenNotFound) Decode(d *jx.Decoder) error { +// Decode decodes ShowProjectForbidden from json. +func (s *ShowProjectForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode RevokeProjectTokenNotFound to nil") + return errors.New("invalid: unable to decode ShowProjectForbidden to nil") } var unwrapped Error if err := func() error { @@ -9251,34 +11643,34 @@ func (s *RevokeProjectTokenNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = RevokeProjectTokenNotFound(unwrapped) + *s = ShowProjectForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *RevokeProjectTokenNotFound) MarshalJSON() ([]byte, error) { +func (s *ShowProjectForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *RevokeProjectTokenNotFound) UnmarshalJSON(data []byte) error { +func (s *ShowProjectForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes RevokeProjectTokenUnauthorized as json. -func (s *RevokeProjectTokenUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes ShowProjectNotFound as json. +func (s *ShowProjectNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes RevokeProjectTokenUnauthorized from json. -func (s *RevokeProjectTokenUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes ShowProjectNotFound from json. +func (s *ShowProjectNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode RevokeProjectTokenUnauthorized to nil") + return errors.New("invalid: unable to decode ShowProjectNotFound to nil") } var unwrapped Error if err := func() error { @@ -9289,34 +11681,34 @@ func (s *RevokeProjectTokenUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = RevokeProjectTokenUnauthorized(unwrapped) + *s = ShowProjectNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *RevokeProjectTokenUnauthorized) MarshalJSON() ([]byte, error) { +func (s *ShowProjectNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *RevokeProjectTokenUnauthorized) UnmarshalJSON(data []byte) error { +func (s *ShowProjectNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ShowOrganizationForbidden as json. -func (s *ShowOrganizationForbidden) Encode(e *jx.Encoder) { +// Encode encodes ShowProjectUnauthorized as json. +func (s *ShowProjectUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ShowOrganizationForbidden from json. -func (s *ShowOrganizationForbidden) Decode(d *jx.Decoder) error { +// Decode decodes ShowProjectUnauthorized from json. +func (s *ShowProjectUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ShowOrganizationForbidden to nil") + return errors.New("invalid: unable to decode ShowProjectUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -9327,34 +11719,34 @@ func (s *ShowOrganizationForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ShowOrganizationForbidden(unwrapped) + *s = ShowProjectUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ShowOrganizationForbidden) MarshalJSON() ([]byte, error) { +func (s *ShowProjectUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ShowOrganizationForbidden) UnmarshalJSON(data []byte) error { +func (s *ShowProjectUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ShowOrganizationNotFound as json. -func (s *ShowOrganizationNotFound) Encode(e *jx.Encoder) { +// Encode encodes StartAnalyticsArtifactMultipartUploadForbidden as json. +func (s *StartAnalyticsArtifactMultipartUploadForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ShowOrganizationNotFound from json. -func (s *ShowOrganizationNotFound) Decode(d *jx.Decoder) error { +// Decode decodes StartAnalyticsArtifactMultipartUploadForbidden from json. +func (s *StartAnalyticsArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ShowOrganizationNotFound to nil") + return errors.New("invalid: unable to decode StartAnalyticsArtifactMultipartUploadForbidden to nil") } var unwrapped Error if err := func() error { @@ -9365,34 +11757,34 @@ func (s *ShowOrganizationNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ShowOrganizationNotFound(unwrapped) + *s = StartAnalyticsArtifactMultipartUploadForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ShowOrganizationNotFound) MarshalJSON() ([]byte, error) { +func (s *StartAnalyticsArtifactMultipartUploadForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ShowOrganizationNotFound) UnmarshalJSON(data []byte) error { +func (s *StartAnalyticsArtifactMultipartUploadForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ShowOrganizationUnauthorized as json. -func (s *ShowOrganizationUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes StartAnalyticsArtifactMultipartUploadNotFound as json. +func (s *StartAnalyticsArtifactMultipartUploadNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ShowOrganizationUnauthorized from json. -func (s *ShowOrganizationUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes StartAnalyticsArtifactMultipartUploadNotFound from json. +func (s *StartAnalyticsArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ShowOrganizationUnauthorized to nil") + return errors.New("invalid: unable to decode StartAnalyticsArtifactMultipartUploadNotFound to nil") } var unwrapped Error if err := func() error { @@ -9403,34 +11795,34 @@ func (s *ShowOrganizationUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ShowOrganizationUnauthorized(unwrapped) + *s = StartAnalyticsArtifactMultipartUploadNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ShowOrganizationUnauthorized) MarshalJSON() ([]byte, error) { +func (s *StartAnalyticsArtifactMultipartUploadNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ShowOrganizationUnauthorized) UnmarshalJSON(data []byte) error { +func (s *StartAnalyticsArtifactMultipartUploadNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ShowOrganizationUsageForbidden as json. -func (s *ShowOrganizationUsageForbidden) Encode(e *jx.Encoder) { +// Encode encodes StartAnalyticsArtifactMultipartUploadUnauthorized as json. +func (s *StartAnalyticsArtifactMultipartUploadUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ShowOrganizationUsageForbidden from json. -func (s *ShowOrganizationUsageForbidden) Decode(d *jx.Decoder) error { +// Decode decodes StartAnalyticsArtifactMultipartUploadUnauthorized from json. +func (s *StartAnalyticsArtifactMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ShowOrganizationUsageForbidden to nil") + return errors.New("invalid: unable to decode StartAnalyticsArtifactMultipartUploadUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -9441,34 +11833,34 @@ func (s *ShowOrganizationUsageForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ShowOrganizationUsageForbidden(unwrapped) + *s = StartAnalyticsArtifactMultipartUploadUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ShowOrganizationUsageForbidden) MarshalJSON() ([]byte, error) { +func (s *StartAnalyticsArtifactMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ShowOrganizationUsageForbidden) UnmarshalJSON(data []byte) error { +func (s *StartAnalyticsArtifactMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ShowOrganizationUsageNotFound as json. -func (s *ShowOrganizationUsageNotFound) Encode(e *jx.Encoder) { +// Encode encodes StartCacheArtifactMultipartUploadForbidden as json. +func (s *StartCacheArtifactMultipartUploadForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ShowOrganizationUsageNotFound from json. -func (s *ShowOrganizationUsageNotFound) Decode(d *jx.Decoder) error { +// Decode decodes StartCacheArtifactMultipartUploadForbidden from json. +func (s *StartCacheArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ShowOrganizationUsageNotFound to nil") + return errors.New("invalid: unable to decode StartCacheArtifactMultipartUploadForbidden to nil") } var unwrapped Error if err := func() error { @@ -9479,34 +11871,34 @@ func (s *ShowOrganizationUsageNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ShowOrganizationUsageNotFound(unwrapped) + *s = StartCacheArtifactMultipartUploadForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ShowOrganizationUsageNotFound) MarshalJSON() ([]byte, error) { +func (s *StartCacheArtifactMultipartUploadForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ShowOrganizationUsageNotFound) UnmarshalJSON(data []byte) error { +func (s *StartCacheArtifactMultipartUploadForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ShowOrganizationUsageUnauthorized as json. -func (s *ShowOrganizationUsageUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes StartCacheArtifactMultipartUploadNotFound as json. +func (s *StartCacheArtifactMultipartUploadNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ShowOrganizationUsageUnauthorized from json. -func (s *ShowOrganizationUsageUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes StartCacheArtifactMultipartUploadNotFound from json. +func (s *StartCacheArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ShowOrganizationUsageUnauthorized to nil") + return errors.New("invalid: unable to decode StartCacheArtifactMultipartUploadNotFound to nil") } var unwrapped Error if err := func() error { @@ -9517,34 +11909,34 @@ func (s *ShowOrganizationUsageUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ShowOrganizationUsageUnauthorized(unwrapped) + *s = StartCacheArtifactMultipartUploadNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ShowOrganizationUsageUnauthorized) MarshalJSON() ([]byte, error) { +func (s *StartCacheArtifactMultipartUploadNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ShowOrganizationUsageUnauthorized) UnmarshalJSON(data []byte) error { +func (s *StartCacheArtifactMultipartUploadNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ShowProjectForbidden as json. -func (s *ShowProjectForbidden) Encode(e *jx.Encoder) { +// Encode encodes StartCacheArtifactMultipartUploadPaymentRequired as json. +func (s *StartCacheArtifactMultipartUploadPaymentRequired) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ShowProjectForbidden from json. -func (s *ShowProjectForbidden) Decode(d *jx.Decoder) error { +// Decode decodes StartCacheArtifactMultipartUploadPaymentRequired from json. +func (s *StartCacheArtifactMultipartUploadPaymentRequired) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ShowProjectForbidden to nil") + return errors.New("invalid: unable to decode StartCacheArtifactMultipartUploadPaymentRequired to nil") } var unwrapped Error if err := func() error { @@ -9555,34 +11947,34 @@ func (s *ShowProjectForbidden) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ShowProjectForbidden(unwrapped) + *s = StartCacheArtifactMultipartUploadPaymentRequired(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ShowProjectForbidden) MarshalJSON() ([]byte, error) { +func (s *StartCacheArtifactMultipartUploadPaymentRequired) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ShowProjectForbidden) UnmarshalJSON(data []byte) error { +func (s *StartCacheArtifactMultipartUploadPaymentRequired) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ShowProjectNotFound as json. -func (s *ShowProjectNotFound) Encode(e *jx.Encoder) { +// Encode encodes StartCacheArtifactMultipartUploadUnauthorized as json. +func (s *StartCacheArtifactMultipartUploadUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ShowProjectNotFound from json. -func (s *ShowProjectNotFound) Decode(d *jx.Decoder) error { +// Decode decodes StartCacheArtifactMultipartUploadUnauthorized from json. +func (s *StartCacheArtifactMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ShowProjectNotFound to nil") + return errors.New("invalid: unable to decode StartCacheArtifactMultipartUploadUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -9593,34 +11985,34 @@ func (s *ShowProjectNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ShowProjectNotFound(unwrapped) + *s = StartCacheArtifactMultipartUploadUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ShowProjectNotFound) MarshalJSON() ([]byte, error) { +func (s *StartCacheArtifactMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ShowProjectNotFound) UnmarshalJSON(data []byte) error { +func (s *StartCacheArtifactMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes ShowProjectUnauthorized as json. -func (s *ShowProjectUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes StartPreviewsMultipartUploadForbidden as json. +func (s *StartPreviewsMultipartUploadForbidden) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes ShowProjectUnauthorized from json. -func (s *ShowProjectUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes StartPreviewsMultipartUploadForbidden from json. +func (s *StartPreviewsMultipartUploadForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode ShowProjectUnauthorized to nil") + return errors.New("invalid: unable to decode StartPreviewsMultipartUploadForbidden to nil") } var unwrapped Error if err := func() error { @@ -9631,34 +12023,34 @@ func (s *ShowProjectUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = ShowProjectUnauthorized(unwrapped) + *s = StartPreviewsMultipartUploadForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *ShowProjectUnauthorized) MarshalJSON() ([]byte, error) { +func (s *StartPreviewsMultipartUploadForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *ShowProjectUnauthorized) UnmarshalJSON(data []byte) error { +func (s *StartPreviewsMultipartUploadForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartAnalyticsArtifactMultipartUploadForbidden as json. -func (s *StartAnalyticsArtifactMultipartUploadForbidden) Encode(e *jx.Encoder) { +// Encode encodes StartPreviewsMultipartUploadNotFound as json. +func (s *StartPreviewsMultipartUploadNotFound) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes StartAnalyticsArtifactMultipartUploadForbidden from json. -func (s *StartAnalyticsArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) error { +// Decode decodes StartPreviewsMultipartUploadNotFound from json. +func (s *StartPreviewsMultipartUploadNotFound) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartAnalyticsArtifactMultipartUploadForbidden to nil") + return errors.New("invalid: unable to decode StartPreviewsMultipartUploadNotFound to nil") } var unwrapped Error if err := func() error { @@ -9669,300 +12061,478 @@ func (s *StartAnalyticsArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) e }(); err != nil { return errors.Wrap(err, "alias") } - *s = StartAnalyticsArtifactMultipartUploadForbidden(unwrapped) + *s = StartPreviewsMultipartUploadNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartAnalyticsArtifactMultipartUploadForbidden) MarshalJSON() ([]byte, error) { +func (s *StartPreviewsMultipartUploadNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartAnalyticsArtifactMultipartUploadForbidden) UnmarshalJSON(data []byte) error { +func (s *StartPreviewsMultipartUploadNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartAnalyticsArtifactMultipartUploadNotFound as json. -func (s *StartAnalyticsArtifactMultipartUploadNotFound) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) +// Encode implements json.Marshaler. +func (s *StartPreviewsMultipartUploadOK) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} - unwrapped.Encode(e) +// encodeFields encodes fields. +func (s *StartPreviewsMultipartUploadOK) encodeFields(e *jx.Encoder) { + { + e.FieldStart("data") + s.Data.Encode(e) + } + { + e.FieldStart("status") + s.Status.Encode(e) + } } -// Decode decodes StartAnalyticsArtifactMultipartUploadNotFound from json. -func (s *StartAnalyticsArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) error { +var jsonFieldsNameOfStartPreviewsMultipartUploadOK = [2]string{ + 0: "data", + 1: "status", +} + +// Decode decodes StartPreviewsMultipartUploadOK from json. +func (s *StartPreviewsMultipartUploadOK) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartAnalyticsArtifactMultipartUploadNotFound to nil") + return errors.New("invalid: unable to decode StartPreviewsMultipartUploadOK to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err + var requiredBitSet [1]uint8 + s.setDefaults() + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "data": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + if err := s.Data.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"data\"") + } + case "status": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + if err := s.Status.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"status\"") + } + default: + return d.Skip() } return nil - }(); err != nil { - return errors.Wrap(err, "alias") + }); err != nil { + return errors.Wrap(err, "decode StartPreviewsMultipartUploadOK") } - *s = StartAnalyticsArtifactMultipartUploadNotFound(unwrapped) + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfStartPreviewsMultipartUploadOK) { + name = jsonFieldsNameOfStartPreviewsMultipartUploadOK[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartAnalyticsArtifactMultipartUploadNotFound) MarshalJSON() ([]byte, error) { +func (s *StartPreviewsMultipartUploadOK) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartAnalyticsArtifactMultipartUploadNotFound) UnmarshalJSON(data []byte) error { +func (s *StartPreviewsMultipartUploadOK) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartAnalyticsArtifactMultipartUploadUnauthorized as json. -func (s *StartAnalyticsArtifactMultipartUploadUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) +// Encode implements json.Marshaler. +func (s *StartPreviewsMultipartUploadOKData) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() +} - unwrapped.Encode(e) +// encodeFields encodes fields. +func (s *StartPreviewsMultipartUploadOKData) encodeFields(e *jx.Encoder) { + { + e.FieldStart("preview_id") + e.Str(s.PreviewID) + } + { + e.FieldStart("upload_id") + e.Str(s.UploadID) + } } -// Decode decodes StartAnalyticsArtifactMultipartUploadUnauthorized from json. -func (s *StartAnalyticsArtifactMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { +var jsonFieldsNameOfStartPreviewsMultipartUploadOKData = [2]string{ + 0: "preview_id", + 1: "upload_id", +} + +// Decode decodes StartPreviewsMultipartUploadOKData from json. +func (s *StartPreviewsMultipartUploadOKData) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartAnalyticsArtifactMultipartUploadUnauthorized to nil") + return errors.New("invalid: unable to decode StartPreviewsMultipartUploadOKData to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err + var requiredBitSet [1]uint8 + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "preview_id": + requiredBitSet[0] |= 1 << 0 + if err := func() error { + v, err := d.Str() + s.PreviewID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"preview_id\"") + } + case "upload_id": + requiredBitSet[0] |= 1 << 1 + if err := func() error { + v, err := d.Str() + s.UploadID = string(v) + if err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"upload_id\"") + } + default: + return d.Skip() + } + return nil + }); err != nil { + return errors.Wrap(err, "decode StartPreviewsMultipartUploadOKData") + } + // Validate required fields. + var failures []validate.FieldError + for i, mask := range [1]uint8{ + 0b00000011, + } { + if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { + // Mask only required fields and check equality to mask using XOR. + // + // If XOR result is not zero, result is not equal to expected, so some fields are missed. + // Bits of fields which would be set are actually bits of missed fields. + missed := bits.OnesCount8(result) + for bitN := 0; bitN < missed; bitN++ { + bitIdx := bits.TrailingZeros8(result) + fieldIdx := i*8 + bitIdx + var name string + if fieldIdx < len(jsonFieldsNameOfStartPreviewsMultipartUploadOKData) { + name = jsonFieldsNameOfStartPreviewsMultipartUploadOKData[fieldIdx] + } else { + name = strconv.Itoa(fieldIdx) + } + failures = append(failures, validate.FieldError{ + Name: name, + Error: validate.ErrFieldRequired, + }) + // Reset bit. + result &^= 1 << bitIdx + } } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") } - *s = StartAnalyticsArtifactMultipartUploadUnauthorized(unwrapped) + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartAnalyticsArtifactMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { +func (s *StartPreviewsMultipartUploadOKData) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartAnalyticsArtifactMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { +func (s *StartPreviewsMultipartUploadOKData) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartCacheArtifactMultipartUploadForbidden as json. -func (s *StartCacheArtifactMultipartUploadForbidden) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode encodes StartPreviewsMultipartUploadOKStatus as json. +func (s StartPreviewsMultipartUploadOKStatus) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes StartCacheArtifactMultipartUploadForbidden from json. -func (s *StartCacheArtifactMultipartUploadForbidden) Decode(d *jx.Decoder) error { +// Decode decodes StartPreviewsMultipartUploadOKStatus from json. +func (s *StartPreviewsMultipartUploadOKStatus) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartCacheArtifactMultipartUploadForbidden to nil") + return errors.New("invalid: unable to decode StartPreviewsMultipartUploadOKStatus to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") + v, err := d.StrBytes() + if err != nil { + return err } - *s = StartCacheArtifactMultipartUploadForbidden(unwrapped) + // Try to use constant string. + switch StartPreviewsMultipartUploadOKStatus(v) { + case StartPreviewsMultipartUploadOKStatusSuccess: + *s = StartPreviewsMultipartUploadOKStatusSuccess + default: + *s = StartPreviewsMultipartUploadOKStatus(v) + } + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartCacheArtifactMultipartUploadForbidden) MarshalJSON() ([]byte, error) { +func (s StartPreviewsMultipartUploadOKStatus) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartCacheArtifactMultipartUploadForbidden) UnmarshalJSON(data []byte) error { +func (s *StartPreviewsMultipartUploadOKStatus) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartCacheArtifactMultipartUploadNotFound as json. -func (s *StartCacheArtifactMultipartUploadNotFound) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode implements json.Marshaler. +func (s *StartPreviewsMultipartUploadReq) Encode(e *jx.Encoder) { + e.ObjStart() + s.encodeFields(e) + e.ObjEnd() } -// Decode decodes StartCacheArtifactMultipartUploadNotFound from json. -func (s *StartCacheArtifactMultipartUploadNotFound) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode StartCacheArtifactMultipartUploadNotFound to nil") +// encodeFields encodes fields. +func (s *StartPreviewsMultipartUploadReq) encodeFields(e *jx.Encoder) { + { + if s.BundleIdentifier.Set { + e.FieldStart("bundle_identifier") + s.BundleIdentifier.Encode(e) + } } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err + { + if s.DisplayName.Set { + e.FieldStart("display_name") + s.DisplayName.Encode(e) } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") } - *s = StartCacheArtifactMultipartUploadNotFound(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *StartCacheArtifactMultipartUploadNotFound) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartCacheArtifactMultipartUploadNotFound) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes StartCacheArtifactMultipartUploadPaymentRequired as json. -func (s *StartCacheArtifactMultipartUploadPaymentRequired) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) -} - -// Decode decodes StartCacheArtifactMultipartUploadPaymentRequired from json. -func (s *StartCacheArtifactMultipartUploadPaymentRequired) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode StartCacheArtifactMultipartUploadPaymentRequired to nil") + { + if s.SupportedPlatforms != nil { + e.FieldStart("supported_platforms") + e.ArrStart() + for _, elem := range s.SupportedPlatforms { + elem.Encode(e) + } + e.ArrEnd() + } } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err + { + if s.Type.Set { + e.FieldStart("type") + s.Type.Encode(e) + } + } + { + if s.Version.Set { + e.FieldStart("version") + s.Version.Encode(e) } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") } - *s = StartCacheArtifactMultipartUploadPaymentRequired(unwrapped) - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *StartCacheArtifactMultipartUploadPaymentRequired) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartCacheArtifactMultipartUploadPaymentRequired) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) } -// Encode encodes StartCacheArtifactMultipartUploadUnauthorized as json. -func (s *StartCacheArtifactMultipartUploadUnauthorized) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +var jsonFieldsNameOfStartPreviewsMultipartUploadReq = [5]string{ + 0: "bundle_identifier", + 1: "display_name", + 2: "supported_platforms", + 3: "type", + 4: "version", } -// Decode decodes StartCacheArtifactMultipartUploadUnauthorized from json. -func (s *StartCacheArtifactMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes StartPreviewsMultipartUploadReq from json. +func (s *StartPreviewsMultipartUploadReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartCacheArtifactMultipartUploadUnauthorized to nil") + return errors.New("invalid: unable to decode StartPreviewsMultipartUploadReq to nil") } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err + s.setDefaults() + + if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { + switch string(k) { + case "bundle_identifier": + if err := func() error { + s.BundleIdentifier.Reset() + if err := s.BundleIdentifier.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"bundle_identifier\"") + } + case "display_name": + if err := func() error { + s.DisplayName.Reset() + if err := s.DisplayName.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"display_name\"") + } + case "supported_platforms": + if err := func() error { + s.SupportedPlatforms = make([]PreviewSupportedPlatform, 0) + if err := d.Arr(func(d *jx.Decoder) error { + var elem PreviewSupportedPlatform + if err := elem.Decode(d); err != nil { + return err + } + s.SupportedPlatforms = append(s.SupportedPlatforms, elem) + return nil + }); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"supported_platforms\"") + } + case "type": + if err := func() error { + s.Type.Reset() + if err := s.Type.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"type\"") + } + case "version": + if err := func() error { + s.Version.Reset() + if err := s.Version.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"version\"") + } + default: + return d.Skip() } return nil - }(); err != nil { - return errors.Wrap(err, "alias") + }); err != nil { + return errors.Wrap(err, "decode StartPreviewsMultipartUploadReq") } - *s = StartCacheArtifactMultipartUploadUnauthorized(unwrapped) + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartCacheArtifactMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { +func (s *StartPreviewsMultipartUploadReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartCacheArtifactMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { +func (s *StartPreviewsMultipartUploadReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartPreviewsMultipartUploadForbidden as json. -func (s *StartPreviewsMultipartUploadForbidden) Encode(e *jx.Encoder) { - unwrapped := (*Error)(s) - - unwrapped.Encode(e) +// Encode encodes StartPreviewsMultipartUploadReqType as json. +func (s StartPreviewsMultipartUploadReqType) Encode(e *jx.Encoder) { + e.Str(string(s)) } -// Decode decodes StartPreviewsMultipartUploadForbidden from json. -func (s *StartPreviewsMultipartUploadForbidden) Decode(d *jx.Decoder) error { +// Decode decodes StartPreviewsMultipartUploadReqType from json. +func (s *StartPreviewsMultipartUploadReqType) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartPreviewsMultipartUploadForbidden to nil") + return errors.New("invalid: unable to decode StartPreviewsMultipartUploadReqType to nil") + } + v, err := d.StrBytes() + if err != nil { + return err } - var unwrapped Error - if err := func() error { - if err := unwrapped.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "alias") + // Try to use constant string. + switch StartPreviewsMultipartUploadReqType(v) { + case StartPreviewsMultipartUploadReqTypeAppBundle: + *s = StartPreviewsMultipartUploadReqTypeAppBundle + case StartPreviewsMultipartUploadReqTypeIpa: + *s = StartPreviewsMultipartUploadReqTypeIpa + default: + *s = StartPreviewsMultipartUploadReqType(v) } - *s = StartPreviewsMultipartUploadForbidden(unwrapped) + return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartPreviewsMultipartUploadForbidden) MarshalJSON() ([]byte, error) { +func (s StartPreviewsMultipartUploadReqType) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartPreviewsMultipartUploadForbidden) UnmarshalJSON(data []byte) error { +func (s *StartPreviewsMultipartUploadReqType) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartPreviewsMultipartUploadNotFound as json. -func (s *StartPreviewsMultipartUploadNotFound) Encode(e *jx.Encoder) { +// Encode encodes StartPreviewsMultipartUploadUnauthorized as json. +func (s *StartPreviewsMultipartUploadUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes StartPreviewsMultipartUploadNotFound from json. -func (s *StartPreviewsMultipartUploadNotFound) Decode(d *jx.Decoder) error { +// Decode decodes StartPreviewsMultipartUploadUnauthorized from json. +func (s *StartPreviewsMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartPreviewsMultipartUploadNotFound to nil") + return errors.New("invalid: unable to decode StartPreviewsMultipartUploadUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -9973,450 +12543,211 @@ func (s *StartPreviewsMultipartUploadNotFound) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = StartPreviewsMultipartUploadNotFound(unwrapped) + *s = StartPreviewsMultipartUploadUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartPreviewsMultipartUploadNotFound) MarshalJSON() ([]byte, error) { +func (s *StartPreviewsMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartPreviewsMultipartUploadNotFound) UnmarshalJSON(data []byte) error { +func (s *StartPreviewsMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *StartPreviewsMultipartUploadOK) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *StartPreviewsMultipartUploadOK) encodeFields(e *jx.Encoder) { - { - e.FieldStart("data") - s.Data.Encode(e) - } - { - e.FieldStart("status") - s.Status.Encode(e) - } -} +// Encode encodes UpdateAccountBadRequest as json. +func (s *UpdateAccountBadRequest) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) -var jsonFieldsNameOfStartPreviewsMultipartUploadOK = [2]string{ - 0: "data", - 1: "status", + unwrapped.Encode(e) } -// Decode decodes StartPreviewsMultipartUploadOK from json. -func (s *StartPreviewsMultipartUploadOK) Decode(d *jx.Decoder) error { +// Decode decodes UpdateAccountBadRequest from json. +func (s *UpdateAccountBadRequest) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartPreviewsMultipartUploadOK to nil") + return errors.New("invalid: unable to decode UpdateAccountBadRequest to nil") } - var requiredBitSet [1]uint8 - s.setDefaults() - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "data": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - if err := s.Data.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"data\"") - } - case "status": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - if err := s.Status.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"status\"") - } - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } return nil - }); err != nil { - return errors.Wrap(err, "decode StartPreviewsMultipartUploadOK") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000011, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfStartPreviewsMultipartUploadOK) { - name = jsonFieldsNameOfStartPreviewsMultipartUploadOK[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = UpdateAccountBadRequest(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartPreviewsMultipartUploadOK) MarshalJSON() ([]byte, error) { +func (s *UpdateAccountBadRequest) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartPreviewsMultipartUploadOK) UnmarshalJSON(data []byte) error { +func (s *UpdateAccountBadRequest) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode implements json.Marshaler. -func (s *StartPreviewsMultipartUploadOKData) Encode(e *jx.Encoder) { - e.ObjStart() - s.encodeFields(e) - e.ObjEnd() -} - -// encodeFields encodes fields. -func (s *StartPreviewsMultipartUploadOKData) encodeFields(e *jx.Encoder) { - { - e.FieldStart("preview_id") - e.Str(s.PreviewID) - } - { - e.FieldStart("upload_id") - e.Str(s.UploadID) - } -} +// Encode encodes UpdateAccountForbidden as json. +func (s *UpdateAccountForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) -var jsonFieldsNameOfStartPreviewsMultipartUploadOKData = [2]string{ - 0: "preview_id", - 1: "upload_id", + unwrapped.Encode(e) } -// Decode decodes StartPreviewsMultipartUploadOKData from json. -func (s *StartPreviewsMultipartUploadOKData) Decode(d *jx.Decoder) error { +// Decode decodes UpdateAccountForbidden from json. +func (s *UpdateAccountForbidden) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartPreviewsMultipartUploadOKData to nil") + return errors.New("invalid: unable to decode UpdateAccountForbidden to nil") } - var requiredBitSet [1]uint8 - - if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { - switch string(k) { - case "preview_id": - requiredBitSet[0] |= 1 << 0 - if err := func() error { - v, err := d.Str() - s.PreviewID = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"preview_id\"") - } - case "upload_id": - requiredBitSet[0] |= 1 << 1 - if err := func() error { - v, err := d.Str() - s.UploadID = string(v) - if err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"upload_id\"") - } - default: - return d.Skip() + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err } return nil - }); err != nil { - return errors.Wrap(err, "decode StartPreviewsMultipartUploadOKData") - } - // Validate required fields. - var failures []validate.FieldError - for i, mask := range [1]uint8{ - 0b00000011, - } { - if result := (requiredBitSet[i] & mask) ^ mask; result != 0 { - // Mask only required fields and check equality to mask using XOR. - // - // If XOR result is not zero, result is not equal to expected, so some fields are missed. - // Bits of fields which would be set are actually bits of missed fields. - missed := bits.OnesCount8(result) - for bitN := 0; bitN < missed; bitN++ { - bitIdx := bits.TrailingZeros8(result) - fieldIdx := i*8 + bitIdx - var name string - if fieldIdx < len(jsonFieldsNameOfStartPreviewsMultipartUploadOKData) { - name = jsonFieldsNameOfStartPreviewsMultipartUploadOKData[fieldIdx] - } else { - name = strconv.Itoa(fieldIdx) - } - failures = append(failures, validate.FieldError{ - Name: name, - Error: validate.ErrFieldRequired, - }) - // Reset bit. - result &^= 1 << bitIdx - } - } - } - if len(failures) > 0 { - return &validate.Error{Fields: failures} + }(); err != nil { + return errors.Wrap(err, "alias") } - + *s = UpdateAccountForbidden(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartPreviewsMultipartUploadOKData) MarshalJSON() ([]byte, error) { +func (s *UpdateAccountForbidden) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartPreviewsMultipartUploadOKData) UnmarshalJSON(data []byte) error { +func (s *UpdateAccountForbidden) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartPreviewsMultipartUploadOKStatus as json. -func (s StartPreviewsMultipartUploadOKStatus) Encode(e *jx.Encoder) { - e.Str(string(s)) -} - -// Decode decodes StartPreviewsMultipartUploadOKStatus from json. -func (s *StartPreviewsMultipartUploadOKStatus) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode StartPreviewsMultipartUploadOKStatus to nil") - } - v, err := d.StrBytes() - if err != nil { - return err - } - // Try to use constant string. - switch StartPreviewsMultipartUploadOKStatus(v) { - case StartPreviewsMultipartUploadOKStatusSuccess: - *s = StartPreviewsMultipartUploadOKStatusSuccess - default: - *s = StartPreviewsMultipartUploadOKStatus(v) - } +// Encode encodes UpdateAccountNotFound as json. +func (s *UpdateAccountNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + unwrapped.Encode(e) +} + +// Decode decodes UpdateAccountNotFound from json. +func (s *UpdateAccountNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UpdateAccountNotFound to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = UpdateAccountNotFound(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s StartPreviewsMultipartUploadOKStatus) MarshalJSON() ([]byte, error) { +func (s *UpdateAccountNotFound) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartPreviewsMultipartUploadOKStatus) UnmarshalJSON(data []byte) error { +func (s *UpdateAccountNotFound) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } // Encode implements json.Marshaler. -func (s *StartPreviewsMultipartUploadReq) Encode(e *jx.Encoder) { +func (s *UpdateAccountReq) Encode(e *jx.Encoder) { e.ObjStart() s.encodeFields(e) e.ObjEnd() } // encodeFields encodes fields. -func (s *StartPreviewsMultipartUploadReq) encodeFields(e *jx.Encoder) { - { - if s.BundleIdentifier.Set { - e.FieldStart("bundle_identifier") - s.BundleIdentifier.Encode(e) - } - } - { - if s.DisplayName.Set { - e.FieldStart("display_name") - s.DisplayName.Encode(e) - } - } - { - if s.Type.Set { - e.FieldStart("type") - s.Type.Encode(e) - } - } +func (s *UpdateAccountReq) encodeFields(e *jx.Encoder) { { - if s.Version.Set { - e.FieldStart("version") - s.Version.Encode(e) + if s.Handle.Set { + e.FieldStart("handle") + s.Handle.Encode(e) } } } -var jsonFieldsNameOfStartPreviewsMultipartUploadReq = [4]string{ - 0: "bundle_identifier", - 1: "display_name", - 2: "type", - 3: "version", +var jsonFieldsNameOfUpdateAccountReq = [1]string{ + 0: "handle", } -// Decode decodes StartPreviewsMultipartUploadReq from json. -func (s *StartPreviewsMultipartUploadReq) Decode(d *jx.Decoder) error { +// Decode decodes UpdateAccountReq from json. +func (s *UpdateAccountReq) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartPreviewsMultipartUploadReq to nil") + return errors.New("invalid: unable to decode UpdateAccountReq to nil") } - s.setDefaults() if err := d.ObjBytes(func(d *jx.Decoder, k []byte) error { switch string(k) { - case "bundle_identifier": - if err := func() error { - s.BundleIdentifier.Reset() - if err := s.BundleIdentifier.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"bundle_identifier\"") - } - case "display_name": - if err := func() error { - s.DisplayName.Reset() - if err := s.DisplayName.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"display_name\"") - } - case "type": - if err := func() error { - s.Type.Reset() - if err := s.Type.Decode(d); err != nil { - return err - } - return nil - }(); err != nil { - return errors.Wrap(err, "decode field \"type\"") - } - case "version": + case "handle": if err := func() error { - s.Version.Reset() - if err := s.Version.Decode(d); err != nil { + s.Handle.Reset() + if err := s.Handle.Decode(d); err != nil { return err } return nil }(); err != nil { - return errors.Wrap(err, "decode field \"version\"") + return errors.Wrap(err, "decode field \"handle\"") } default: return d.Skip() } return nil }); err != nil { - return errors.Wrap(err, "decode StartPreviewsMultipartUploadReq") - } - - return nil -} - -// MarshalJSON implements stdjson.Marshaler. -func (s *StartPreviewsMultipartUploadReq) MarshalJSON() ([]byte, error) { - e := jx.Encoder{} - s.Encode(&e) - return e.Bytes(), nil -} - -// UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartPreviewsMultipartUploadReq) UnmarshalJSON(data []byte) error { - d := jx.DecodeBytes(data) - return s.Decode(d) -} - -// Encode encodes StartPreviewsMultipartUploadReqType as json. -func (s StartPreviewsMultipartUploadReqType) Encode(e *jx.Encoder) { - e.Str(string(s)) -} - -// Decode decodes StartPreviewsMultipartUploadReqType from json. -func (s *StartPreviewsMultipartUploadReqType) Decode(d *jx.Decoder) error { - if s == nil { - return errors.New("invalid: unable to decode StartPreviewsMultipartUploadReqType to nil") - } - v, err := d.StrBytes() - if err != nil { - return err - } - // Try to use constant string. - switch StartPreviewsMultipartUploadReqType(v) { - case StartPreviewsMultipartUploadReqTypeAppBundle: - *s = StartPreviewsMultipartUploadReqTypeAppBundle - case StartPreviewsMultipartUploadReqTypeIpa: - *s = StartPreviewsMultipartUploadReqTypeIpa - default: - *s = StartPreviewsMultipartUploadReqType(v) + return errors.Wrap(err, "decode UpdateAccountReq") } return nil } // MarshalJSON implements stdjson.Marshaler. -func (s StartPreviewsMultipartUploadReqType) MarshalJSON() ([]byte, error) { +func (s *UpdateAccountReq) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartPreviewsMultipartUploadReqType) UnmarshalJSON(data []byte) error { +func (s *UpdateAccountReq) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } -// Encode encodes StartPreviewsMultipartUploadUnauthorized as json. -func (s *StartPreviewsMultipartUploadUnauthorized) Encode(e *jx.Encoder) { +// Encode encodes UpdateAccountUnauthorized as json. +func (s *UpdateAccountUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) unwrapped.Encode(e) } -// Decode decodes StartPreviewsMultipartUploadUnauthorized from json. -func (s *StartPreviewsMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { +// Decode decodes UpdateAccountUnauthorized from json. +func (s *UpdateAccountUnauthorized) Decode(d *jx.Decoder) error { if s == nil { - return errors.New("invalid: unable to decode StartPreviewsMultipartUploadUnauthorized to nil") + return errors.New("invalid: unable to decode UpdateAccountUnauthorized to nil") } var unwrapped Error if err := func() error { @@ -10427,19 +12758,19 @@ func (s *StartPreviewsMultipartUploadUnauthorized) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "alias") } - *s = StartPreviewsMultipartUploadUnauthorized(unwrapped) + *s = UpdateAccountUnauthorized(unwrapped) return nil } // MarshalJSON implements stdjson.Marshaler. -func (s *StartPreviewsMultipartUploadUnauthorized) MarshalJSON() ([]byte, error) { +func (s *UpdateAccountUnauthorized) MarshalJSON() ([]byte, error) { e := jx.Encoder{} s.Encode(&e) return e.Bytes(), nil } // UnmarshalJSON implements stdjson.Unmarshaler. -func (s *StartPreviewsMultipartUploadUnauthorized) UnmarshalJSON(data []byte) error { +func (s *UpdateAccountUnauthorized) UnmarshalJSON(data []byte) error { d := jx.DecodeBytes(data) return s.Decode(d) } @@ -10656,6 +12987,8 @@ func (s *UpdateOrganization2ReqSSOProvider) Decode(d *jx.Decoder) error { switch UpdateOrganization2ReqSSOProvider(v) { case UpdateOrganization2ReqSSOProviderGoogle: *s = UpdateOrganization2ReqSSOProviderGoogle + case UpdateOrganization2ReqSSOProviderOkta: + *s = UpdateOrganization2ReqSSOProviderOkta case UpdateOrganization2ReqSSOProviderNone: *s = UpdateOrganization2ReqSSOProviderNone default: @@ -11214,6 +13547,8 @@ func (s *UpdateOrganizationReqSSOProvider) Decode(d *jx.Decoder) error { switch UpdateOrganizationReqSSOProvider(v) { case UpdateOrganizationReqSSOProviderGoogle: *s = UpdateOrganizationReqSSOProviderGoogle + case UpdateOrganizationReqSSOProviderOkta: + *s = UpdateOrganizationReqSSOProviderOkta case UpdateOrganizationReqSSOProviderNone: *s = UpdateOrganizationReqSSOProviderNone default: @@ -11409,11 +13744,18 @@ func (s *UpdateProjectReq) encodeFields(e *jx.Encoder) { s.RepositoryURL.Encode(e) } } + { + if s.Visibility.Set { + e.FieldStart("visibility") + s.Visibility.Encode(e) + } + } } -var jsonFieldsNameOfUpdateProjectReq = [2]string{ +var jsonFieldsNameOfUpdateProjectReq = [3]string{ 0: "default_branch", 1: "repository_url", + 2: "visibility", } // Decode decodes UpdateProjectReq from json. @@ -11444,6 +13786,16 @@ func (s *UpdateProjectReq) Decode(d *jx.Decoder) error { }(); err != nil { return errors.Wrap(err, "decode field \"repository_url\"") } + case "visibility": + if err := func() error { + s.Visibility.Reset() + if err := s.Visibility.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "decode field \"visibility\"") + } default: return d.Skip() } @@ -11468,6 +13820,46 @@ func (s *UpdateProjectReq) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes UpdateProjectReqVisibility as json. +func (s UpdateProjectReqVisibility) Encode(e *jx.Encoder) { + e.Str(string(s)) +} + +// Decode decodes UpdateProjectReqVisibility from json. +func (s *UpdateProjectReqVisibility) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UpdateProjectReqVisibility to nil") + } + v, err := d.StrBytes() + if err != nil { + return err + } + // Try to use constant string. + switch UpdateProjectReqVisibility(v) { + case UpdateProjectReqVisibilityPublic: + *s = UpdateProjectReqVisibilityPublic + case UpdateProjectReqVisibilityPrivate: + *s = UpdateProjectReqVisibilityPrivate + default: + *s = UpdateProjectReqVisibility(v) + } + + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s UpdateProjectReqVisibility) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UpdateProjectReqVisibility) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode encodes UpdateProjectUnauthorized as json. func (s *UpdateProjectUnauthorized) Encode(e *jx.Encoder) { unwrapped := (*Error)(s) @@ -11835,6 +14227,120 @@ func (s *UploadCacheActionItemUnauthorized) UnmarshalJSON(data []byte) error { return s.Decode(d) } +// Encode encodes UploadPreviewIconForbidden as json. +func (s *UploadPreviewIconForbidden) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes UploadPreviewIconForbidden from json. +func (s *UploadPreviewIconForbidden) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UploadPreviewIconForbidden to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = UploadPreviewIconForbidden(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UploadPreviewIconForbidden) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UploadPreviewIconForbidden) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UploadPreviewIconNotFound as json. +func (s *UploadPreviewIconNotFound) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes UploadPreviewIconNotFound from json. +func (s *UploadPreviewIconNotFound) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UploadPreviewIconNotFound to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = UploadPreviewIconNotFound(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UploadPreviewIconNotFound) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UploadPreviewIconNotFound) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + +// Encode encodes UploadPreviewIconUnauthorized as json. +func (s *UploadPreviewIconUnauthorized) Encode(e *jx.Encoder) { + unwrapped := (*Error)(s) + + unwrapped.Encode(e) +} + +// Decode decodes UploadPreviewIconUnauthorized from json. +func (s *UploadPreviewIconUnauthorized) Decode(d *jx.Decoder) error { + if s == nil { + return errors.New("invalid: unable to decode UploadPreviewIconUnauthorized to nil") + } + var unwrapped Error + if err := func() error { + if err := unwrapped.Decode(d); err != nil { + return err + } + return nil + }(); err != nil { + return errors.Wrap(err, "alias") + } + *s = UploadPreviewIconUnauthorized(unwrapped) + return nil +} + +// MarshalJSON implements stdjson.Marshaler. +func (s *UploadPreviewIconUnauthorized) MarshalJSON() ([]byte, error) { + e := jx.Encoder{} + s.Encode(&e) + return e.Bytes(), nil +} + +// UnmarshalJSON implements stdjson.Unmarshaler. +func (s *UploadPreviewIconUnauthorized) UnmarshalJSON(data []byte) error { + d := jx.DecodeBytes(data) + return s.Decode(d) +} + // Encode implements json.Marshaler. func (s *User) Encode(e *jx.Encoder) { e.ObjStart() diff --git a/internal/agent/http_cache/tuistcache/api/oas_parameters_gen.go b/internal/agent/http_cache/tuistcache/api/oas_parameters_gen.go index 866abd0f..bdd9b1cc 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_parameters_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_parameters_gen.go @@ -3,6 +3,7 @@ package api import ( + "fmt" "net/http" "net/url" @@ -235,6 +236,72 @@ func decodeCacheArtifactExistsParams(args [0]string, argsEscaped bool, r *http.R return params, nil } +// CancelInvitationParams is parameters of cancelInvitation operation. +type CancelInvitationParams struct { + // The name of the organization. + OrganizationName string +} + +func unpackCancelInvitationParams(packed middleware.Parameters) (params CancelInvitationParams) { + { + key := middleware.ParameterKey{ + Name: "organization_name", + In: "path", + } + params.OrganizationName = packed[key].(string) + } + return params +} + +func decodeCancelInvitationParams(args [1]string, argsEscaped bool, r *http.Request) (params CancelInvitationParams, _ error) { + // Decode path: organization_name. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "organization_name", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.OrganizationName = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "organization_name", + In: "path", + Err: err, + } + } + return params, nil +} + // CleanCacheParams is parameters of cleanCache operation. type CleanCacheParams struct { // The name of the account that the project belongs to. @@ -872,6 +939,72 @@ func decodeCompletePreviewsMultipartUploadParams(args [2]string, argsEscaped boo return params, nil } +// CreateAccountTokenParams is parameters of createAccountToken operation. +type CreateAccountTokenParams struct { + // The account handle. + AccountHandle string +} + +func unpackCreateAccountTokenParams(packed middleware.Parameters) (params CreateAccountTokenParams) { + { + key := middleware.ParameterKey{ + Name: "account_handle", + In: "path", + } + params.AccountHandle = packed[key].(string) + } + return params +} + +func decodeCreateAccountTokenParams(args [1]string, argsEscaped bool, r *http.Request) (params CreateAccountTokenParams, _ error) { + // Decode path: account_handle. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "account_handle", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.AccountHandle = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "account_handle", + In: "path", + Err: err, + } + } + return params, nil +} + // CreateCommandEventParams is parameters of createCommandEvent operation. type CreateCommandEventParams struct { // The project id. @@ -2430,15 +2563,24 @@ func decodeGetDeviceCodeParams(args [1]string, argsEscaped bool, r *http.Request return params, nil } -// ListProjectTokensParams is parameters of listProjectTokens operation. -type ListProjectTokensParams struct { - // The account handle. +// ListPreviewsParams is parameters of listPreviews operation. +type ListPreviewsParams struct { + // The handle of the account. AccountHandle string - // The project handle. + // The handle of the project. ProjectHandle string + // The display name of previews. + DisplayName OptString + // The preview version specifier. Currently, accepts a commit SHA, branch name, or latest. + Specifier OptString + SupportedPlatforms []PreviewSupportedPlatform + PageSize OptInt + Page OptInt + // Distinct fields – no two previews will be returned with this field having the same value. + DistinctField OptListPreviewsDistinctField } -func unpackListProjectTokensParams(packed middleware.Parameters) (params ListProjectTokensParams) { +func unpackListPreviewsParams(packed middleware.Parameters) (params ListPreviewsParams) { { key := middleware.ParameterKey{ Name: "account_handle", @@ -2453,10 +2595,65 @@ func unpackListProjectTokensParams(packed middleware.Parameters) (params ListPro } params.ProjectHandle = packed[key].(string) } + { + key := middleware.ParameterKey{ + Name: "display_name", + In: "query", + } + if v, ok := packed[key]; ok { + params.DisplayName = v.(OptString) + } + } + { + key := middleware.ParameterKey{ + Name: "specifier", + In: "query", + } + if v, ok := packed[key]; ok { + params.Specifier = v.(OptString) + } + } + { + key := middleware.ParameterKey{ + Name: "supported_platforms", + In: "query", + } + if v, ok := packed[key]; ok { + params.SupportedPlatforms = v.([]PreviewSupportedPlatform) + } + } + { + key := middleware.ParameterKey{ + Name: "page_size", + In: "query", + } + if v, ok := packed[key]; ok { + params.PageSize = v.(OptInt) + } + } + { + key := middleware.ParameterKey{ + Name: "page", + In: "query", + } + if v, ok := packed[key]; ok { + params.Page = v.(OptInt) + } + } + { + key := middleware.ParameterKey{ + Name: "distinct_field", + In: "query", + } + if v, ok := packed[key]; ok { + params.DistinctField = v.(OptListPreviewsDistinctField) + } + } return params } -func decodeListProjectTokensParams(args [2]string, argsEscaped bool, r *http.Request) (params ListProjectTokensParams, _ error) { +func decodeListPreviewsParams(args [2]string, argsEscaped bool, r *http.Request) (params ListPreviewsParams, _ error) { + q := uri.NewQueryDecoder(r.URL.Query()) // Decode path: account_handle. if err := func() error { param := args[0] @@ -2547,77 +2744,1029 @@ func decodeListProjectTokensParams(args [2]string, argsEscaped bool, r *http.Req Err: err, } } - return params, nil -} - -// RevokeProjectTokenParams is parameters of revokeProjectToken operation. -type RevokeProjectTokenParams struct { - // The account handle. - AccountHandle string - // The project handle. - ProjectHandle string - // The ID of the project token. - ID string -} - -func unpackRevokeProjectTokenParams(packed middleware.Parameters) (params RevokeProjectTokenParams) { - { - key := middleware.ParameterKey{ - Name: "account_handle", - In: "path", - } - params.AccountHandle = packed[key].(string) - } - { - key := middleware.ParameterKey{ - Name: "project_handle", - In: "path", - } - params.ProjectHandle = packed[key].(string) - } - { - key := middleware.ParameterKey{ - Name: "id", - In: "path", - } - params.ID = packed[key].(string) - } - return params -} - -func decodeRevokeProjectTokenParams(args [3]string, argsEscaped bool, r *http.Request) (params RevokeProjectTokenParams, _ error) { - // Decode path: account_handle. + // Decode query: display_name. if err := func() error { - param := args[0] - if argsEscaped { - unescaped, err := url.PathUnescape(args[0]) - if err != nil { - return errors.Wrap(err, "unescape path") - } - param = unescaped + cfg := uri.QueryParameterDecodingConfig{ + Name: "display_name", + Style: uri.QueryStyleForm, + Explode: true, } - if len(param) > 0 { - d := uri.NewPathDecoder(uri.PathDecoderConfig{ - Param: "account_handle", - Value: param, - Style: uri.PathStyleSimple, - Explode: false, - }) - if err := func() error { - val, err := d.DecodeValue() - if err != nil { - return err - } + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotDisplayNameVal string + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } - c, err := conv.ToString(val) - if err != nil { + c, err := conv.ToString(val) + if err != nil { + return err + } + + paramsDotDisplayNameVal = c + return nil + }(); err != nil { return err } - - params.AccountHandle = c + params.DisplayName.SetTo(paramsDotDisplayNameVal) return nil - }(); err != nil { + }); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "display_name", + In: "query", + Err: err, + } + } + // Decode query: specifier. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "specifier", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotSpecifierVal string + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + paramsDotSpecifierVal = c + return nil + }(); err != nil { + return err + } + params.Specifier.SetTo(paramsDotSpecifierVal) + return nil + }); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "specifier", + In: "query", + Err: err, + } + } + // Decode query: supported_platforms. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "supported_platforms", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + return d.DecodeArray(func(d uri.Decoder) error { + var paramsDotSupportedPlatformsVal PreviewSupportedPlatform + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + paramsDotSupportedPlatformsVal = PreviewSupportedPlatform(c) + return nil + }(); err != nil { + return err + } + params.SupportedPlatforms = append(params.SupportedPlatforms, paramsDotSupportedPlatformsVal) + return nil + }) + }); err != nil { + return err + } + if err := func() error { + var failures []validate.FieldError + for i, elem := range params.SupportedPlatforms { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "supported_platforms", + In: "query", + Err: err, + } + } + // Set default value for query: page_size. + { + val := int(10) + params.PageSize.SetTo(val) + } + // Decode query: page_size. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "page_size", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotPageSizeVal int + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + paramsDotPageSizeVal = c + return nil + }(); err != nil { + return err + } + params.PageSize.SetTo(paramsDotPageSizeVal) + return nil + }); err != nil { + return err + } + if err := func() error { + if value, ok := params.PageSize.Get(); ok { + if err := func() error { + if err := (validate.Int{ + MinSet: true, + Min: 1, + MaxSet: true, + Max: 20, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + }).Validate(int64(value)); err != nil { + return errors.Wrap(err, "int") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "page_size", + In: "query", + Err: err, + } + } + // Set default value for query: page. + { + val := int(1) + params.Page.SetTo(val) + } + // Decode query: page. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "page", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotPageVal int + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + paramsDotPageVal = c + return nil + }(); err != nil { + return err + } + params.Page.SetTo(paramsDotPageVal) + return nil + }); err != nil { + return err + } + if err := func() error { + if value, ok := params.Page.Get(); ok { + if err := func() error { + if err := (validate.Int{ + MinSet: true, + Min: 1, + MaxSet: false, + Max: 0, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + }).Validate(int64(value)); err != nil { + return errors.Wrap(err, "int") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "page", + In: "query", + Err: err, + } + } + // Decode query: distinct_field. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "distinct_field", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotDistinctFieldVal ListPreviewsDistinctField + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + paramsDotDistinctFieldVal = ListPreviewsDistinctField(c) + return nil + }(); err != nil { + return err + } + params.DistinctField.SetTo(paramsDotDistinctFieldVal) + return nil + }); err != nil { + return err + } + if err := func() error { + if value, ok := params.DistinctField.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "distinct_field", + In: "query", + Err: err, + } + } + return params, nil +} + +// ListProjectTokensParams is parameters of listProjectTokens operation. +type ListProjectTokensParams struct { + // The account handle. + AccountHandle string + // The project handle. + ProjectHandle string +} + +func unpackListProjectTokensParams(packed middleware.Parameters) (params ListProjectTokensParams) { + { + key := middleware.ParameterKey{ + Name: "account_handle", + In: "path", + } + params.AccountHandle = packed[key].(string) + } + { + key := middleware.ParameterKey{ + Name: "project_handle", + In: "path", + } + params.ProjectHandle = packed[key].(string) + } + return params +} + +func decodeListProjectTokensParams(args [2]string, argsEscaped bool, r *http.Request) (params ListProjectTokensParams, _ error) { + // Decode path: account_handle. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "account_handle", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.AccountHandle = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "account_handle", + In: "path", + Err: err, + } + } + // Decode path: project_handle. + if err := func() error { + param := args[1] + if argsEscaped { + unescaped, err := url.PathUnescape(args[1]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "project_handle", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.ProjectHandle = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "project_handle", + In: "path", + Err: err, + } + } + return params, nil +} + +// ListRunsParams is parameters of listRuns operation. +type ListRunsParams struct { + // The handle of the account. + AccountHandle string + // The handle of the project. + ProjectHandle string + // The name of the run. + Name OptString + // The git ref of the run. + GitRef OptString + // The git branch of the run. + GitBranch OptString + // The git commit SHA of the run. + GitCommitSha OptString + PageSize OptInt + Page OptInt +} + +func unpackListRunsParams(packed middleware.Parameters) (params ListRunsParams) { + { + key := middleware.ParameterKey{ + Name: "account_handle", + In: "path", + } + params.AccountHandle = packed[key].(string) + } + { + key := middleware.ParameterKey{ + Name: "project_handle", + In: "path", + } + params.ProjectHandle = packed[key].(string) + } + { + key := middleware.ParameterKey{ + Name: "name", + In: "query", + } + if v, ok := packed[key]; ok { + params.Name = v.(OptString) + } + } + { + key := middleware.ParameterKey{ + Name: "git_ref", + In: "query", + } + if v, ok := packed[key]; ok { + params.GitRef = v.(OptString) + } + } + { + key := middleware.ParameterKey{ + Name: "git_branch", + In: "query", + } + if v, ok := packed[key]; ok { + params.GitBranch = v.(OptString) + } + } + { + key := middleware.ParameterKey{ + Name: "git_commit_sha", + In: "query", + } + if v, ok := packed[key]; ok { + params.GitCommitSha = v.(OptString) + } + } + { + key := middleware.ParameterKey{ + Name: "page_size", + In: "query", + } + if v, ok := packed[key]; ok { + params.PageSize = v.(OptInt) + } + } + { + key := middleware.ParameterKey{ + Name: "page", + In: "query", + } + if v, ok := packed[key]; ok { + params.Page = v.(OptInt) + } + } + return params +} + +func decodeListRunsParams(args [2]string, argsEscaped bool, r *http.Request) (params ListRunsParams, _ error) { + q := uri.NewQueryDecoder(r.URL.Query()) + // Decode path: account_handle. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "account_handle", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.AccountHandle = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "account_handle", + In: "path", + Err: err, + } + } + // Decode path: project_handle. + if err := func() error { + param := args[1] + if argsEscaped { + unescaped, err := url.PathUnescape(args[1]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "project_handle", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.ProjectHandle = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "project_handle", + In: "path", + Err: err, + } + } + // Decode query: name. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "name", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotNameVal string + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + paramsDotNameVal = c + return nil + }(); err != nil { + return err + } + params.Name.SetTo(paramsDotNameVal) + return nil + }); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "name", + In: "query", + Err: err, + } + } + // Decode query: git_ref. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "git_ref", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotGitRefVal string + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + paramsDotGitRefVal = c + return nil + }(); err != nil { + return err + } + params.GitRef.SetTo(paramsDotGitRefVal) + return nil + }); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "git_ref", + In: "query", + Err: err, + } + } + // Decode query: git_branch. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "git_branch", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotGitBranchVal string + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + paramsDotGitBranchVal = c + return nil + }(); err != nil { + return err + } + params.GitBranch.SetTo(paramsDotGitBranchVal) + return nil + }); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "git_branch", + In: "query", + Err: err, + } + } + // Decode query: git_commit_sha. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "git_commit_sha", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotGitCommitShaVal string + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + paramsDotGitCommitShaVal = c + return nil + }(); err != nil { + return err + } + params.GitCommitSha.SetTo(paramsDotGitCommitShaVal) + return nil + }); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "git_commit_sha", + In: "query", + Err: err, + } + } + // Set default value for query: page_size. + { + val := int(20) + params.PageSize.SetTo(val) + } + // Decode query: page_size. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "page_size", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotPageSizeVal int + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + paramsDotPageSizeVal = c + return nil + }(); err != nil { + return err + } + params.PageSize.SetTo(paramsDotPageSizeVal) + return nil + }); err != nil { + return err + } + if err := func() error { + if value, ok := params.PageSize.Get(); ok { + if err := func() error { + if err := (validate.Int{ + MinSet: true, + Min: 1, + MaxSet: true, + Max: 100, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + }).Validate(int64(value)); err != nil { + return errors.Wrap(err, "int") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "page_size", + In: "query", + Err: err, + } + } + // Set default value for query: page. + { + val := int(1) + params.Page.SetTo(val) + } + // Decode query: page. + if err := func() error { + cfg := uri.QueryParameterDecodingConfig{ + Name: "page", + Style: uri.QueryStyleForm, + Explode: true, + } + + if err := q.HasParam(cfg); err == nil { + if err := q.DecodeParam(cfg, func(d uri.Decoder) error { + var paramsDotPageVal int + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToInt(val) + if err != nil { + return err + } + + paramsDotPageVal = c + return nil + }(); err != nil { + return err + } + params.Page.SetTo(paramsDotPageVal) + return nil + }); err != nil { + return err + } + if err := func() error { + if value, ok := params.Page.Get(); ok { + if err := func() error { + if err := (validate.Int{ + MinSet: true, + Min: 1, + MaxSet: false, + Max: 0, + MinExclusive: false, + MaxExclusive: false, + MultipleOfSet: false, + MultipleOf: 0, + }).Validate(int64(value)); err != nil { + return errors.Wrap(err, "int") + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "page", + In: "query", + Err: err, + } + } + return params, nil +} + +// RevokeProjectTokenParams is parameters of revokeProjectToken operation. +type RevokeProjectTokenParams struct { + // The account handle. + AccountHandle string + // The project handle. + ProjectHandle string + // The ID of the project token. + ID string +} + +func unpackRevokeProjectTokenParams(packed middleware.Parameters) (params RevokeProjectTokenParams) { + { + key := middleware.ParameterKey{ + Name: "account_handle", + In: "path", + } + params.AccountHandle = packed[key].(string) + } + { + key := middleware.ParameterKey{ + Name: "project_handle", + In: "path", + } + params.ProjectHandle = packed[key].(string) + } + { + key := middleware.ParameterKey{ + Name: "id", + In: "path", + } + params.ID = packed[key].(string) + } + return params +} + +func decodeRevokeProjectTokenParams(args [3]string, argsEscaped bool, r *http.Request) (params RevokeProjectTokenParams, _ error) { + // Decode path: account_handle. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "account_handle", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.AccountHandle = c + return nil + }(); err != nil { return err } } else { @@ -3382,6 +4531,72 @@ func decodeStartPreviewsMultipartUploadParams(args [2]string, argsEscaped bool, return params, nil } +// UpdateAccountParams is parameters of updateAccount operation. +type UpdateAccountParams struct { + // The handle of the account. + AccountHandle string +} + +func unpackUpdateAccountParams(packed middleware.Parameters) (params UpdateAccountParams) { + { + key := middleware.ParameterKey{ + Name: "account_handle", + In: "path", + } + params.AccountHandle = packed[key].(string) + } + return params +} + +func decodeUpdateAccountParams(args [1]string, argsEscaped bool, r *http.Request) (params UpdateAccountParams, _ error) { + // Decode path: account_handle. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "account_handle", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.AccountHandle = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "account_handle", + In: "path", + Err: err, + } + } + return params, nil +} + // UpdateOrganizationParams is parameters of updateOrganization operation. type UpdateOrganizationParams struct { // The name of the organization to update. @@ -3873,3 +5088,177 @@ func decodeUploadCacheActionItemParams(args [2]string, argsEscaped bool, r *http } return params, nil } + +// UploadPreviewIconParams is parameters of uploadPreviewIcon operation. +type UploadPreviewIconParams struct { + // The handle of the account. + AccountHandle string + // The handle of the project. + ProjectHandle string + // The preview identifier. + PreviewID string +} + +func unpackUploadPreviewIconParams(packed middleware.Parameters) (params UploadPreviewIconParams) { + { + key := middleware.ParameterKey{ + Name: "account_handle", + In: "path", + } + params.AccountHandle = packed[key].(string) + } + { + key := middleware.ParameterKey{ + Name: "project_handle", + In: "path", + } + params.ProjectHandle = packed[key].(string) + } + { + key := middleware.ParameterKey{ + Name: "preview_id", + In: "path", + } + params.PreviewID = packed[key].(string) + } + return params +} + +func decodeUploadPreviewIconParams(args [3]string, argsEscaped bool, r *http.Request) (params UploadPreviewIconParams, _ error) { + // Decode path: account_handle. + if err := func() error { + param := args[0] + if argsEscaped { + unescaped, err := url.PathUnescape(args[0]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "account_handle", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.AccountHandle = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "account_handle", + In: "path", + Err: err, + } + } + // Decode path: project_handle. + if err := func() error { + param := args[1] + if argsEscaped { + unescaped, err := url.PathUnescape(args[1]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "project_handle", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.ProjectHandle = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "project_handle", + In: "path", + Err: err, + } + } + // Decode path: preview_id. + if err := func() error { + param := args[2] + if argsEscaped { + unescaped, err := url.PathUnescape(args[2]) + if err != nil { + return errors.Wrap(err, "unescape path") + } + param = unescaped + } + if len(param) > 0 { + d := uri.NewPathDecoder(uri.PathDecoderConfig{ + Param: "preview_id", + Value: param, + Style: uri.PathStyleSimple, + Explode: false, + }) + + if err := func() error { + val, err := d.DecodeValue() + if err != nil { + return err + } + + c, err := conv.ToString(val) + if err != nil { + return err + } + + params.PreviewID = c + return nil + }(); err != nil { + return err + } + } else { + return validate.ErrFieldRequired + } + return nil + }(); err != nil { + return params, &ogenerrors.DecodeParamError{ + Name: "preview_id", + In: "path", + Err: err, + } + } + return params, nil +} diff --git a/internal/agent/http_cache/tuistcache/api/oas_request_decoders_gen.go b/internal/agent/http_cache/tuistcache/api/oas_request_decoders_gen.go index 61c8cd58..0c201de5 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_request_decoders_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_request_decoders_gen.go @@ -82,6 +82,73 @@ func (s *Server) decodeAuthenticateRequest(r *http.Request) ( } } +func (s *Server) decodeCancelInvitationRequest(r *http.Request) ( + req OptCancelInvitationReq, + close func() error, + rerr error, +) { + var closers []func() error + close = func() error { + var merr error + // Close in reverse order, to match defer behavior. + for i := len(closers) - 1; i >= 0; i-- { + c := closers[i] + merr = multierr.Append(merr, c()) + } + return merr + } + defer func() { + if rerr != nil { + rerr = multierr.Append(rerr, close()) + } + }() + if _, ok := r.Header["Content-Type"]; !ok && r.ContentLength == 0 { + return req, close, nil + } + ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return req, close, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + if r.ContentLength == 0 { + return req, close, nil + } + buf, err := io.ReadAll(r.Body) + if err != nil { + return req, close, err + } + + if len(buf) == 0 { + return req, close, nil + } + + d := jx.DecodeBytes(buf) + + var request OptCancelInvitationReq + if err := func() error { + request.Reset() + if err := request.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return req, close, err + } + return request, close, nil + default: + return req, close, validate.InvalidContentType(ct) + } +} + func (s *Server) decodeCompleteAnalyticsArtifactMultipartUploadRequest(r *http.Request) ( req OptCompleteAnalyticsArtifactMultipartUploadReq, close func() error, @@ -395,6 +462,88 @@ func (s *Server) decodeCompletePreviewsMultipartUploadRequest(r *http.Request) ( } } +func (s *Server) decodeCreateAccountTokenRequest(r *http.Request) ( + req OptCreateAccountTokenReq, + close func() error, + rerr error, +) { + var closers []func() error + close = func() error { + var merr error + // Close in reverse order, to match defer behavior. + for i := len(closers) - 1; i >= 0; i-- { + c := closers[i] + merr = multierr.Append(merr, c()) + } + return merr + } + defer func() { + if rerr != nil { + rerr = multierr.Append(rerr, close()) + } + }() + if _, ok := r.Header["Content-Type"]; !ok && r.ContentLength == 0 { + return req, close, nil + } + ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return req, close, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + if r.ContentLength == 0 { + return req, close, nil + } + buf, err := io.ReadAll(r.Body) + if err != nil { + return req, close, err + } + + if len(buf) == 0 { + return req, close, nil + } + + d := jx.DecodeBytes(buf) + + var request OptCreateAccountTokenReq + if err := func() error { + request.Reset() + if err := request.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return req, close, err + } + if err := func() error { + if value, ok := request.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return req, close, errors.Wrap(err, "validate") + } + return request, close, nil + default: + return req, close, validate.InvalidContentType(ct) + } +} + func (s *Server) decodeCreateCommandEventRequest(r *http.Request) ( req OptCreateCommandEventReq, close func() error, @@ -739,6 +888,21 @@ func (s *Server) decodeGenerateAnalyticsArtifactMultipartUploadURLRequest(r *htt } return req, close, err } + if err := func() error { + if value, ok := request.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return req, close, errors.Wrap(err, "validate") + } return request, close, nil default: return req, close, validate.InvalidContentType(ct) @@ -880,7 +1044,7 @@ func (s *Server) decodeRefreshTokenRequest(r *http.Request) ( } func (s *Server) decodeStartAnalyticsArtifactMultipartUploadRequest(r *http.Request) ( - req CommandEventArtifact, + req OptCommandEventArtifact, close func() error, rerr error, ) { @@ -922,8 +1086,9 @@ func (s *Server) decodeStartAnalyticsArtifactMultipartUploadRequest(r *http.Requ d := jx.DecodeBytes(buf) - var request CommandEventArtifact + var request OptCommandEventArtifact if err := func() error { + request.Reset() if err := request.Decode(d); err != nil { return err } @@ -939,6 +1104,21 @@ func (s *Server) decodeStartAnalyticsArtifactMultipartUploadRequest(r *http.Requ } return req, close, err } + if err := func() error { + if value, ok := request.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return req, close, errors.Wrap(err, "validate") + } return request, close, nil default: return req, close, validate.InvalidContentType(ct) @@ -1027,6 +1207,73 @@ func (s *Server) decodeStartPreviewsMultipartUploadRequest(r *http.Request) ( } } +func (s *Server) decodeUpdateAccountRequest(r *http.Request) ( + req OptUpdateAccountReq, + close func() error, + rerr error, +) { + var closers []func() error + close = func() error { + var merr error + // Close in reverse order, to match defer behavior. + for i := len(closers) - 1; i >= 0; i-- { + c := closers[i] + merr = multierr.Append(merr, c()) + } + return merr + } + defer func() { + if rerr != nil { + rerr = multierr.Append(rerr, close()) + } + }() + if _, ok := r.Header["Content-Type"]; !ok && r.ContentLength == 0 { + return req, close, nil + } + ct, _, err := mime.ParseMediaType(r.Header.Get("Content-Type")) + if err != nil { + return req, close, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + if r.ContentLength == 0 { + return req, close, nil + } + buf, err := io.ReadAll(r.Body) + if err != nil { + return req, close, err + } + + if len(buf) == 0 { + return req, close, nil + } + + d := jx.DecodeBytes(buf) + + var request OptUpdateAccountReq + if err := func() error { + request.Reset() + if err := request.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return req, close, err + } + return request, close, nil + default: + return req, close, validate.InvalidContentType(ct) + } +} + func (s *Server) decodeUpdateOrganizationRequest(r *http.Request) ( req OptUpdateOrganizationReq, close func() error, @@ -1334,6 +1581,21 @@ func (s *Server) decodeUpdateProjectRequest(r *http.Request) ( } return req, close, err } + if err := func() error { + if value, ok := request.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + return req, close, errors.Wrap(err, "validate") + } return request, close, nil default: return req, close, validate.InvalidContentType(ct) diff --git a/internal/agent/http_cache/tuistcache/api/oas_request_encoders_gen.go b/internal/agent/http_cache/tuistcache/api/oas_request_encoders_gen.go index 1465f3f7..a9b44457 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_request_encoders_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_request_encoders_gen.go @@ -31,6 +31,26 @@ func encodeAuthenticateRequest( return nil } +func encodeCancelInvitationRequest( + req OptCancelInvitationReq, + r *http.Request, +) error { + const contentType = "application/json" + if !req.Set { + // Keep request with empty body if value is not set. + return nil + } + e := new(jx.Encoder) + { + if req.Set { + req.Encode(e) + } + } + encoded := e.Bytes() + ht.SetBody(r, bytes.NewReader(encoded), contentType) + return nil +} + func encodeCompleteAnalyticsArtifactMultipartUploadRequest( req OptCompleteAnalyticsArtifactMultipartUploadReq, r *http.Request, @@ -111,6 +131,26 @@ func encodeCompletePreviewsMultipartUploadRequest( return nil } +func encodeCreateAccountTokenRequest( + req OptCreateAccountTokenReq, + r *http.Request, +) error { + const contentType = "application/json" + if !req.Set { + // Keep request with empty body if value is not set. + return nil + } + e := new(jx.Encoder) + { + if req.Set { + req.Encode(e) + } + } + encoded := e.Bytes() + ht.SetBody(r, bytes.NewReader(encoded), contentType) + return nil +} + func encodeCreateCommandEventRequest( req OptCreateCommandEventReq, r *http.Request, @@ -252,13 +292,19 @@ func encodeRefreshTokenRequest( } func encodeStartAnalyticsArtifactMultipartUploadRequest( - req CommandEventArtifact, + req OptCommandEventArtifact, r *http.Request, ) error { const contentType = "application/json" + if !req.Set { + // Keep request with empty body if value is not set. + return nil + } e := new(jx.Encoder) { - req.Encode(e) + if req.Set { + req.Encode(e) + } } encoded := e.Bytes() ht.SetBody(r, bytes.NewReader(encoded), contentType) @@ -285,6 +331,26 @@ func encodeStartPreviewsMultipartUploadRequest( return nil } +func encodeUpdateAccountRequest( + req OptUpdateAccountReq, + r *http.Request, +) error { + const contentType = "application/json" + if !req.Set { + // Keep request with empty body if value is not set. + return nil + } + e := new(jx.Encoder) + { + if req.Set { + req.Encode(e) + } + } + encoded := e.Bytes() + ht.SetBody(r, bytes.NewReader(encoded), contentType) + return nil +} + func encodeUpdateOrganizationRequest( req OptUpdateOrganizationReq, r *http.Request, diff --git a/internal/agent/http_cache/tuistcache/api/oas_response_decoders_gen.go b/internal/agent/http_cache/tuistcache/api/oas_response_decoders_gen.go index dc6f356f..8aea7e18 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_response_decoders_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_response_decoders_gen.go @@ -280,6 +280,120 @@ func decodeCacheArtifactExistsResponse(resp *http.Response) (res CacheArtifactEx return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodeCancelInvitationResponse(resp *http.Response) (res CancelInvitationRes, _ error) { + switch resp.StatusCode { + case 204: + // Code 204. + return &CancelInvitationNoContent{}, nil + case 401: + // Code 401. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response CancelInvitationUnauthorized + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 403: + // Code 403. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response CancelInvitationForbidden + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response CancelInvitationNotFound + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodeCleanCacheResponse(resp *http.Response) (res CleanCacheRes, _ error) { switch resp.StatusCode { case 204: @@ -863,7 +977,7 @@ func decodeCompletePreviewsMultipartUploadResponse(resp *http.Response) (res Com } d := jx.DecodeBytes(buf) - var response CompletePreviewsMultipartUploadOK + var response Preview if err := func() error { if err := response.Decode(d); err != nil { return err @@ -993,6 +1107,152 @@ func decodeCompletePreviewsMultipartUploadResponse(resp *http.Response) (res Com return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodeCreateAccountTokenResponse(resp *http.Response) (res CreateAccountTokenRes, _ error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response CreateAccountTokenOK + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 401: + // Code 401. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response CreateAccountTokenUnauthorized + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 403: + // Code 403. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response CreateAccountTokenForbidden + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response CreateAccountTokenNotFound + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodeCreateCommandEventResponse(resp *http.Response) (res CreateCommandEventRes, _ error) { switch resp.StatusCode { case 200: @@ -2123,7 +2383,7 @@ func decodeDownloadPreviewResponse(resp *http.Response) (res DownloadPreviewRes, } d := jx.DecodeBytes(buf) - var response ArtifactDownloadURL + var response Preview if err := func() error { if err := response.Decode(d); err != nil { return err @@ -3165,7 +3425,7 @@ func decodeListOrganizationsResponse(resp *http.Response) (res ListOrganizations return res, validate.UnexpectedStatusCode(resp.StatusCode) } -func decodeListProjectTokensResponse(resp *http.Response) (res ListProjectTokensRes, _ error) { +func decodeListPreviewsResponse(resp *http.Response) (res ListPreviewsRes, _ error) { switch resp.StatusCode { case 200: // Code 200. @@ -3181,7 +3441,7 @@ func decodeListProjectTokensResponse(resp *http.Response) (res ListProjectTokens } d := jx.DecodeBytes(buf) - var response ListProjectTokensOK + var response ListPreviewsOK if err := func() error { if err := response.Decode(d); err != nil { return err @@ -3225,7 +3485,7 @@ func decodeListProjectTokensResponse(resp *http.Response) (res ListProjectTokens } d := jx.DecodeBytes(buf) - var response ListProjectTokensUnauthorized + var response ListPreviewsUnauthorized if err := func() error { if err := response.Decode(d); err != nil { return err @@ -3260,7 +3520,7 @@ func decodeListProjectTokensResponse(resp *http.Response) (res ListProjectTokens } d := jx.DecodeBytes(buf) - var response ListProjectTokensForbidden + var response ListPreviewsForbidden if err := func() error { if err := response.Decode(d); err != nil { return err @@ -3281,8 +3541,128 @@ func decodeListProjectTokensResponse(resp *http.Response) (res ListProjectTokens default: return res, validate.InvalidContentType(ct) } - case 404: - // Code 404. + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + +func decodeListProjectTokensResponse(resp *http.Response) (res ListProjectTokensRes, _ error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response ListProjectTokensOK + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + // Validate response. + if err := func() error { + if err := response.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return res, errors.Wrap(err, "validate") + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 401: + // Code 401. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response ListProjectTokensUnauthorized + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 403: + // Code 403. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response ListProjectTokensForbidden + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) if err != nil { return res, errors.Wrap(err, "parse media type") @@ -3405,6 +3785,91 @@ func decodeListProjectsResponse(resp *http.Response) (res ListProjectsRes, _ err return res, validate.UnexpectedStatusCode(resp.StatusCode) } +func decodeListRunsResponse(resp *http.Response) (res ListRunsRes, _ error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response ListRunsOK + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + // Validate response. + if err := func() error { + if err := response.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return res, errors.Wrap(err, "validate") + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 403: + // Code 403. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response Error + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + func decodeRefreshTokenResponse(resp *http.Response) (res RefreshTokenRes, _ error) { switch resp.StatusCode { case 200: @@ -4595,7 +5060,7 @@ func decodeStartPreviewsMultipartUploadResponse(resp *http.Response) (res StartP return res, validate.UnexpectedStatusCode(resp.StatusCode) } -func decodeUpdateOrganizationResponse(resp *http.Response) (res UpdateOrganizationRes, _ error) { +func decodeUpdateAccountResponse(resp *http.Response) (res UpdateAccountRes, _ error) { switch resp.StatusCode { case 200: // Code 200. @@ -4611,7 +5076,7 @@ func decodeUpdateOrganizationResponse(resp *http.Response) (res UpdateOrganizati } d := jx.DecodeBytes(buf) - var response Organization + var response Account if err := func() error { if err := response.Decode(d); err != nil { return err @@ -4655,7 +5120,7 @@ func decodeUpdateOrganizationResponse(resp *http.Response) (res UpdateOrganizati } d := jx.DecodeBytes(buf) - var response UpdateOrganizationBadRequest + var response UpdateAccountBadRequest if err := func() error { if err := response.Decode(d); err != nil { return err @@ -4690,7 +5155,7 @@ func decodeUpdateOrganizationResponse(resp *http.Response) (res UpdateOrganizati } d := jx.DecodeBytes(buf) - var response UpdateOrganizationUnauthorized + var response UpdateAccountUnauthorized if err := func() error { if err := response.Decode(d); err != nil { return err @@ -4725,7 +5190,7 @@ func decodeUpdateOrganizationResponse(resp *http.Response) (res UpdateOrganizati } d := jx.DecodeBytes(buf) - var response UpdateOrganizationForbidden + var response UpdateAccountForbidden if err := func() error { if err := response.Decode(d); err != nil { return err @@ -4760,7 +5225,7 @@ func decodeUpdateOrganizationResponse(resp *http.Response) (res UpdateOrganizati } d := jx.DecodeBytes(buf) - var response UpdateOrganizationNotFound + var response UpdateAccountNotFound if err := func() error { if err := response.Decode(d); err != nil { return err @@ -4785,7 +5250,7 @@ func decodeUpdateOrganizationResponse(resp *http.Response) (res UpdateOrganizati return res, validate.UnexpectedStatusCode(resp.StatusCode) } -func decodeUpdateOrganization2Response(resp *http.Response) (res UpdateOrganization2Res, _ error) { +func decodeUpdateOrganizationResponse(resp *http.Response) (res UpdateOrganizationRes, _ error) { switch resp.StatusCode { case 200: // Code 200. @@ -4845,7 +5310,7 @@ func decodeUpdateOrganization2Response(resp *http.Response) (res UpdateOrganizat } d := jx.DecodeBytes(buf) - var response UpdateOrganization2BadRequest + var response UpdateOrganizationBadRequest if err := func() error { if err := response.Decode(d); err != nil { return err @@ -4880,7 +5345,7 @@ func decodeUpdateOrganization2Response(resp *http.Response) (res UpdateOrganizat } d := jx.DecodeBytes(buf) - var response UpdateOrganization2Unauthorized + var response UpdateOrganizationUnauthorized if err := func() error { if err := response.Decode(d); err != nil { return err @@ -4915,7 +5380,7 @@ func decodeUpdateOrganization2Response(resp *http.Response) (res UpdateOrganizat } d := jx.DecodeBytes(buf) - var response UpdateOrganization2Forbidden + var response UpdateOrganizationForbidden if err := func() error { if err := response.Decode(d); err != nil { return err @@ -4950,7 +5415,7 @@ func decodeUpdateOrganization2Response(resp *http.Response) (res UpdateOrganizat } d := jx.DecodeBytes(buf) - var response UpdateOrganization2NotFound + var response UpdateOrganizationNotFound if err := func() error { if err := response.Decode(d); err != nil { return err @@ -4975,7 +5440,7 @@ func decodeUpdateOrganization2Response(resp *http.Response) (res UpdateOrganizat return res, validate.UnexpectedStatusCode(resp.StatusCode) } -func decodeUpdateOrganizationMemberResponse(resp *http.Response) (res UpdateOrganizationMemberRes, _ error) { +func decodeUpdateOrganization2Response(resp *http.Response) (res UpdateOrganization2Res, _ error) { switch resp.StatusCode { case 200: // Code 200. @@ -4991,7 +5456,7 @@ func decodeUpdateOrganizationMemberResponse(resp *http.Response) (res UpdateOrga } d := jx.DecodeBytes(buf) - var response OrganizationMember + var response Organization if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5035,7 +5500,7 @@ func decodeUpdateOrganizationMemberResponse(resp *http.Response) (res UpdateOrga } d := jx.DecodeBytes(buf) - var response UpdateOrganizationMemberBadRequest + var response UpdateOrganization2BadRequest if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5070,7 +5535,7 @@ func decodeUpdateOrganizationMemberResponse(resp *http.Response) (res UpdateOrga } d := jx.DecodeBytes(buf) - var response UpdateOrganizationMemberUnauthorized + var response UpdateOrganization2Unauthorized if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5105,7 +5570,7 @@ func decodeUpdateOrganizationMemberResponse(resp *http.Response) (res UpdateOrga } d := jx.DecodeBytes(buf) - var response UpdateOrganizationMemberForbidden + var response UpdateOrganization2Forbidden if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5140,7 +5605,7 @@ func decodeUpdateOrganizationMemberResponse(resp *http.Response) (res UpdateOrga } d := jx.DecodeBytes(buf) - var response UpdateOrganizationMemberNotFound + var response UpdateOrganization2NotFound if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5165,7 +5630,7 @@ func decodeUpdateOrganizationMemberResponse(resp *http.Response) (res UpdateOrga return res, validate.UnexpectedStatusCode(resp.StatusCode) } -func decodeUpdateProjectResponse(resp *http.Response) (res UpdateProjectRes, _ error) { +func decodeUpdateOrganizationMemberResponse(resp *http.Response) (res UpdateOrganizationMemberRes, _ error) { switch resp.StatusCode { case 200: // Code 200. @@ -5181,7 +5646,7 @@ func decodeUpdateProjectResponse(resp *http.Response) (res UpdateProjectRes, _ e } d := jx.DecodeBytes(buf) - var response Project + var response OrganizationMember if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5225,7 +5690,7 @@ func decodeUpdateProjectResponse(resp *http.Response) (res UpdateProjectRes, _ e } d := jx.DecodeBytes(buf) - var response UpdateProjectBadRequest + var response UpdateOrganizationMemberBadRequest if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5260,7 +5725,7 @@ func decodeUpdateProjectResponse(resp *http.Response) (res UpdateProjectRes, _ e } d := jx.DecodeBytes(buf) - var response UpdateProjectUnauthorized + var response UpdateOrganizationMemberUnauthorized if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5295,7 +5760,7 @@ func decodeUpdateProjectResponse(resp *http.Response) (res UpdateProjectRes, _ e } d := jx.DecodeBytes(buf) - var response UpdateProjectForbidden + var response UpdateOrganizationMemberForbidden if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5330,7 +5795,7 @@ func decodeUpdateProjectResponse(resp *http.Response) (res UpdateProjectRes, _ e } d := jx.DecodeBytes(buf) - var response UpdateProjectNotFound + var response UpdateOrganizationMemberNotFound if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5355,7 +5820,7 @@ func decodeUpdateProjectResponse(resp *http.Response) (res UpdateProjectRes, _ e return res, validate.UnexpectedStatusCode(resp.StatusCode) } -func decodeUploadCacheActionItemResponse(resp *http.Response) (res UploadCacheActionItemRes, _ error) { +func decodeUpdateProjectResponse(resp *http.Response) (res UpdateProjectRes, _ error) { switch resp.StatusCode { case 200: // Code 200. @@ -5371,7 +5836,7 @@ func decodeUploadCacheActionItemResponse(resp *http.Response) (res UploadCacheAc } d := jx.DecodeBytes(buf) - var response UploadCacheActionItemOK + var response Project if err := func() error { if err := response.Decode(d); err != nil { return err @@ -5388,13 +5853,203 @@ func decodeUploadCacheActionItemResponse(resp *http.Response) (res UploadCacheAc } return res, err } - return &response, nil - default: - return res, validate.InvalidContentType(ct) - } - case 201: - // Code 201. - ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + // Validate response. + if err := func() error { + if err := response.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return res, errors.Wrap(err, "validate") + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 400: + // Code 400. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UpdateProjectBadRequest + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 401: + // Code 401. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UpdateProjectUnauthorized + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 403: + // Code 403. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UpdateProjectForbidden + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UpdateProjectNotFound + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} + +func decodeUploadCacheActionItemResponse(resp *http.Response) (res UploadCacheActionItemRes, _ error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UploadCacheActionItemOK + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 201: + // Code 201. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) if err != nil { return res, errors.Wrap(err, "parse media type") } @@ -5605,3 +6260,149 @@ func decodeUploadCacheActionItemResponse(resp *http.Response) (res UploadCacheAc } return res, validate.UnexpectedStatusCode(resp.StatusCode) } + +func decodeUploadPreviewIconResponse(resp *http.Response) (res UploadPreviewIconRes, _ error) { + switch resp.StatusCode { + case 200: + // Code 200. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response ArtifactUploadURL + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 401: + // Code 401. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UploadPreviewIconUnauthorized + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 403: + // Code 403. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UploadPreviewIconForbidden + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + case 404: + // Code 404. + ct, _, err := mime.ParseMediaType(resp.Header.Get("Content-Type")) + if err != nil { + return res, errors.Wrap(err, "parse media type") + } + switch { + case ct == "application/json": + buf, err := io.ReadAll(resp.Body) + if err != nil { + return res, err + } + d := jx.DecodeBytes(buf) + + var response UploadPreviewIconNotFound + if err := func() error { + if err := response.Decode(d); err != nil { + return err + } + if err := d.Skip(); err != io.EOF { + return errors.New("unexpected trailing data") + } + return nil + }(); err != nil { + err = &ogenerrors.DecodeBodyError{ + ContentType: ct, + Body: buf, + Err: err, + } + return res, err + } + return &response, nil + default: + return res, validate.InvalidContentType(ct) + } + } + return res, validate.UnexpectedStatusCode(resp.StatusCode) +} diff --git a/internal/agent/http_cache/tuistcache/api/oas_response_encoders_gen.go b/internal/agent/http_cache/tuistcache/api/oas_response_encoders_gen.go index ef28c3c0..9785e111 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_response_encoders_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_response_encoders_gen.go @@ -116,6 +116,58 @@ func encodeCacheArtifactExistsResponse(response CacheArtifactExistsRes, w http.R } } +func encodeCancelInvitationResponse(response CancelInvitationRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *CancelInvitationNoContent: + w.WriteHeader(204) + span.SetStatus(codes.Ok, http.StatusText(204)) + + return nil + + case *CancelInvitationUnauthorized: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(401) + span.SetStatus(codes.Error, http.StatusText(401)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CancelInvitationForbidden: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(403) + span.SetStatus(codes.Error, http.StatusText(403)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CancelInvitationNotFound: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeCleanCacheResponse(response CleanCacheRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *CleanCacheNoContent: @@ -359,7 +411,7 @@ func encodeCompleteCacheArtifactMultipartUploadResponse(response CompleteCacheAr func encodeCompletePreviewsMultipartUploadResponse(response CompletePreviewsMultipartUploadRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { - case *CompletePreviewsMultipartUploadOK: + case *Preview: w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(200) span.SetStatus(codes.Ok, http.StatusText(200)) @@ -416,6 +468,65 @@ func encodeCompletePreviewsMultipartUploadResponse(response CompletePreviewsMult } } +func encodeCreateAccountTokenResponse(response CreateAccountTokenRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *CreateAccountTokenOK: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CreateAccountTokenUnauthorized: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(401) + span.SetStatus(codes.Error, http.StatusText(401)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CreateAccountTokenForbidden: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(403) + span.SetStatus(codes.Error, http.StatusText(403)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *CreateAccountTokenNotFound: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeCreateCommandEventResponse(response CreateCommandEventRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *CommandEvent: @@ -863,7 +974,7 @@ func encodeDownloadCacheArtifactResponse(response DownloadCacheArtifactRes, w ht func encodeDownloadPreviewResponse(response DownloadPreviewRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { - case *ArtifactDownloadURL: + case *Preview: w.Header().Set("Content-Type", "application/json; charset=utf-8") w.WriteHeader(200) span.SetStatus(codes.Ok, http.StatusText(200)) @@ -1274,6 +1385,52 @@ func encodeListOrganizationsResponse(response ListOrganizationsRes, w http.Respo } } +func encodeListPreviewsResponse(response ListPreviewsRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *ListPreviewsOK: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *ListPreviewsUnauthorized: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(401) + span.SetStatus(codes.Error, http.StatusText(401)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *ListPreviewsForbidden: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(403) + span.SetStatus(codes.Error, http.StatusText(403)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeListProjectTokensResponse(response ListProjectTokensRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *ListProjectTokensOK: @@ -1366,6 +1523,39 @@ func encodeListProjectsResponse(response ListProjectsRes, w http.ResponseWriter, } } +func encodeListRunsResponse(response ListRunsRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *ListRunsOK: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *Error: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(403) + span.SetStatus(codes.Error, http.StatusText(403)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeRefreshTokenResponse(response RefreshTokenRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *AuthenticationTokens: @@ -1831,6 +2021,78 @@ func encodeStartPreviewsMultipartUploadResponse(response StartPreviewsMultipartU } } +func encodeUpdateAccountResponse(response UpdateAccountRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *Account: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UpdateAccountBadRequest: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(400) + span.SetStatus(codes.Error, http.StatusText(400)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UpdateAccountUnauthorized: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(401) + span.SetStatus(codes.Error, http.StatusText(401)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UpdateAccountForbidden: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(403) + span.SetStatus(codes.Error, http.StatusText(403)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UpdateAccountNotFound: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} + func encodeUpdateOrganizationResponse(response UpdateOrganizationRes, w http.ResponseWriter, span trace.Span) error { switch response := response.(type) { case *Organization: @@ -2216,3 +2478,62 @@ func encodeUploadCacheActionItemResponse(response UploadCacheActionItemRes, w ht return errors.Errorf("unexpected response type: %T", response) } } + +func encodeUploadPreviewIconResponse(response UploadPreviewIconRes, w http.ResponseWriter, span trace.Span) error { + switch response := response.(type) { + case *ArtifactUploadURL: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(200) + span.SetStatus(codes.Ok, http.StatusText(200)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UploadPreviewIconUnauthorized: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(401) + span.SetStatus(codes.Error, http.StatusText(401)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UploadPreviewIconForbidden: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(403) + span.SetStatus(codes.Error, http.StatusText(403)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + case *UploadPreviewIconNotFound: + w.Header().Set("Content-Type", "application/json; charset=utf-8") + w.WriteHeader(404) + span.SetStatus(codes.Error, http.StatusText(404)) + + e := new(jx.Encoder) + response.Encode(e) + if _, err := e.WriteTo(w); err != nil { + return errors.Wrap(err, "write") + } + + return nil + + default: + return errors.Errorf("unexpected response type: %T", response) + } +} diff --git a/internal/agent/http_cache/tuistcache/api/oas_router_gen.go b/internal/agent/http_cache/tuistcache/api/oas_router_gen.go index 578481b7..014ecb0a 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_router_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_router_gen.go @@ -73,6 +73,62 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { break } switch elem[0] { + case 'c': // Prefix: "ccounts/" + origElem := elem + if l := len("ccounts/"); len(elem) >= l && elem[0:l] == "ccounts/" { + elem = elem[l:] + } else { + break + } + + // Param: "account_handle" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] + + if len(elem) == 0 { + switch r.Method { + case "PATCH": + s.handleUpdateAccountRequest([1]string{ + args[0], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, "PATCH") + } + + return + } + switch elem[0] { + case '/': // Prefix: "/tokens" + origElem := elem + if l := len("/tokens"); len(elem) >= l && elem[0:l] == "/tokens" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch r.Method { + case "POST": + s.handleCreateAccountTokenRequest([1]string{ + args[0], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, "POST") + } + + return + } + + elem = origElem + } + + elem = origElem case 'n': // Prefix: "nalytics" origElem := elem if l := len("nalytics"); len(elem) >= l && elem[0:l] == "nalytics" { @@ -405,12 +461,16 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { if len(elem) == 0 { // Leaf node. switch r.Method { + case "DELETE": + s.handleCancelInvitationRequest([1]string{ + args[0], + }, elemIsEscaped, w, r) case "POST": s.handleCreateInvitationRequest([1]string{ args[0], }, elemIsEscaped, w, r) default: - s.notAllowed(w, r, "POST") + s.notAllowed(w, r, "DELETE,POST") } return @@ -671,104 +731,183 @@ func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) { } elem = origElem - case 'p': // Prefix: "previews/" + case 'p': // Prefix: "previews" origElem := elem - if l := len("previews/"); len(elem) >= l && elem[0:l] == "previews/" { + if l := len("previews"); len(elem) >= l && elem[0:l] == "previews" { elem = elem[l:] } else { break } if len(elem) == 0 { - break + switch r.Method { + case "GET": + s.handleListPreviewsRequest([2]string{ + args[0], + args[1], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, "GET") + } + + return } switch elem[0] { - case 'c': // Prefix: "complete" + case '/': // Prefix: "/" origElem := elem - if l := len("complete"); len(elem) >= l && elem[0:l] == "complete" { + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { elem = elem[l:] } else { break } if len(elem) == 0 { - // Leaf node. - switch r.Method { - case "POST": - s.handleCompletePreviewsMultipartUploadRequest([2]string{ - args[0], - args[1], - }, elemIsEscaped, w, r) - default: - s.notAllowed(w, r, "POST") + break + } + switch elem[0] { + case 'c': // Prefix: "complete" + origElem := elem + if l := len("complete"); len(elem) >= l && elem[0:l] == "complete" { + elem = elem[l:] + } else { + break } - return - } + if len(elem) == 0 { + // Leaf node. + switch r.Method { + case "POST": + s.handleCompletePreviewsMultipartUploadRequest([2]string{ + args[0], + args[1], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, "POST") + } - elem = origElem - case 'g': // Prefix: "generate-url" - origElem := elem - if l := len("generate-url"); len(elem) >= l && elem[0:l] == "generate-url" { - elem = elem[l:] - } else { - break + return + } + + elem = origElem + case 'g': // Prefix: "generate-url" + origElem := elem + if l := len("generate-url"); len(elem) >= l && elem[0:l] == "generate-url" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch r.Method { + case "POST": + s.handleGeneratePreviewsMultipartUploadURLRequest([2]string{ + args[0], + args[1], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, "POST") + } + + return + } + + elem = origElem + case 's': // Prefix: "start" + origElem := elem + if l := len("start"); len(elem) >= l && elem[0:l] == "start" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch r.Method { + case "POST": + s.handleStartPreviewsMultipartUploadRequest([2]string{ + args[0], + args[1], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, "POST") + } + + return + } + + elem = origElem + } + // Param: "preview_id" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) } + args[2] = elem[:idx] + elem = elem[idx:] if len(elem) == 0 { - // Leaf node. switch r.Method { - case "POST": - s.handleGeneratePreviewsMultipartUploadURLRequest([2]string{ + case "GET": + s.handleDownloadPreviewRequest([3]string{ args[0], args[1], + args[2], }, elemIsEscaped, w, r) default: - s.notAllowed(w, r, "POST") + s.notAllowed(w, r, "GET") } return } + switch elem[0] { + case '/': // Prefix: "/icons" + origElem := elem + if l := len("/icons"); len(elem) >= l && elem[0:l] == "/icons" { + elem = elem[l:] + } else { + break + } - elem = origElem - case 's': // Prefix: "start" - origElem := elem - if l := len("start"); len(elem) >= l && elem[0:l] == "start" { - elem = elem[l:] - } else { - break - } + if len(elem) == 0 { + // Leaf node. + switch r.Method { + case "POST": + s.handleUploadPreviewIconRequest([3]string{ + args[0], + args[1], + args[2], + }, elemIsEscaped, w, r) + default: + s.notAllowed(w, r, "POST") + } - if len(elem) == 0 { - // Leaf node. - switch r.Method { - case "POST": - s.handleStartPreviewsMultipartUploadRequest([2]string{ - args[0], - args[1], - }, elemIsEscaped, w, r) - default: - s.notAllowed(w, r, "POST") + return } - return + elem = origElem } elem = origElem } - // Param: "preview_id" - // Leaf parameter - args[2] = elem - elem = "" + + elem = origElem + case 'r': // Prefix: "runs" + origElem := elem + if l := len("runs"); len(elem) >= l && elem[0:l] == "runs" { + elem = elem[l:] + } else { + break + } if len(elem) == 0 { // Leaf node. switch r.Method { case "GET": - s.handleDownloadPreviewRequest([3]string{ + s.handleListRunsRequest([2]string{ args[0], args[1], - args[2], }, elemIsEscaped, w, r) default: s.notAllowed(w, r, "GET") @@ -1089,6 +1228,66 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { break } switch elem[0] { + case 'c': // Prefix: "ccounts/" + origElem := elem + if l := len("ccounts/"); len(elem) >= l && elem[0:l] == "ccounts/" { + elem = elem[l:] + } else { + break + } + + // Param: "account_handle" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[0] = elem[:idx] + elem = elem[idx:] + + if len(elem) == 0 { + switch method { + case "PATCH": + r.name = "UpdateAccount" + r.summary = "Update account" + r.operationID = "updateAccount" + r.pathPattern = "/api/accounts/{account_handle}" + r.args = args + r.count = 1 + return r, true + default: + return + } + } + switch elem[0] { + case '/': // Prefix: "/tokens" + origElem := elem + if l := len("/tokens"); len(elem) >= l && elem[0:l] == "/tokens" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch method { + case "POST": + r.name = "CreateAccountToken" + r.summary = "Create a new account token." + r.operationID = "createAccountToken" + r.pathPattern = "/api/accounts/{account_handle}/tokens" + r.args = args + r.count = 1 + return r, true + default: + return + } + } + + elem = origElem + } + + elem = origElem case 'n': // Prefix: "nalytics" origElem := elem if l := len("nalytics"); len(elem) >= l && elem[0:l] == "nalytics" { @@ -1479,6 +1678,14 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { if len(elem) == 0 { // Leaf node. switch method { + case "DELETE": + r.name = "CancelInvitation" + r.summary = "Cancels an invitation" + r.operationID = "cancelInvitation" + r.pathPattern = "/api/organizations/{organization_name}/invitations" + r.args = args + r.count = 1 + return r, true case "POST": r.name = "CreateInvitation" r.summary = "Creates an invitation" @@ -1768,109 +1975,190 @@ func (s *Server) FindPath(method string, u *url.URL) (r Route, _ bool) { } elem = origElem - case 'p': // Prefix: "previews/" + case 'p': // Prefix: "previews" origElem := elem - if l := len("previews/"); len(elem) >= l && elem[0:l] == "previews/" { + if l := len("previews"); len(elem) >= l && elem[0:l] == "previews" { elem = elem[l:] } else { break } if len(elem) == 0 { - break + switch method { + case "GET": + r.name = "ListPreviews" + r.summary = "List previews." + r.operationID = "listPreviews" + r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews" + r.args = args + r.count = 2 + return r, true + default: + return + } } switch elem[0] { - case 'c': // Prefix: "complete" + case '/': // Prefix: "/" origElem := elem - if l := len("complete"); len(elem) >= l && elem[0:l] == "complete" { + if l := len("/"); len(elem) >= l && elem[0:l] == "/" { elem = elem[l:] } else { break } if len(elem) == 0 { - // Leaf node. - switch method { - case "POST": - r.name = "CompletePreviewsMultipartUpload" - r.summary = "It completes a multi-part upload." - r.operationID = "completePreviewsMultipartUpload" - r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews/complete" - r.args = args - r.count = 2 - return r, true - default: - return - } - } - - elem = origElem - case 'g': // Prefix: "generate-url" - origElem := elem - if l := len("generate-url"); len(elem) >= l && elem[0:l] == "generate-url" { - elem = elem[l:] - } else { break } + switch elem[0] { + case 'c': // Prefix: "complete" + origElem := elem + if l := len("complete"); len(elem) >= l && elem[0:l] == "complete" { + elem = elem[l:] + } else { + break + } - if len(elem) == 0 { - // Leaf node. - switch method { - case "POST": - r.name = "GeneratePreviewsMultipartUploadURL" - r.summary = "It generates a signed URL for uploading a part." - r.operationID = "generatePreviewsMultipartUploadURL" - r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews/generate-url" - r.args = args - r.count = 2 - return r, true - default: - return + if len(elem) == 0 { + // Leaf node. + switch method { + case "POST": + r.name = "CompletePreviewsMultipartUpload" + r.summary = "It completes a multi-part upload." + r.operationID = "completePreviewsMultipartUpload" + r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews/complete" + r.args = args + r.count = 2 + return r, true + default: + return + } } - } - elem = origElem - case 's': // Prefix: "start" - origElem := elem - if l := len("start"); len(elem) >= l && elem[0:l] == "start" { - elem = elem[l:] - } else { - break + elem = origElem + case 'g': // Prefix: "generate-url" + origElem := elem + if l := len("generate-url"); len(elem) >= l && elem[0:l] == "generate-url" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch method { + case "POST": + r.name = "GeneratePreviewsMultipartUploadURL" + r.summary = "It generates a signed URL for uploading a part." + r.operationID = "generatePreviewsMultipartUploadURL" + r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews/generate-url" + r.args = args + r.count = 2 + return r, true + default: + return + } + } + + elem = origElem + case 's': // Prefix: "start" + origElem := elem + if l := len("start"); len(elem) >= l && elem[0:l] == "start" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch method { + case "POST": + r.name = "StartPreviewsMultipartUpload" + r.summary = "It initiates a multipart upload for a preview artifact." + r.operationID = "startPreviewsMultipartUpload" + r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews/start" + r.args = args + r.count = 2 + return r, true + default: + return + } + } + + elem = origElem } + // Param: "preview_id" + // Match until "/" + idx := strings.IndexByte(elem, '/') + if idx < 0 { + idx = len(elem) + } + args[2] = elem[:idx] + elem = elem[idx:] if len(elem) == 0 { - // Leaf node. switch method { - case "POST": - r.name = "StartPreviewsMultipartUpload" - r.summary = "It initiates a multipart upload for a preview artifact." - r.operationID = "startPreviewsMultipartUpload" - r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews/start" + case "GET": + r.name = "DownloadPreview" + r.summary = "Returns a preview with a given id." + r.operationID = "downloadPreview" + r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews/{preview_id}" r.args = args - r.count = 2 + r.count = 3 return r, true default: return } } + switch elem[0] { + case '/': // Prefix: "/icons" + origElem := elem + if l := len("/icons"); len(elem) >= l && elem[0:l] == "/icons" { + elem = elem[l:] + } else { + break + } + + if len(elem) == 0 { + // Leaf node. + switch method { + case "POST": + r.name = "UploadPreviewIcon" + r.summary = "Uploads a preview icon." + r.operationID = "uploadPreviewIcon" + r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons" + r.args = args + r.count = 3 + return r, true + default: + return + } + } + + elem = origElem + } elem = origElem } - // Param: "preview_id" - // Leaf parameter - args[2] = elem - elem = "" + + elem = origElem + case 'r': // Prefix: "runs" + origElem := elem + if l := len("runs"); len(elem) >= l && elem[0:l] == "runs" { + elem = elem[l:] + } else { + break + } if len(elem) == 0 { // Leaf node. switch method { case "GET": - r.name = "DownloadPreview" - r.summary = "Downloads a preview." - r.operationID = "downloadPreview" - r.pathPattern = "/api/projects/{account_handle}/{project_handle}/previews/{preview_id}" + r.name = "ListRuns" + r.summary = "List runs associated with a given project." + r.operationID = "listRuns" + r.pathPattern = "/api/projects/{account_handle}/{project_handle}/runs" r.args = args - r.count = 3 + r.count = 2 return r, true default: return diff --git a/internal/agent/http_cache/tuistcache/api/oas_schemas_gen.go b/internal/agent/http_cache/tuistcache/api/oas_schemas_gen.go index 477d9b1a..8b112da6 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_schemas_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_schemas_gen.go @@ -6,41 +6,78 @@ import ( "time" "github.com/go-faster/errors" - "github.com/go-faster/jx" ) -// The URL to download an artifact. -// Ref: #/components/schemas/ArtifactDownloadURL -type ArtifactDownloadURL struct { - // The UNIX timestamp when the URL expires. - ExpiresAt int `json:"expires_at"` - // The URL to download the artifact. - URL string `json:"url"` +// Ref: #/components/schemas/Account +type Account struct { + // The handle of the account. + Handle string `json:"handle"` + // ID of the account. + ID float64 `json:"id"` } -// GetExpiresAt returns the value of ExpiresAt. -func (s *ArtifactDownloadURL) GetExpiresAt() int { - return s.ExpiresAt +// GetHandle returns the value of Handle. +func (s *Account) GetHandle() string { + return s.Handle } -// GetURL returns the value of URL. -func (s *ArtifactDownloadURL) GetURL() string { - return s.URL +// GetID returns the value of ID. +func (s *Account) GetID() float64 { + return s.ID } -// SetExpiresAt sets the value of ExpiresAt. -func (s *ArtifactDownloadURL) SetExpiresAt(val int) { - s.ExpiresAt = val +// SetHandle sets the value of Handle. +func (s *Account) SetHandle(val string) { + s.Handle = val } -// SetURL sets the value of URL. -func (s *ArtifactDownloadURL) SetURL(val string) { - s.URL = val +// SetID sets the value of ID. +func (s *Account) SetID(val float64) { + s.ID = val +} + +func (*Account) updateAccountRes() {} + +// Represents an multipart upload's part identified by the upload id and the part number. +// Ref: #/components/schemas/ArtifactMultipartUploadPart +type ArtifactMultipartUploadPart struct { + // The content length of the part. + ContentLength OptInt `json:"content_length"` + // The part number of the multipart upload. + PartNumber int `json:"part_number"` + // The upload ID. + UploadID string `json:"upload_id"` +} + +// GetContentLength returns the value of ContentLength. +func (s *ArtifactMultipartUploadPart) GetContentLength() OptInt { + return s.ContentLength +} + +// GetPartNumber returns the value of PartNumber. +func (s *ArtifactMultipartUploadPart) GetPartNumber() int { + return s.PartNumber +} + +// GetUploadID returns the value of UploadID. +func (s *ArtifactMultipartUploadPart) GetUploadID() string { + return s.UploadID } -func (*ArtifactDownloadURL) downloadPreviewRes() {} +// SetContentLength sets the value of ContentLength. +func (s *ArtifactMultipartUploadPart) SetContentLength(val OptInt) { + s.ContentLength = val +} + +// SetPartNumber sets the value of PartNumber. +func (s *ArtifactMultipartUploadPart) SetPartNumber(val int) { + s.PartNumber = val +} -type ArtifactMultipartUploadPart jx.Raw +// SetUploadID sets the value of UploadID. +func (s *ArtifactMultipartUploadPart) SetUploadID(val string) { + s.UploadID = val +} // It represents a part that has been uploaded using multipart uploads. The part is identified by its // number and the etag. @@ -260,6 +297,37 @@ func (s *ArtifactUploadIDStatus) UnmarshalText(data []byte) error { } } +// The URL to upload an artifact. +// Ref: #/components/schemas/ArtifactUploadURL +type ArtifactUploadURL struct { + // The UNIX timestamp when the URL expires. + ExpiresAt int `json:"expires_at"` + // The URL to upload the artifact. + URL string `json:"url"` +} + +// GetExpiresAt returns the value of ExpiresAt. +func (s *ArtifactUploadURL) GetExpiresAt() int { + return s.ExpiresAt +} + +// GetURL returns the value of URL. +func (s *ArtifactUploadURL) GetURL() string { + return s.URL +} + +// SetExpiresAt sets the value of ExpiresAt. +func (s *ArtifactUploadURL) SetExpiresAt(val int) { + s.ExpiresAt = val +} + +// SetURL sets the value of URL. +func (s *ArtifactUploadURL) SetURL(val string) { + s.URL = val +} + +func (*ArtifactUploadURL) uploadPreviewIconRes() {} + type AuthenticateReq struct { // The email to authenticate with. Email string `json:"email"` @@ -320,20 +388,6 @@ func (s *AuthenticationTokens) SetRefreshToken(val string) { func (*AuthenticationTokens) authenticateRes() {} func (*AuthenticationTokens) refreshTokenRes() {} -type Authorization struct { - Token string -} - -// GetToken returns the value of Token. -func (s *Authorization) GetToken() string { - return s.Token -} - -// SetToken sets the value of Token. -func (s *Authorization) SetToken(val string) { - s.Token = val -} - // Represents an action item stored in the cache. // Ref: #/components/schemas/CacheActionItem type CacheActionItem struct { @@ -603,6 +657,38 @@ func (s *CacheCategory) UnmarshalText(data []byte) error { } } +type CancelInvitationForbidden Error + +func (*CancelInvitationForbidden) cancelInvitationRes() {} + +// CancelInvitationNoContent is response for CancelInvitation operation. +type CancelInvitationNoContent struct{} + +func (*CancelInvitationNoContent) cancelInvitationRes() {} + +type CancelInvitationNotFound Error + +func (*CancelInvitationNotFound) cancelInvitationRes() {} + +type CancelInvitationReq struct { + // The email of the invitee. + InviteeEmail string `json:"invitee_email"` +} + +// GetInviteeEmail returns the value of InviteeEmail. +func (s *CancelInvitationReq) GetInviteeEmail() string { + return s.InviteeEmail +} + +// SetInviteeEmail sets the value of InviteeEmail. +func (s *CancelInvitationReq) SetInviteeEmail(val string) { + s.InviteeEmail = val +} + +type CancelInvitationUnauthorized Error + +func (*CancelInvitationUnauthorized) cancelInvitationRes() {} + type CleanCacheForbidden Error func (*CleanCacheForbidden) cleanCacheRes() {} @@ -663,7 +749,93 @@ func (s *CommandEvent) SetURL(val string) { func (*CommandEvent) createCommandEventRes() {} -type CommandEventArtifact jx.Raw +// It represents an artifact that's associated with a command event (e.g. result bundles). +// Ref: #/components/schemas/CommandEventArtifact +type CommandEventArtifact struct { + // The name of the file. It's used only for certain types such as result_bundle_object. + Name OptString `json:"name"` + // The command event artifact type. It can be: + // - result_bundle: A result bundle artifact that represents the whole `.xcresult` bundle + // - invocation_record: An invocation record artifact. This is a root bundle object of the result + // bundle + // - result_bundle_object: A result bundle object. There are many different bundle objects per result + // bundle. + Type CommandEventArtifactType `json:"type"` +} + +// GetName returns the value of Name. +func (s *CommandEventArtifact) GetName() OptString { + return s.Name +} + +// GetType returns the value of Type. +func (s *CommandEventArtifact) GetType() CommandEventArtifactType { + return s.Type +} + +// SetName sets the value of Name. +func (s *CommandEventArtifact) SetName(val OptString) { + s.Name = val +} + +// SetType sets the value of Type. +func (s *CommandEventArtifact) SetType(val CommandEventArtifactType) { + s.Type = val +} + +// The command event artifact type. It can be: +// - result_bundle: A result bundle artifact that represents the whole `.xcresult` bundle +// - invocation_record: An invocation record artifact. This is a root bundle object of the result +// bundle +// - result_bundle_object: A result bundle object. There are many different bundle objects per result +// bundle. +type CommandEventArtifactType string + +const ( + CommandEventArtifactTypeResultBundle CommandEventArtifactType = "result_bundle" + CommandEventArtifactTypeInvocationRecord CommandEventArtifactType = "invocation_record" + CommandEventArtifactTypeResultBundleObject CommandEventArtifactType = "result_bundle_object" +) + +// AllValues returns all CommandEventArtifactType values. +func (CommandEventArtifactType) AllValues() []CommandEventArtifactType { + return []CommandEventArtifactType{ + CommandEventArtifactTypeResultBundle, + CommandEventArtifactTypeInvocationRecord, + CommandEventArtifactTypeResultBundleObject, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s CommandEventArtifactType) MarshalText() ([]byte, error) { + switch s { + case CommandEventArtifactTypeResultBundle: + return []byte(s), nil + case CommandEventArtifactTypeInvocationRecord: + return []byte(s), nil + case CommandEventArtifactTypeResultBundleObject: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *CommandEventArtifactType) UnmarshalText(data []byte) error { + switch CommandEventArtifactType(data) { + case CommandEventArtifactTypeResultBundle: + *s = CommandEventArtifactTypeResultBundle + return nil + case CommandEventArtifactTypeInvocationRecord: + *s = CommandEventArtifactTypeInvocationRecord + return nil + case CommandEventArtifactTypeResultBundleObject: + *s = CommandEventArtifactTypeResultBundleObject + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} type CompleteAnalyticsArtifactMultipartUploadForbidden Error @@ -879,24 +1051,6 @@ type CompletePreviewsMultipartUploadNotFound Error func (*CompletePreviewsMultipartUploadNotFound) completePreviewsMultipartUploadRes() {} -// The preview multipart upload has been completed. -type CompletePreviewsMultipartUploadOK struct { - // The URL to download the preview. - URL string `json:"url"` -} - -// GetURL returns the value of URL. -func (s *CompletePreviewsMultipartUploadOK) GetURL() string { - return s.URL -} - -// SetURL sets the value of URL. -func (s *CompletePreviewsMultipartUploadOK) SetURL(val string) { - s.URL = val -} - -func (*CompletePreviewsMultipartUploadOK) completePreviewsMultipartUploadRes() {} - // The request body to complete the multipart upload of a preview. type CompletePreviewsMultipartUploadReq struct { MultipartUploadParts ArtifactMultipartUploadParts `json:"multipart_upload_parts"` @@ -928,20 +1082,87 @@ type CompletePreviewsMultipartUploadUnauthorized Error func (*CompletePreviewsMultipartUploadUnauthorized) completePreviewsMultipartUploadRes() {} -type Cookie struct { - APIKey string +type CreateAccountTokenForbidden Error + +func (*CreateAccountTokenForbidden) createAccountTokenRes() {} + +type CreateAccountTokenNotFound Error + +func (*CreateAccountTokenNotFound) createAccountTokenRes() {} + +// A new account token. +type CreateAccountTokenOK struct { + // The generated account token. + Token string `json:"token"` +} + +// GetToken returns the value of Token. +func (s *CreateAccountTokenOK) GetToken() string { + return s.Token +} + +// SetToken sets the value of Token. +func (s *CreateAccountTokenOK) SetToken(val string) { + s.Token = val +} + +func (*CreateAccountTokenOK) createAccountTokenRes() {} + +// The request to create a new account token. +type CreateAccountTokenReq struct { + // The scopes for the new account token. + Scopes []CreateAccountTokenReqScopesItem `json:"scopes"` +} + +// GetScopes returns the value of Scopes. +func (s *CreateAccountTokenReq) GetScopes() []CreateAccountTokenReqScopesItem { + return s.Scopes +} + +// SetScopes sets the value of Scopes. +func (s *CreateAccountTokenReq) SetScopes(val []CreateAccountTokenReqScopesItem) { + s.Scopes = val +} + +// The scope of the token. +type CreateAccountTokenReqScopesItem string + +const ( + CreateAccountTokenReqScopesItemAccountRegistryRead CreateAccountTokenReqScopesItem = "account_registry_read" +) + +// AllValues returns all CreateAccountTokenReqScopesItem values. +func (CreateAccountTokenReqScopesItem) AllValues() []CreateAccountTokenReqScopesItem { + return []CreateAccountTokenReqScopesItem{ + CreateAccountTokenReqScopesItemAccountRegistryRead, + } } -// GetAPIKey returns the value of APIKey. -func (s *Cookie) GetAPIKey() string { - return s.APIKey +// MarshalText implements encoding.TextMarshaler. +func (s CreateAccountTokenReqScopesItem) MarshalText() ([]byte, error) { + switch s { + case CreateAccountTokenReqScopesItemAccountRegistryRead: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } } -// SetAPIKey sets the value of APIKey. -func (s *Cookie) SetAPIKey(val string) { - s.APIKey = val +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *CreateAccountTokenReqScopesItem) UnmarshalText(data []byte) error { + switch CreateAccountTokenReqScopesItem(data) { + case CreateAccountTokenReqScopesItemAccountRegistryRead: + *s = CreateAccountTokenReqScopesItemAccountRegistryRead + return nil + default: + return errors.Errorf("invalid value: %q", data) + } } +type CreateAccountTokenUnauthorized Error + +func (*CreateAccountTokenUnauthorized) createAccountTokenRes() {} + type CreateCommandEventForbidden Error func (*CreateCommandEventForbidden) createCommandEventRes() {} @@ -955,6 +1176,8 @@ type CreateCommandEventReq struct { Duration float64 `json:"duration"` // The error message of the command. ErrorMessage OptString `json:"error_message"` + // The git branch. + GitBranch OptString `json:"git_branch"` // The commit SHA. GitCommitSha OptString `json:"git_commit_sha"` // The git ref. When on CI, the value can be equal to remote reference such as `refs/pull/1234/merge`. @@ -1001,6 +1224,11 @@ func (s *CreateCommandEventReq) GetErrorMessage() OptString { return s.ErrorMessage } +// GetGitBranch returns the value of GitBranch. +func (s *CreateCommandEventReq) GetGitBranch() OptString { + return s.GitBranch +} + // GetGitCommitSha returns the value of GitCommitSha. func (s *CreateCommandEventReq) GetGitCommitSha() OptString { return s.GitCommitSha @@ -1081,6 +1309,11 @@ func (s *CreateCommandEventReq) SetErrorMessage(val OptString) { s.ErrorMessage = val } +// SetGitBranch sets the value of GitBranch. +func (s *CreateCommandEventReq) SetGitBranch(val OptString) { + s.GitBranch = val +} + // SetGitCommitSha sets the value of GitCommitSha. func (s *CreateCommandEventReq) SetGitCommitSha(val OptString) { s.GitCommitSha = val @@ -1477,6 +1710,7 @@ func (*Error) authenticateRes() {} func (*Error) createOrganizationRes() {} func (*Error) getDeviceCodeRes() {} func (*Error) listProjectsRes() {} +func (*Error) listRunsRes() {} func (*Error) refreshTokenRes() {} type GenerateAnalyticsArtifactMultipartUploadURLForbidden Error @@ -1731,6 +1965,65 @@ type ListOrganizationsUnauthorized Error func (*ListOrganizationsUnauthorized) listOrganizationsRes() {} +type ListPreviewsDistinctField string + +const ( + ListPreviewsDistinctFieldBundleIdentifier ListPreviewsDistinctField = "bundle_identifier" +) + +// AllValues returns all ListPreviewsDistinctField values. +func (ListPreviewsDistinctField) AllValues() []ListPreviewsDistinctField { + return []ListPreviewsDistinctField{ + ListPreviewsDistinctFieldBundleIdentifier, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ListPreviewsDistinctField) MarshalText() ([]byte, error) { + switch s { + case ListPreviewsDistinctFieldBundleIdentifier: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ListPreviewsDistinctField) UnmarshalText(data []byte) error { + switch ListPreviewsDistinctField(data) { + case ListPreviewsDistinctFieldBundleIdentifier: + *s = ListPreviewsDistinctFieldBundleIdentifier + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +type ListPreviewsForbidden Error + +func (*ListPreviewsForbidden) listPreviewsRes() {} + +type ListPreviewsOK struct { + // Previews list. + Previews []Preview `json:"previews"` +} + +// GetPreviews returns the value of Previews. +func (s *ListPreviewsOK) GetPreviews() []Preview { + return s.Previews +} + +// SetPreviews sets the value of Previews. +func (s *ListPreviewsOK) SetPreviews(val []Preview) { + s.Previews = val +} + +func (*ListPreviewsOK) listPreviewsRes() {} + +type ListPreviewsUnauthorized Error + +func (*ListPreviewsUnauthorized) listPreviewsRes() {} + type ListProjectTokensForbidden Error func (*ListProjectTokensForbidden) listProjectTokensRes() {} @@ -1776,6 +2069,22 @@ func (s *ListProjectsOK) SetProjects(val []Project) { func (*ListProjectsOK) listProjectsRes() {} +type ListRunsOK struct { + Runs []Run `json:"runs"` +} + +// GetRuns returns the value of Runs. +func (s *ListRunsOK) GetRuns() []Run { + return s.Runs +} + +// SetRuns sets the value of Runs. +func (s *ListRunsOK) SetRuns(val []Run) { + s.Runs = val +} + +func (*ListRunsOK) listRunsRes() {} + // Ref: #/components/schemas/Module type Module struct { // A hash that represents the module. @@ -1954,38 +2263,38 @@ func (o OptCacheCategory) Or(d CacheCategory) CacheCategory { return d } -// NewOptCompleteAnalyticsArtifactMultipartUploadReq returns new OptCompleteAnalyticsArtifactMultipartUploadReq with value set to v. -func NewOptCompleteAnalyticsArtifactMultipartUploadReq(v CompleteAnalyticsArtifactMultipartUploadReq) OptCompleteAnalyticsArtifactMultipartUploadReq { - return OptCompleteAnalyticsArtifactMultipartUploadReq{ +// NewOptCancelInvitationReq returns new OptCancelInvitationReq with value set to v. +func NewOptCancelInvitationReq(v CancelInvitationReq) OptCancelInvitationReq { + return OptCancelInvitationReq{ Value: v, Set: true, } } -// OptCompleteAnalyticsArtifactMultipartUploadReq is optional CompleteAnalyticsArtifactMultipartUploadReq. -type OptCompleteAnalyticsArtifactMultipartUploadReq struct { - Value CompleteAnalyticsArtifactMultipartUploadReq +// OptCancelInvitationReq is optional CancelInvitationReq. +type OptCancelInvitationReq struct { + Value CancelInvitationReq Set bool } -// IsSet returns true if OptCompleteAnalyticsArtifactMultipartUploadReq was set. -func (o OptCompleteAnalyticsArtifactMultipartUploadReq) IsSet() bool { return o.Set } +// IsSet returns true if OptCancelInvitationReq was set. +func (o OptCancelInvitationReq) IsSet() bool { return o.Set } // Reset unsets value. -func (o *OptCompleteAnalyticsArtifactMultipartUploadReq) Reset() { - var v CompleteAnalyticsArtifactMultipartUploadReq +func (o *OptCancelInvitationReq) Reset() { + var v CancelInvitationReq o.Value = v o.Set = false } // SetTo sets value to v. -func (o *OptCompleteAnalyticsArtifactMultipartUploadReq) SetTo(v CompleteAnalyticsArtifactMultipartUploadReq) { +func (o *OptCancelInvitationReq) SetTo(v CancelInvitationReq) { o.Set = true o.Value = v } // Get returns value and boolean that denotes whether value was set. -func (o OptCompleteAnalyticsArtifactMultipartUploadReq) Get() (v CompleteAnalyticsArtifactMultipartUploadReq, ok bool) { +func (o OptCancelInvitationReq) Get() (v CancelInvitationReq, ok bool) { if !o.Set { return v, false } @@ -1993,33 +2302,125 @@ func (o OptCompleteAnalyticsArtifactMultipartUploadReq) Get() (v CompleteAnalyti } // Or returns value if set, or given parameter if does not. -func (o OptCompleteAnalyticsArtifactMultipartUploadReq) Or(d CompleteAnalyticsArtifactMultipartUploadReq) CompleteAnalyticsArtifactMultipartUploadReq { +func (o OptCancelInvitationReq) Or(d CancelInvitationReq) CancelInvitationReq { if v, ok := o.Get(); ok { return v } return d } -// NewOptCompleteAnalyticsArtifactsUploadsReq returns new OptCompleteAnalyticsArtifactsUploadsReq with value set to v. -func NewOptCompleteAnalyticsArtifactsUploadsReq(v CompleteAnalyticsArtifactsUploadsReq) OptCompleteAnalyticsArtifactsUploadsReq { - return OptCompleteAnalyticsArtifactsUploadsReq{ +// NewOptCommandEventArtifact returns new OptCommandEventArtifact with value set to v. +func NewOptCommandEventArtifact(v CommandEventArtifact) OptCommandEventArtifact { + return OptCommandEventArtifact{ Value: v, Set: true, } } -// OptCompleteAnalyticsArtifactsUploadsReq is optional CompleteAnalyticsArtifactsUploadsReq. -type OptCompleteAnalyticsArtifactsUploadsReq struct { - Value CompleteAnalyticsArtifactsUploadsReq +// OptCommandEventArtifact is optional CommandEventArtifact. +type OptCommandEventArtifact struct { + Value CommandEventArtifact Set bool } -// IsSet returns true if OptCompleteAnalyticsArtifactsUploadsReq was set. -func (o OptCompleteAnalyticsArtifactsUploadsReq) IsSet() bool { return o.Set } +// IsSet returns true if OptCommandEventArtifact was set. +func (o OptCommandEventArtifact) IsSet() bool { return o.Set } // Reset unsets value. -func (o *OptCompleteAnalyticsArtifactsUploadsReq) Reset() { - var v CompleteAnalyticsArtifactsUploadsReq +func (o *OptCommandEventArtifact) Reset() { + var v CommandEventArtifact + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptCommandEventArtifact) SetTo(v CommandEventArtifact) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptCommandEventArtifact) Get() (v CommandEventArtifact, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptCommandEventArtifact) Or(d CommandEventArtifact) CommandEventArtifact { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptCompleteAnalyticsArtifactMultipartUploadReq returns new OptCompleteAnalyticsArtifactMultipartUploadReq with value set to v. +func NewOptCompleteAnalyticsArtifactMultipartUploadReq(v CompleteAnalyticsArtifactMultipartUploadReq) OptCompleteAnalyticsArtifactMultipartUploadReq { + return OptCompleteAnalyticsArtifactMultipartUploadReq{ + Value: v, + Set: true, + } +} + +// OptCompleteAnalyticsArtifactMultipartUploadReq is optional CompleteAnalyticsArtifactMultipartUploadReq. +type OptCompleteAnalyticsArtifactMultipartUploadReq struct { + Value CompleteAnalyticsArtifactMultipartUploadReq + Set bool +} + +// IsSet returns true if OptCompleteAnalyticsArtifactMultipartUploadReq was set. +func (o OptCompleteAnalyticsArtifactMultipartUploadReq) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptCompleteAnalyticsArtifactMultipartUploadReq) Reset() { + var v CompleteAnalyticsArtifactMultipartUploadReq + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptCompleteAnalyticsArtifactMultipartUploadReq) SetTo(v CompleteAnalyticsArtifactMultipartUploadReq) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptCompleteAnalyticsArtifactMultipartUploadReq) Get() (v CompleteAnalyticsArtifactMultipartUploadReq, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptCompleteAnalyticsArtifactMultipartUploadReq) Or(d CompleteAnalyticsArtifactMultipartUploadReq) CompleteAnalyticsArtifactMultipartUploadReq { + if v, ok := o.Get(); ok { + return v + } + return d +} + +// NewOptCompleteAnalyticsArtifactsUploadsReq returns new OptCompleteAnalyticsArtifactsUploadsReq with value set to v. +func NewOptCompleteAnalyticsArtifactsUploadsReq(v CompleteAnalyticsArtifactsUploadsReq) OptCompleteAnalyticsArtifactsUploadsReq { + return OptCompleteAnalyticsArtifactsUploadsReq{ + Value: v, + Set: true, + } +} + +// OptCompleteAnalyticsArtifactsUploadsReq is optional CompleteAnalyticsArtifactsUploadsReq. +type OptCompleteAnalyticsArtifactsUploadsReq struct { + Value CompleteAnalyticsArtifactsUploadsReq + Set bool +} + +// IsSet returns true if OptCompleteAnalyticsArtifactsUploadsReq was set. +func (o OptCompleteAnalyticsArtifactsUploadsReq) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptCompleteAnalyticsArtifactsUploadsReq) Reset() { + var v CompleteAnalyticsArtifactsUploadsReq o.Value = v o.Set = false } @@ -2184,6 +2585,52 @@ func (o OptCompletePreviewsMultipartUploadReq) Or(d CompletePreviewsMultipartUpl return d } +// NewOptCreateAccountTokenReq returns new OptCreateAccountTokenReq with value set to v. +func NewOptCreateAccountTokenReq(v CreateAccountTokenReq) OptCreateAccountTokenReq { + return OptCreateAccountTokenReq{ + Value: v, + Set: true, + } +} + +// OptCreateAccountTokenReq is optional CreateAccountTokenReq. +type OptCreateAccountTokenReq struct { + Value CreateAccountTokenReq + Set bool +} + +// IsSet returns true if OptCreateAccountTokenReq was set. +func (o OptCreateAccountTokenReq) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptCreateAccountTokenReq) Reset() { + var v CreateAccountTokenReq + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptCreateAccountTokenReq) SetTo(v CreateAccountTokenReq) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptCreateAccountTokenReq) Get() (v CreateAccountTokenReq, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptCreateAccountTokenReq) Or(d CreateAccountTokenReq) CreateAccountTokenReq { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptCreateCommandEventReq returns new OptCreateCommandEventReq with value set to v. func NewOptCreateCommandEventReq(v CreateCommandEventReq) OptCreateCommandEventReq { return OptCreateCommandEventReq{ @@ -2598,6 +3045,52 @@ func (o OptInt) Or(d int) int { return d } +// NewOptListPreviewsDistinctField returns new OptListPreviewsDistinctField with value set to v. +func NewOptListPreviewsDistinctField(v ListPreviewsDistinctField) OptListPreviewsDistinctField { + return OptListPreviewsDistinctField{ + Value: v, + Set: true, + } +} + +// OptListPreviewsDistinctField is optional ListPreviewsDistinctField. +type OptListPreviewsDistinctField struct { + Value ListPreviewsDistinctField + Set bool +} + +// IsSet returns true if OptListPreviewsDistinctField was set. +func (o OptListPreviewsDistinctField) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptListPreviewsDistinctField) Reset() { + var v ListPreviewsDistinctField + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptListPreviewsDistinctField) SetTo(v ListPreviewsDistinctField) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptListPreviewsDistinctField) Get() (v ListPreviewsDistinctField, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptListPreviewsDistinctField) Or(d ListPreviewsDistinctField) ListPreviewsDistinctField { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptNilString returns new OptNilString with value set to v. func NewOptNilString(v string) OptNilString { return OptNilString{ @@ -2891,6 +3384,52 @@ func (o OptString) Or(d string) string { return d } +// NewOptUpdateAccountReq returns new OptUpdateAccountReq with value set to v. +func NewOptUpdateAccountReq(v UpdateAccountReq) OptUpdateAccountReq { + return OptUpdateAccountReq{ + Value: v, + Set: true, + } +} + +// OptUpdateAccountReq is optional UpdateAccountReq. +type OptUpdateAccountReq struct { + Value UpdateAccountReq + Set bool +} + +// IsSet returns true if OptUpdateAccountReq was set. +func (o OptUpdateAccountReq) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptUpdateAccountReq) Reset() { + var v UpdateAccountReq + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptUpdateAccountReq) SetTo(v UpdateAccountReq) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptUpdateAccountReq) Get() (v UpdateAccountReq, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptUpdateAccountReq) Or(d UpdateAccountReq) UpdateAccountReq { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptUpdateOrganization2Req returns new OptUpdateOrganization2Req with value set to v. func NewOptUpdateOrganization2Req(v UpdateOrganization2Req) OptUpdateOrganization2Req { return OptUpdateOrganization2Req{ @@ -3167,6 +3706,52 @@ func (o OptUpdateProjectReq) Or(d UpdateProjectReq) UpdateProjectReq { return d } +// NewOptUpdateProjectReqVisibility returns new OptUpdateProjectReqVisibility with value set to v. +func NewOptUpdateProjectReqVisibility(v UpdateProjectReqVisibility) OptUpdateProjectReqVisibility { + return OptUpdateProjectReqVisibility{ + Value: v, + Set: true, + } +} + +// OptUpdateProjectReqVisibility is optional UpdateProjectReqVisibility. +type OptUpdateProjectReqVisibility struct { + Value UpdateProjectReqVisibility + Set bool +} + +// IsSet returns true if OptUpdateProjectReqVisibility was set. +func (o OptUpdateProjectReqVisibility) IsSet() bool { return o.Set } + +// Reset unsets value. +func (o *OptUpdateProjectReqVisibility) Reset() { + var v UpdateProjectReqVisibility + o.Value = v + o.Set = false +} + +// SetTo sets value to v. +func (o *OptUpdateProjectReqVisibility) SetTo(v UpdateProjectReqVisibility) { + o.Set = true + o.Value = v +} + +// Get returns value and boolean that denotes whether value was set. +func (o OptUpdateProjectReqVisibility) Get() (v UpdateProjectReqVisibility, ok bool) { + if !o.Set { + return v, false + } + return o.Value, true +} + +// Or returns value if set, or given parameter if does not. +func (o OptUpdateProjectReqVisibility) Or(d UpdateProjectReqVisibility) UpdateProjectReqVisibility { + if v, ok := o.Get(); ok { + return v + } + return d +} + // NewOptUploadCacheActionItemReq returns new OptUploadCacheActionItemReq with value set to v. func NewOptUploadCacheActionItemReq(v UploadCacheActionItemReq) OptUploadCacheActionItemReq { return OptUploadCacheActionItemReq{ @@ -3465,12 +4050,14 @@ type OrganizationSSOProvider string const ( OrganizationSSOProviderGoogle OrganizationSSOProvider = "google" + OrganizationSSOProviderOkta OrganizationSSOProvider = "okta" ) // AllValues returns all OrganizationSSOProvider values. func (OrganizationSSOProvider) AllValues() []OrganizationSSOProvider { return []OrganizationSSOProvider{ OrganizationSSOProviderGoogle, + OrganizationSSOProviderOkta, } } @@ -3479,6 +4066,8 @@ func (s OrganizationSSOProvider) MarshalText() ([]byte, error) { switch s { case OrganizationSSOProviderGoogle: return []byte(s), nil + case OrganizationSSOProviderOkta: + return []byte(s), nil default: return nil, errors.Errorf("invalid value: %q", s) } @@ -3490,6 +4079,9 @@ func (s *OrganizationSSOProvider) UnmarshalText(data []byte) error { case OrganizationSSOProviderGoogle: *s = OrganizationSSOProviderGoogle return nil + case OrganizationSSOProviderOkta: + *s = OrganizationSSOProviderOkta + return nil default: return errors.Errorf("invalid value: %q", data) } @@ -3514,31 +4106,227 @@ func (s *OrganizationUsage) SetCurrentMonthRemoteCacheHits(val float64) { func (*OrganizationUsage) showOrganizationUsageRes() {} -// Ref: #/components/schemas/Project -type Project struct { - // The default branch of the project. - DefaultBranch string `json:"default_branch"` - // The full name of the project (e.g. tuist/tuist). - FullName string `json:"full_name"` - // ID of the project. - ID float64 `json:"id"` - // The URL of the connected git repository, such as https://github.com/tuist/tuist or https://github. - // com/tuist/tuist.git. - RepositoryURL OptString `json:"repository_url"` - // The token that should be used to authenticate the project. For CI only. - // - // Deprecated: schema marks this property as deprecated. - Token string `json:"token"` +// Ref: #/components/schemas/Preview +type Preview struct { + // The bundle identifier of the preview. + BundleIdentifier OptString `json:"bundle_identifier"` + // The display name of the preview. + DisplayName OptString `json:"display_name"` + // The git branch associated with the preview. + GitBranch OptString `json:"git_branch"` + // The git commit SHA associated with the preview. + GitCommitSha OptString `json:"git_commit_sha"` + // The URL for the icon image of the preview. + IconURL string `json:"icon_url"` + // Unique identifier of the preview. + ID string `json:"id"` + // The URL for the QR code image to dowload the preview. + QrCodeURL string `json:"qr_code_url"` + // The URL to download the preview. + URL string `json:"url"` } -// GetDefaultBranch returns the value of DefaultBranch. -func (s *Project) GetDefaultBranch() string { - return s.DefaultBranch +// GetBundleIdentifier returns the value of BundleIdentifier. +func (s *Preview) GetBundleIdentifier() OptString { + return s.BundleIdentifier } -// GetFullName returns the value of FullName. -func (s *Project) GetFullName() string { - return s.FullName +// GetDisplayName returns the value of DisplayName. +func (s *Preview) GetDisplayName() OptString { + return s.DisplayName +} + +// GetGitBranch returns the value of GitBranch. +func (s *Preview) GetGitBranch() OptString { + return s.GitBranch +} + +// GetGitCommitSha returns the value of GitCommitSha. +func (s *Preview) GetGitCommitSha() OptString { + return s.GitCommitSha +} + +// GetIconURL returns the value of IconURL. +func (s *Preview) GetIconURL() string { + return s.IconURL +} + +// GetID returns the value of ID. +func (s *Preview) GetID() string { + return s.ID +} + +// GetQrCodeURL returns the value of QrCodeURL. +func (s *Preview) GetQrCodeURL() string { + return s.QrCodeURL +} + +// GetURL returns the value of URL. +func (s *Preview) GetURL() string { + return s.URL +} + +// SetBundleIdentifier sets the value of BundleIdentifier. +func (s *Preview) SetBundleIdentifier(val OptString) { + s.BundleIdentifier = val +} + +// SetDisplayName sets the value of DisplayName. +func (s *Preview) SetDisplayName(val OptString) { + s.DisplayName = val +} + +// SetGitBranch sets the value of GitBranch. +func (s *Preview) SetGitBranch(val OptString) { + s.GitBranch = val +} + +// SetGitCommitSha sets the value of GitCommitSha. +func (s *Preview) SetGitCommitSha(val OptString) { + s.GitCommitSha = val +} + +// SetIconURL sets the value of IconURL. +func (s *Preview) SetIconURL(val string) { + s.IconURL = val +} + +// SetID sets the value of ID. +func (s *Preview) SetID(val string) { + s.ID = val +} + +// SetQrCodeURL sets the value of QrCodeURL. +func (s *Preview) SetQrCodeURL(val string) { + s.QrCodeURL = val +} + +// SetURL sets the value of URL. +func (s *Preview) SetURL(val string) { + s.URL = val +} + +func (*Preview) completePreviewsMultipartUploadRes() {} +func (*Preview) downloadPreviewRes() {} + +// Ref: #/components/schemas/PreviewSupportedPlatform +type PreviewSupportedPlatform string + +const ( + PreviewSupportedPlatformIos PreviewSupportedPlatform = "ios" + PreviewSupportedPlatformIosSimulator PreviewSupportedPlatform = "ios_simulator" + PreviewSupportedPlatformTvos PreviewSupportedPlatform = "tvos" + PreviewSupportedPlatformTvosSimulator PreviewSupportedPlatform = "tvos_simulator" + PreviewSupportedPlatformWatchos PreviewSupportedPlatform = "watchos" + PreviewSupportedPlatformWatchosSimulator PreviewSupportedPlatform = "watchos_simulator" + PreviewSupportedPlatformVisionos PreviewSupportedPlatform = "visionos" + PreviewSupportedPlatformVisionosSimulator PreviewSupportedPlatform = "visionos_simulator" + PreviewSupportedPlatformMacos PreviewSupportedPlatform = "macos" +) + +// AllValues returns all PreviewSupportedPlatform values. +func (PreviewSupportedPlatform) AllValues() []PreviewSupportedPlatform { + return []PreviewSupportedPlatform{ + PreviewSupportedPlatformIos, + PreviewSupportedPlatformIosSimulator, + PreviewSupportedPlatformTvos, + PreviewSupportedPlatformTvosSimulator, + PreviewSupportedPlatformWatchos, + PreviewSupportedPlatformWatchosSimulator, + PreviewSupportedPlatformVisionos, + PreviewSupportedPlatformVisionosSimulator, + PreviewSupportedPlatformMacos, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s PreviewSupportedPlatform) MarshalText() ([]byte, error) { + switch s { + case PreviewSupportedPlatformIos: + return []byte(s), nil + case PreviewSupportedPlatformIosSimulator: + return []byte(s), nil + case PreviewSupportedPlatformTvos: + return []byte(s), nil + case PreviewSupportedPlatformTvosSimulator: + return []byte(s), nil + case PreviewSupportedPlatformWatchos: + return []byte(s), nil + case PreviewSupportedPlatformWatchosSimulator: + return []byte(s), nil + case PreviewSupportedPlatformVisionos: + return []byte(s), nil + case PreviewSupportedPlatformVisionosSimulator: + return []byte(s), nil + case PreviewSupportedPlatformMacos: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *PreviewSupportedPlatform) UnmarshalText(data []byte) error { + switch PreviewSupportedPlatform(data) { + case PreviewSupportedPlatformIos: + *s = PreviewSupportedPlatformIos + return nil + case PreviewSupportedPlatformIosSimulator: + *s = PreviewSupportedPlatformIosSimulator + return nil + case PreviewSupportedPlatformTvos: + *s = PreviewSupportedPlatformTvos + return nil + case PreviewSupportedPlatformTvosSimulator: + *s = PreviewSupportedPlatformTvosSimulator + return nil + case PreviewSupportedPlatformWatchos: + *s = PreviewSupportedPlatformWatchos + return nil + case PreviewSupportedPlatformWatchosSimulator: + *s = PreviewSupportedPlatformWatchosSimulator + return nil + case PreviewSupportedPlatformVisionos: + *s = PreviewSupportedPlatformVisionos + return nil + case PreviewSupportedPlatformVisionosSimulator: + *s = PreviewSupportedPlatformVisionosSimulator + return nil + case PreviewSupportedPlatformMacos: + *s = PreviewSupportedPlatformMacos + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + +// Ref: #/components/schemas/Project +type Project struct { + // The default branch of the project. + DefaultBranch string `json:"default_branch"` + // The full name of the project (e.g. tuist/tuist). + FullName string `json:"full_name"` + // ID of the project. + ID float64 `json:"id"` + // The URL of the connected git repository, such as https://github.com/tuist/tuist or https://github. + // com/tuist/tuist.git. + RepositoryURL OptString `json:"repository_url"` + // The token that should be used to authenticate the project. For CI only. + // + // Deprecated: schema marks this property as deprecated. + Token string `json:"token"` + // The visibility of the project. + Visibility ProjectVisibility `json:"visibility"` +} + +// GetDefaultBranch returns the value of DefaultBranch. +func (s *Project) GetDefaultBranch() string { + return s.DefaultBranch +} + +// GetFullName returns the value of FullName. +func (s *Project) GetFullName() string { + return s.FullName } // GetID returns the value of ID. @@ -3556,6 +4344,11 @@ func (s *Project) GetToken() string { return s.Token } +// GetVisibility returns the value of Visibility. +func (s *Project) GetVisibility() ProjectVisibility { + return s.Visibility +} + // SetDefaultBranch sets the value of DefaultBranch. func (s *Project) SetDefaultBranch(val string) { s.DefaultBranch = val @@ -3581,6 +4374,11 @@ func (s *Project) SetToken(val string) { s.Token = val } +// SetVisibility sets the value of Visibility. +func (s *Project) SetVisibility(val ProjectVisibility) { + s.Visibility = val +} + func (*Project) createProjectRes() {} func (*Project) showProjectRes() {} func (*Project) updateProjectRes() {} @@ -3614,6 +4412,48 @@ func (s *ProjectToken) SetInsertedAt(val time.Time) { s.InsertedAt = val } +// The visibility of the project. +type ProjectVisibility string + +const ( + ProjectVisibilityPrivate ProjectVisibility = "private" + ProjectVisibilityPublic ProjectVisibility = "public" +) + +// AllValues returns all ProjectVisibility values. +func (ProjectVisibility) AllValues() []ProjectVisibility { + return []ProjectVisibility{ + ProjectVisibilityPrivate, + ProjectVisibilityPublic, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s ProjectVisibility) MarshalText() ([]byte, error) { + switch s { + case ProjectVisibilityPrivate: + return []byte(s), nil + case ProjectVisibilityPublic: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *ProjectVisibility) UnmarshalText(data []byte) error { + switch ProjectVisibility(data) { + case ProjectVisibilityPrivate: + *s = ProjectVisibilityPrivate + return nil + case ProjectVisibilityPublic: + *s = ProjectVisibilityPublic + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + type RefreshTokenReq struct { // User refresh token. RefreshToken string `json:"refresh_token"` @@ -3650,6 +4490,252 @@ type RevokeProjectTokenUnauthorized Error func (*RevokeProjectTokenUnauthorized) revokeProjectTokenRes() {} +// The schema for a Tuist run. +// Ref: #/components/schemas/Run +type Run struct { + // Cacheable targets of the run. + CacheableTargets []string `json:"cacheable_targets"` + // Arguments passed to the command. + CommandArguments []string `json:"command_arguments"` + // Duration of the run. + Duration float64 `json:"duration"` + // Git branch of the repository. + GitBranch string `json:"git_branch"` + // Git commit SHA of the repository. + GitCommitSha string `json:"git_commit_sha"` + // Git reference of the repository. When run from CI in a pull request, this will be the remote + // reference to the pull request, such as `refs/pull/23958/merge`. + GitRef string `json:"git_ref"` + // ID of the run. + ID float64 `json:"id"` + // Local cache target hits of the run. + LocalCacheTargetHits []string `json:"local_cache_target_hits"` + // Local test target hits of the run. + LocalTestTargetHits []string `json:"local_test_target_hits"` + // Version of macOS used. + MacosVersion string `json:"macos_version"` + // Command name of the run. + Name string `json:"name"` + // ID of the associated preview. + PreviewID OptString `json:"preview_id"` + // Remote cache target hits of the run. + RemoteCacheTargetHits []string `json:"remote_cache_target_hits"` + // Remote test target hits of the run. + RemoteTestTargetHits []string `json:"remote_test_target_hits"` + // Status of the command event. + Status string `json:"status"` + // Subcommand of the run. + Subcommand string `json:"subcommand"` + // Version of Swift used. + SwiftVersion string `json:"swift_version"` + // Test targets of the run. + TestTargets []string `json:"test_targets"` + // Version of Tuist used. + TuistVersion string `json:"tuist_version"` + // URL to the run. + URL string `json:"url"` +} + +// GetCacheableTargets returns the value of CacheableTargets. +func (s *Run) GetCacheableTargets() []string { + return s.CacheableTargets +} + +// GetCommandArguments returns the value of CommandArguments. +func (s *Run) GetCommandArguments() []string { + return s.CommandArguments +} + +// GetDuration returns the value of Duration. +func (s *Run) GetDuration() float64 { + return s.Duration +} + +// GetGitBranch returns the value of GitBranch. +func (s *Run) GetGitBranch() string { + return s.GitBranch +} + +// GetGitCommitSha returns the value of GitCommitSha. +func (s *Run) GetGitCommitSha() string { + return s.GitCommitSha +} + +// GetGitRef returns the value of GitRef. +func (s *Run) GetGitRef() string { + return s.GitRef +} + +// GetID returns the value of ID. +func (s *Run) GetID() float64 { + return s.ID +} + +// GetLocalCacheTargetHits returns the value of LocalCacheTargetHits. +func (s *Run) GetLocalCacheTargetHits() []string { + return s.LocalCacheTargetHits +} + +// GetLocalTestTargetHits returns the value of LocalTestTargetHits. +func (s *Run) GetLocalTestTargetHits() []string { + return s.LocalTestTargetHits +} + +// GetMacosVersion returns the value of MacosVersion. +func (s *Run) GetMacosVersion() string { + return s.MacosVersion +} + +// GetName returns the value of Name. +func (s *Run) GetName() string { + return s.Name +} + +// GetPreviewID returns the value of PreviewID. +func (s *Run) GetPreviewID() OptString { + return s.PreviewID +} + +// GetRemoteCacheTargetHits returns the value of RemoteCacheTargetHits. +func (s *Run) GetRemoteCacheTargetHits() []string { + return s.RemoteCacheTargetHits +} + +// GetRemoteTestTargetHits returns the value of RemoteTestTargetHits. +func (s *Run) GetRemoteTestTargetHits() []string { + return s.RemoteTestTargetHits +} + +// GetStatus returns the value of Status. +func (s *Run) GetStatus() string { + return s.Status +} + +// GetSubcommand returns the value of Subcommand. +func (s *Run) GetSubcommand() string { + return s.Subcommand +} + +// GetSwiftVersion returns the value of SwiftVersion. +func (s *Run) GetSwiftVersion() string { + return s.SwiftVersion +} + +// GetTestTargets returns the value of TestTargets. +func (s *Run) GetTestTargets() []string { + return s.TestTargets +} + +// GetTuistVersion returns the value of TuistVersion. +func (s *Run) GetTuistVersion() string { + return s.TuistVersion +} + +// GetURL returns the value of URL. +func (s *Run) GetURL() string { + return s.URL +} + +// SetCacheableTargets sets the value of CacheableTargets. +func (s *Run) SetCacheableTargets(val []string) { + s.CacheableTargets = val +} + +// SetCommandArguments sets the value of CommandArguments. +func (s *Run) SetCommandArguments(val []string) { + s.CommandArguments = val +} + +// SetDuration sets the value of Duration. +func (s *Run) SetDuration(val float64) { + s.Duration = val +} + +// SetGitBranch sets the value of GitBranch. +func (s *Run) SetGitBranch(val string) { + s.GitBranch = val +} + +// SetGitCommitSha sets the value of GitCommitSha. +func (s *Run) SetGitCommitSha(val string) { + s.GitCommitSha = val +} + +// SetGitRef sets the value of GitRef. +func (s *Run) SetGitRef(val string) { + s.GitRef = val +} + +// SetID sets the value of ID. +func (s *Run) SetID(val float64) { + s.ID = val +} + +// SetLocalCacheTargetHits sets the value of LocalCacheTargetHits. +func (s *Run) SetLocalCacheTargetHits(val []string) { + s.LocalCacheTargetHits = val +} + +// SetLocalTestTargetHits sets the value of LocalTestTargetHits. +func (s *Run) SetLocalTestTargetHits(val []string) { + s.LocalTestTargetHits = val +} + +// SetMacosVersion sets the value of MacosVersion. +func (s *Run) SetMacosVersion(val string) { + s.MacosVersion = val +} + +// SetName sets the value of Name. +func (s *Run) SetName(val string) { + s.Name = val +} + +// SetPreviewID sets the value of PreviewID. +func (s *Run) SetPreviewID(val OptString) { + s.PreviewID = val +} + +// SetRemoteCacheTargetHits sets the value of RemoteCacheTargetHits. +func (s *Run) SetRemoteCacheTargetHits(val []string) { + s.RemoteCacheTargetHits = val +} + +// SetRemoteTestTargetHits sets the value of RemoteTestTargetHits. +func (s *Run) SetRemoteTestTargetHits(val []string) { + s.RemoteTestTargetHits = val +} + +// SetStatus sets the value of Status. +func (s *Run) SetStatus(val string) { + s.Status = val +} + +// SetSubcommand sets the value of Subcommand. +func (s *Run) SetSubcommand(val string) { + s.Subcommand = val +} + +// SetSwiftVersion sets the value of SwiftVersion. +func (s *Run) SetSwiftVersion(val string) { + s.SwiftVersion = val +} + +// SetTestTargets sets the value of TestTargets. +func (s *Run) SetTestTargets(val []string) { + s.TestTargets = val +} + +// SetTuistVersion sets the value of TuistVersion. +func (s *Run) SetTuistVersion(val string) { + s.TuistVersion = val +} + +// SetURL sets the value of URL. +func (s *Run) SetURL(val string) { + s.URL = val +} + type ShowOrganizationForbidden Error func (*ShowOrganizationForbidden) showOrganizationRes() {} @@ -3822,6 +4908,8 @@ type StartPreviewsMultipartUploadReq struct { BundleIdentifier OptString `json:"bundle_identifier"` // The display name of the preview. DisplayName OptString `json:"display_name"` + // The supported platforms of the preview. + SupportedPlatforms []PreviewSupportedPlatform `json:"supported_platforms"` // The type of the preview to upload. Type OptStartPreviewsMultipartUploadReqType `json:"type"` // The version of the preview. @@ -3838,6 +4926,11 @@ func (s *StartPreviewsMultipartUploadReq) GetDisplayName() OptString { return s.DisplayName } +// GetSupportedPlatforms returns the value of SupportedPlatforms. +func (s *StartPreviewsMultipartUploadReq) GetSupportedPlatforms() []PreviewSupportedPlatform { + return s.SupportedPlatforms +} + // GetType returns the value of Type. func (s *StartPreviewsMultipartUploadReq) GetType() OptStartPreviewsMultipartUploadReqType { return s.Type @@ -3858,6 +4951,11 @@ func (s *StartPreviewsMultipartUploadReq) SetDisplayName(val OptString) { s.DisplayName = val } +// SetSupportedPlatforms sets the value of SupportedPlatforms. +func (s *StartPreviewsMultipartUploadReq) SetSupportedPlatforms(val []PreviewSupportedPlatform) { + s.SupportedPlatforms = val +} + // SetType sets the value of Type. func (s *StartPreviewsMultipartUploadReq) SetType(val OptStartPreviewsMultipartUploadReqType) { s.Type = val @@ -3914,6 +5012,37 @@ type StartPreviewsMultipartUploadUnauthorized Error func (*StartPreviewsMultipartUploadUnauthorized) startPreviewsMultipartUploadRes() {} +type UpdateAccountBadRequest Error + +func (*UpdateAccountBadRequest) updateAccountRes() {} + +type UpdateAccountForbidden Error + +func (*UpdateAccountForbidden) updateAccountRes() {} + +type UpdateAccountNotFound Error + +func (*UpdateAccountNotFound) updateAccountRes() {} + +type UpdateAccountReq struct { + // The new account handle. + Handle OptString `json:"handle"` +} + +// GetHandle returns the value of Handle. +func (s *UpdateAccountReq) GetHandle() OptString { + return s.Handle +} + +// SetHandle sets the value of Handle. +func (s *UpdateAccountReq) SetHandle(val OptString) { + s.Handle = val +} + +type UpdateAccountUnauthorized Error + +func (*UpdateAccountUnauthorized) updateAccountRes() {} + type UpdateOrganization2BadRequest Error func (*UpdateOrganization2BadRequest) updateOrganization2Res() {} @@ -3958,6 +5087,7 @@ type UpdateOrganization2ReqSSOProvider string const ( UpdateOrganization2ReqSSOProviderGoogle UpdateOrganization2ReqSSOProvider = "google" + UpdateOrganization2ReqSSOProviderOkta UpdateOrganization2ReqSSOProvider = "okta" UpdateOrganization2ReqSSOProviderNone UpdateOrganization2ReqSSOProvider = "none" ) @@ -3965,6 +5095,7 @@ const ( func (UpdateOrganization2ReqSSOProvider) AllValues() []UpdateOrganization2ReqSSOProvider { return []UpdateOrganization2ReqSSOProvider{ UpdateOrganization2ReqSSOProviderGoogle, + UpdateOrganization2ReqSSOProviderOkta, UpdateOrganization2ReqSSOProviderNone, } } @@ -3974,6 +5105,8 @@ func (s UpdateOrganization2ReqSSOProvider) MarshalText() ([]byte, error) { switch s { case UpdateOrganization2ReqSSOProviderGoogle: return []byte(s), nil + case UpdateOrganization2ReqSSOProviderOkta: + return []byte(s), nil case UpdateOrganization2ReqSSOProviderNone: return []byte(s), nil default: @@ -3987,6 +5120,9 @@ func (s *UpdateOrganization2ReqSSOProvider) UnmarshalText(data []byte) error { case UpdateOrganization2ReqSSOProviderGoogle: *s = UpdateOrganization2ReqSSOProviderGoogle return nil + case UpdateOrganization2ReqSSOProviderOkta: + *s = UpdateOrganization2ReqSSOProviderOkta + return nil case UpdateOrganization2ReqSSOProviderNone: *s = UpdateOrganization2ReqSSOProviderNone return nil @@ -4116,6 +5252,7 @@ type UpdateOrganizationReqSSOProvider string const ( UpdateOrganizationReqSSOProviderGoogle UpdateOrganizationReqSSOProvider = "google" + UpdateOrganizationReqSSOProviderOkta UpdateOrganizationReqSSOProvider = "okta" UpdateOrganizationReqSSOProviderNone UpdateOrganizationReqSSOProvider = "none" ) @@ -4123,6 +5260,7 @@ const ( func (UpdateOrganizationReqSSOProvider) AllValues() []UpdateOrganizationReqSSOProvider { return []UpdateOrganizationReqSSOProvider{ UpdateOrganizationReqSSOProviderGoogle, + UpdateOrganizationReqSSOProviderOkta, UpdateOrganizationReqSSOProviderNone, } } @@ -4132,6 +5270,8 @@ func (s UpdateOrganizationReqSSOProvider) MarshalText() ([]byte, error) { switch s { case UpdateOrganizationReqSSOProviderGoogle: return []byte(s), nil + case UpdateOrganizationReqSSOProviderOkta: + return []byte(s), nil case UpdateOrganizationReqSSOProviderNone: return []byte(s), nil default: @@ -4145,6 +5285,9 @@ func (s *UpdateOrganizationReqSSOProvider) UnmarshalText(data []byte) error { case UpdateOrganizationReqSSOProviderGoogle: *s = UpdateOrganizationReqSSOProviderGoogle return nil + case UpdateOrganizationReqSSOProviderOkta: + *s = UpdateOrganizationReqSSOProviderOkta + return nil case UpdateOrganizationReqSSOProviderNone: *s = UpdateOrganizationReqSSOProviderNone return nil @@ -4174,6 +5317,9 @@ type UpdateProjectReq struct { DefaultBranch OptString `json:"default_branch"` // The repository URL for the project. RepositoryURL OptString `json:"repository_url"` + // The visibility of the project. Public projects are visible to everyone, private projects are only + // visible to the project's members. + Visibility OptUpdateProjectReqVisibility `json:"visibility"` } // GetDefaultBranch returns the value of DefaultBranch. @@ -4186,6 +5332,11 @@ func (s *UpdateProjectReq) GetRepositoryURL() OptString { return s.RepositoryURL } +// GetVisibility returns the value of Visibility. +func (s *UpdateProjectReq) GetVisibility() OptUpdateProjectReqVisibility { + return s.Visibility +} + // SetDefaultBranch sets the value of DefaultBranch. func (s *UpdateProjectReq) SetDefaultBranch(val OptString) { s.DefaultBranch = val @@ -4196,6 +5347,54 @@ func (s *UpdateProjectReq) SetRepositoryURL(val OptString) { s.RepositoryURL = val } +// SetVisibility sets the value of Visibility. +func (s *UpdateProjectReq) SetVisibility(val OptUpdateProjectReqVisibility) { + s.Visibility = val +} + +// The visibility of the project. Public projects are visible to everyone, private projects are only +// visible to the project's members. +type UpdateProjectReqVisibility string + +const ( + UpdateProjectReqVisibilityPublic UpdateProjectReqVisibility = "public" + UpdateProjectReqVisibilityPrivate UpdateProjectReqVisibility = "private" +) + +// AllValues returns all UpdateProjectReqVisibility values. +func (UpdateProjectReqVisibility) AllValues() []UpdateProjectReqVisibility { + return []UpdateProjectReqVisibility{ + UpdateProjectReqVisibilityPublic, + UpdateProjectReqVisibilityPrivate, + } +} + +// MarshalText implements encoding.TextMarshaler. +func (s UpdateProjectReqVisibility) MarshalText() ([]byte, error) { + switch s { + case UpdateProjectReqVisibilityPublic: + return []byte(s), nil + case UpdateProjectReqVisibilityPrivate: + return []byte(s), nil + default: + return nil, errors.Errorf("invalid value: %q", s) + } +} + +// UnmarshalText implements encoding.TextUnmarshaler. +func (s *UpdateProjectReqVisibility) UnmarshalText(data []byte) error { + switch UpdateProjectReqVisibility(data) { + case UpdateProjectReqVisibilityPublic: + *s = UpdateProjectReqVisibilityPublic + return nil + case UpdateProjectReqVisibilityPrivate: + *s = UpdateProjectReqVisibilityPrivate + return nil + default: + return errors.Errorf("invalid value: %q", data) + } +} + type UpdateProjectUnauthorized Error func (*UpdateProjectUnauthorized) updateProjectRes() {} @@ -4243,6 +5442,18 @@ type UploadCacheActionItemUnauthorized Error func (*UploadCacheActionItemUnauthorized) uploadCacheActionItemRes() {} +type UploadPreviewIconForbidden Error + +func (*UploadPreviewIconForbidden) uploadPreviewIconRes() {} + +type UploadPreviewIconNotFound Error + +func (*UploadPreviewIconNotFound) uploadPreviewIconRes() {} + +type UploadPreviewIconUnauthorized Error + +func (*UploadPreviewIconUnauthorized) uploadPreviewIconRes() {} + // A user. // Ref: #/components/schemas/User type User struct { diff --git a/internal/agent/http_cache/tuistcache/api/oas_security_gen.go b/internal/agent/http_cache/tuistcache/api/oas_security_gen.go deleted file mode 100644 index 5c9d76eb..00000000 --- a/internal/agent/http_cache/tuistcache/api/oas_security_gen.go +++ /dev/null @@ -1,101 +0,0 @@ -// Code generated by ogen, DO NOT EDIT. - -package api - -import ( - "context" - "net/http" - "strings" - - "github.com/go-faster/errors" - - "github.com/ogen-go/ogen/ogenerrors" -) - -// SecurityHandler is handler for security parameters. -type SecurityHandler interface { - // HandleAuthorization handles authorization security. - HandleAuthorization(ctx context.Context, operationName string, t Authorization) (context.Context, error) - // HandleCookie handles cookie security. - HandleCookie(ctx context.Context, operationName string, t Cookie) (context.Context, error) -} - -func findAuthorization(h http.Header, prefix string) (string, bool) { - v, ok := h["Authorization"] - if !ok { - return "", false - } - for _, vv := range v { - scheme, value, ok := strings.Cut(vv, " ") - if !ok || !strings.EqualFold(scheme, prefix) { - continue - } - return value, true - } - return "", false -} - -func (s *Server) securityAuthorization(ctx context.Context, operationName string, req *http.Request) (context.Context, bool, error) { - var t Authorization - token, ok := findAuthorization(req.Header, "Bearer") - if !ok { - return ctx, false, nil - } - t.Token = token - rctx, err := s.sec.HandleAuthorization(ctx, operationName, t) - if errors.Is(err, ogenerrors.ErrSkipServerSecurity) { - return nil, false, nil - } else if err != nil { - return nil, false, err - } - return rctx, true, err -} -func (s *Server) securityCookie(ctx context.Context, operationName string, req *http.Request) (context.Context, bool, error) { - var t Cookie - const parameterName = "_tuist_cloud_key" - var value string - switch cookie, err := req.Cookie(parameterName); { - case err == nil: // if NO error - value = cookie.Value - case errors.Is(err, http.ErrNoCookie): - return ctx, false, nil - default: - return nil, false, errors.Wrap(err, "get cookie value") - } - t.APIKey = value - rctx, err := s.sec.HandleCookie(ctx, operationName, t) - if errors.Is(err, ogenerrors.ErrSkipServerSecurity) { - return nil, false, nil - } else if err != nil { - return nil, false, err - } - return rctx, true, err -} - -// SecuritySource is provider of security values (tokens, passwords, etc.). -type SecuritySource interface { - // Authorization provides authorization security value. - Authorization(ctx context.Context, operationName string) (Authorization, error) - // Cookie provides cookie security value. - Cookie(ctx context.Context, operationName string) (Cookie, error) -} - -func (s *Client) securityAuthorization(ctx context.Context, operationName string, req *http.Request) error { - t, err := s.sec.Authorization(ctx, operationName) - if err != nil { - return errors.Wrap(err, "security source \"Authorization\"") - } - req.Header.Set("Authorization", "Bearer "+t.Token) - return nil -} -func (s *Client) securityCookie(ctx context.Context, operationName string, req *http.Request) error { - t, err := s.sec.Cookie(ctx, operationName) - if err != nil { - return errors.Wrap(err, "security source \"Cookie\"") - } - req.AddCookie(&http.Cookie{ - Name: "_tuist_cloud_key", - Value: t.APIKey, - }) - return nil -} diff --git a/internal/agent/http_cache/tuistcache/api/oas_server_gen.go b/internal/agent/http_cache/tuistcache/api/oas_server_gen.go index 26701097..272c3a01 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_server_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_server_gen.go @@ -23,6 +23,12 @@ type Handler interface { // // GET /api/cache/exists CacheArtifactExists(ctx context.Context, params CacheArtifactExistsParams) (CacheArtifactExistsRes, error) + // CancelInvitation implements cancelInvitation operation. + // + // Cancels an invitation for a given invitee email and an organization. + // + // DELETE /api/organizations/{organization_name}/invitations + CancelInvitation(ctx context.Context, req OptCancelInvitationReq, params CancelInvitationParams) (CancelInvitationRes, error) // CleanCache implements cleanCache operation. // // Cleans cache for a given project. @@ -57,6 +63,12 @@ type Handler interface { // // POST /api/projects/{account_handle}/{project_handle}/previews/complete CompletePreviewsMultipartUpload(ctx context.Context, req OptCompletePreviewsMultipartUploadReq, params CompletePreviewsMultipartUploadParams) (CompletePreviewsMultipartUploadRes, error) + // CreateAccountToken implements createAccountToken operation. + // + // This endpoint returns a new account token. + // + // POST /api/accounts/{account_handle}/tokens + CreateAccountToken(ctx context.Context, req OptCreateAccountTokenReq, params CreateAccountTokenParams) (CreateAccountTokenRes, error) // CreateCommandEvent implements createCommandEvent operation. // // Create a a new command analytics event. @@ -107,7 +119,7 @@ type Handler interface { DownloadCacheArtifact(ctx context.Context, params DownloadCacheArtifactParams) (DownloadCacheArtifactRes, error) // DownloadPreview implements downloadPreview operation. // - // This endpoint returns a signed URL that can be used to download a preview. + // This endpoint returns a preview with a given id, including the url to download the preview. // // GET /api/projects/{account_handle}/{project_handle}/previews/{preview_id} DownloadPreview(ctx context.Context, params DownloadPreviewParams) (DownloadPreviewRes, error) @@ -150,6 +162,12 @@ type Handler interface { // // GET /api/organizations ListOrganizations(ctx context.Context) (ListOrganizationsRes, error) + // ListPreviews implements listPreviews operation. + // + // This endpoint returns a list of previews for a given project. + // + // GET /api/projects/{account_handle}/{project_handle}/previews + ListPreviews(ctx context.Context, params ListPreviewsParams) (ListPreviewsRes, error) // ListProjectTokens implements listProjectTokens operation. // // This endpoint returns all tokens for a given project. @@ -162,6 +180,12 @@ type Handler interface { // // GET /api/projects ListProjects(ctx context.Context) (ListProjectsRes, error) + // ListRuns implements listRuns operation. + // + // List runs associated with a given project. + // + // GET /api/projects/{account_handle}/{project_handle}/runs + ListRuns(ctx context.Context, params ListRunsParams) (ListRunsRes, error) // RefreshToken implements refreshToken operation. // // This endpoint returns new tokens for a given refresh token if the refresh token is valid. @@ -198,7 +222,7 @@ type Handler interface { // complete the upload. // // POST /api/runs/{run_id}/start - StartAnalyticsArtifactMultipartUpload(ctx context.Context, req CommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (StartAnalyticsArtifactMultipartUploadRes, error) + StartAnalyticsArtifactMultipartUpload(ctx context.Context, req OptCommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (StartAnalyticsArtifactMultipartUploadRes, error) // StartCacheArtifactMultipartUpload implements startCacheArtifactMultipartUpload operation. // // The endpoint returns an upload ID that can be used to generate URLs for the individual parts and @@ -213,6 +237,12 @@ type Handler interface { // // POST /api/projects/{account_handle}/{project_handle}/previews/start StartPreviewsMultipartUpload(ctx context.Context, req OptStartPreviewsMultipartUploadReq, params StartPreviewsMultipartUploadParams) (StartPreviewsMultipartUploadRes, error) + // UpdateAccount implements updateAccount operation. + // + // Updates the given account. + // + // PATCH /api/accounts/{account_handle} + UpdateAccount(ctx context.Context, req OptUpdateAccountReq, params UpdateAccountParams) (UpdateAccountRes, error) // UpdateOrganization implements updateOrganization operation. // // Updates an organization with given parameters. @@ -244,25 +274,29 @@ type Handler interface { // // POST /api/projects/{account_handle}/{project_handle}/cache/ac UploadCacheActionItem(ctx context.Context, req OptUploadCacheActionItemReq, params UploadCacheActionItemParams) (UploadCacheActionItemRes, error) + // UploadPreviewIcon implements uploadPreviewIcon operation. + // + // The endpoint uploads a preview icon. + // + // POST /api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons + UploadPreviewIcon(ctx context.Context, params UploadPreviewIconParams) (UploadPreviewIconRes, error) } // Server implements http server based on OpenAPI v3 specification and // calls Handler to handle requests. type Server struct { - h Handler - sec SecurityHandler + h Handler baseServer } // NewServer creates new Server. -func NewServer(h Handler, sec SecurityHandler, opts ...ServerOption) (*Server, error) { +func NewServer(h Handler, opts ...ServerOption) (*Server, error) { s, err := newServerConfig(opts...).baseServer() if err != nil { return nil, err } return &Server{ h: h, - sec: sec, baseServer: s, }, nil } diff --git a/internal/agent/http_cache/tuistcache/api/oas_unimplemented_gen.go b/internal/agent/http_cache/tuistcache/api/oas_unimplemented_gen.go index c54adf8d..3b84b6d2 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_unimplemented_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_unimplemented_gen.go @@ -34,6 +34,15 @@ func (UnimplementedHandler) CacheArtifactExists(ctx context.Context, params Cach return r, ht.ErrNotImplemented } +// CancelInvitation implements cancelInvitation operation. +// +// Cancels an invitation for a given invitee email and an organization. +// +// DELETE /api/organizations/{organization_name}/invitations +func (UnimplementedHandler) CancelInvitation(ctx context.Context, req OptCancelInvitationReq, params CancelInvitationParams) (r CancelInvitationRes, _ error) { + return r, ht.ErrNotImplemented +} + // CleanCache implements cleanCache operation. // // Cleans cache for a given project. @@ -83,6 +92,15 @@ func (UnimplementedHandler) CompletePreviewsMultipartUpload(ctx context.Context, return r, ht.ErrNotImplemented } +// CreateAccountToken implements createAccountToken operation. +// +// This endpoint returns a new account token. +// +// POST /api/accounts/{account_handle}/tokens +func (UnimplementedHandler) CreateAccountToken(ctx context.Context, req OptCreateAccountTokenReq, params CreateAccountTokenParams) (r CreateAccountTokenRes, _ error) { + return r, ht.ErrNotImplemented +} + // CreateCommandEvent implements createCommandEvent operation. // // Create a a new command analytics event. @@ -157,7 +175,7 @@ func (UnimplementedHandler) DownloadCacheArtifact(ctx context.Context, params Do // DownloadPreview implements downloadPreview operation. // -// This endpoint returns a signed URL that can be used to download a preview. +// This endpoint returns a preview with a given id, including the url to download the preview. // // GET /api/projects/{account_handle}/{project_handle}/previews/{preview_id} func (UnimplementedHandler) DownloadPreview(ctx context.Context, params DownloadPreviewParams) (r DownloadPreviewRes, _ error) { @@ -221,6 +239,15 @@ func (UnimplementedHandler) ListOrganizations(ctx context.Context) (r ListOrgani return r, ht.ErrNotImplemented } +// ListPreviews implements listPreviews operation. +// +// This endpoint returns a list of previews for a given project. +// +// GET /api/projects/{account_handle}/{project_handle}/previews +func (UnimplementedHandler) ListPreviews(ctx context.Context, params ListPreviewsParams) (r ListPreviewsRes, _ error) { + return r, ht.ErrNotImplemented +} + // ListProjectTokens implements listProjectTokens operation. // // This endpoint returns all tokens for a given project. @@ -239,6 +266,15 @@ func (UnimplementedHandler) ListProjects(ctx context.Context) (r ListProjectsRes return r, ht.ErrNotImplemented } +// ListRuns implements listRuns operation. +// +// List runs associated with a given project. +// +// GET /api/projects/{account_handle}/{project_handle}/runs +func (UnimplementedHandler) ListRuns(ctx context.Context, params ListRunsParams) (r ListRunsRes, _ error) { + return r, ht.ErrNotImplemented +} + // RefreshToken implements refreshToken operation. // // This endpoint returns new tokens for a given refresh token if the refresh token is valid. @@ -290,7 +326,7 @@ func (UnimplementedHandler) ShowProject(ctx context.Context, params ShowProjectP // complete the upload. // // POST /api/runs/{run_id}/start -func (UnimplementedHandler) StartAnalyticsArtifactMultipartUpload(ctx context.Context, req CommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (r StartAnalyticsArtifactMultipartUploadRes, _ error) { +func (UnimplementedHandler) StartAnalyticsArtifactMultipartUpload(ctx context.Context, req OptCommandEventArtifact, params StartAnalyticsArtifactMultipartUploadParams) (r StartAnalyticsArtifactMultipartUploadRes, _ error) { return r, ht.ErrNotImplemented } @@ -314,6 +350,15 @@ func (UnimplementedHandler) StartPreviewsMultipartUpload(ctx context.Context, re return r, ht.ErrNotImplemented } +// UpdateAccount implements updateAccount operation. +// +// Updates the given account. +// +// PATCH /api/accounts/{account_handle} +func (UnimplementedHandler) UpdateAccount(ctx context.Context, req OptUpdateAccountReq, params UpdateAccountParams) (r UpdateAccountRes, _ error) { + return r, ht.ErrNotImplemented +} + // UpdateOrganization implements updateOrganization operation. // // Updates an organization with given parameters. @@ -359,3 +404,12 @@ func (UnimplementedHandler) UpdateProject(ctx context.Context, req OptUpdateProj func (UnimplementedHandler) UploadCacheActionItem(ctx context.Context, req OptUploadCacheActionItemReq, params UploadCacheActionItemParams) (r UploadCacheActionItemRes, _ error) { return r, ht.ErrNotImplemented } + +// UploadPreviewIcon implements uploadPreviewIcon operation. +// +// The endpoint uploads a preview icon. +// +// POST /api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons +func (UnimplementedHandler) UploadPreviewIcon(ctx context.Context, params UploadPreviewIconParams) (r UploadPreviewIconRes, _ error) { + return r, ht.ErrNotImplemented +} diff --git a/internal/agent/http_cache/tuistcache/api/oas_validators_gen.go b/internal/agent/http_cache/tuistcache/api/oas_validators_gen.go index fe74089a..4b59d618 100644 --- a/internal/agent/http_cache/tuistcache/api/oas_validators_gen.go +++ b/internal/agent/http_cache/tuistcache/api/oas_validators_gen.go @@ -10,6 +10,29 @@ import ( "github.com/ogen-go/ogen/validate" ) +func (s *Account) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.ID)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "id", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + func (s *ArtifactMultipartUploadParts) Validate() error { if s == nil { return validate.ErrNilPointer @@ -202,12 +225,59 @@ func (s *CommandEvent) Validate() error { return nil } +func (s *CommandEventArtifact) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.Type.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "type", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s CommandEventArtifactType) Validate() error { + switch s { + case "result_bundle": + return nil + case "invocation_record": + return nil + case "result_bundle_object": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *CompleteAnalyticsArtifactMultipartUploadReq) Validate() error { if s == nil { return validate.ErrNilPointer } var failures []validate.FieldError + if err := func() error { + if err := s.CommandEventArtifact.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "command_event_artifact", + Error: err, + }) + } if err := func() error { if err := s.MultipartUploadParts.Validate(); err != nil { return err @@ -310,6 +380,55 @@ func (s *CompletePreviewsMultipartUploadReq) Validate() error { return nil } +func (s *CreateAccountTokenReq) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.Scopes == nil { + return errors.New("nil is invalid value") + } + var failures []validate.FieldError + for i, elem := range s.Scopes { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "scopes", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s CreateAccountTokenReqScopesItem) Validate() error { + switch s { + case "account_registry_read": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *CreateCommandEventReq) Validate() error { if s == nil { return validate.ErrNilPointer @@ -362,6 +481,29 @@ func (s CreateCommandEventReqStatus) Validate() error { } } +func (s *GenerateAnalyticsArtifactMultipartUploadURLReq) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if err := s.CommandEventArtifact.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "command_event_artifact", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + func (s *Invitation) Validate() error { if s == nil { return validate.ErrNilPointer @@ -447,6 +589,38 @@ func (s *ListOrganizationsOK) Validate() error { return nil } +func (s ListPreviewsDistinctField) Validate() error { + switch s { + case "bundle_identifier": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *ListPreviewsOK) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.Previews == nil { + return errors.New("nil is invalid value") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "previews", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + func (s *ListProjectTokensOK) Validate() error { if s == nil { return validate.ErrNilPointer @@ -510,6 +684,46 @@ func (s *ListProjectsOK) Validate() error { return nil } +func (s *ListRunsOK) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.Runs == nil { + return errors.New("nil is invalid value") + } + var failures []validate.FieldError + for i, elem := range s.Runs { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "runs", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + func (s *Organization) Validate() error { if s == nil { return validate.ErrNilPointer @@ -682,6 +896,8 @@ func (s OrganizationSSOProvider) Validate() error { switch s { case "google": return nil + case "okta": + return nil default: return errors.Errorf("invalid value: %v", s) } @@ -710,6 +926,31 @@ func (s *OrganizationUsage) Validate() error { return nil } +func (s PreviewSupportedPlatform) Validate() error { + switch s { + case "ios": + return nil + case "ios_simulator": + return nil + case "tvos": + return nil + case "tvos_simulator": + return nil + case "watchos": + return nil + case "watchos_simulator": + return nil + case "visionos": + return nil + case "visionos_simulator": + return nil + case "macos": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *Project) Validate() error { if s == nil { return validate.ErrNilPointer @@ -727,6 +968,73 @@ func (s *Project) Validate() error { Error: err, }) } + if err := func() error { + if err := s.Visibility.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "visibility", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s ProjectVisibility) Validate() error { + switch s { + case "private": + return nil + case "public": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + +func (s *Run) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if s.CommandArguments == nil { + return errors.New("nil is invalid value") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "command_arguments", + Error: err, + }) + } + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.Duration)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "duration", + Error: err, + }) + } + if err := func() error { + if err := (validate.Float{}).Validate(float64(s.ID)); err != nil { + return errors.Wrap(err, "float") + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "id", + Error: err, + }) + } if len(failures) > 0 { return &validate.Error{Fields: failures} } @@ -771,6 +1079,31 @@ func (s *StartPreviewsMultipartUploadReq) Validate() error { } var failures []validate.FieldError + if err := func() error { + var failures []validate.FieldError + for i, elem := range s.SupportedPlatforms { + if err := func() error { + if err := elem.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: fmt.Sprintf("[%d]", i), + Error: err, + }) + } + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "supported_platforms", + Error: err, + }) + } if err := func() error { if value, ok := s.Type.Get(); ok { if err := func() error { @@ -840,6 +1173,8 @@ func (s UpdateOrganization2ReqSSOProvider) Validate() error { switch s { case "google": return nil + case "okta": + return nil case "none": return nil default: @@ -915,6 +1250,8 @@ func (s UpdateOrganizationReqSSOProvider) Validate() error { switch s { case "google": return nil + case "okta": + return nil case "none": return nil default: @@ -922,6 +1259,47 @@ func (s UpdateOrganizationReqSSOProvider) Validate() error { } } +func (s *UpdateProjectReq) Validate() error { + if s == nil { + return validate.ErrNilPointer + } + + var failures []validate.FieldError + if err := func() error { + if value, ok := s.Visibility.Get(); ok { + if err := func() error { + if err := value.Validate(); err != nil { + return err + } + return nil + }(); err != nil { + return err + } + } + return nil + }(); err != nil { + failures = append(failures, validate.FieldError{ + Name: "visibility", + Error: err, + }) + } + if len(failures) > 0 { + return &validate.Error{Fields: failures} + } + return nil +} + +func (s UpdateProjectReqVisibility) Validate() error { + switch s { + case "public": + return nil + case "private": + return nil + default: + return errors.Errorf("invalid value: %v", s) + } +} + func (s *User) Validate() error { if s == nil { return validate.ErrNilPointer diff --git a/internal/agent/http_cache/tuistcache/openapi.json b/internal/agent/http_cache/tuistcache/openapi.json index 7bccacd2..b872a6fb 100644 --- a/internal/agent/http_cache/tuistcache/openapi.json +++ b/internal/agent/http_cache/tuistcache/openapi.json @@ -1 +1,5040 @@ -{"components":{"responses":{},"schemas":{"AbsentCacheArtifact":{"properties":{"error":{"items":{"properties":{"code":{"default":"not_found","type":"string"},"message":{"type":"string"}},"type":"object"},"type":"array"}},"title":"AbsentCacheArtifact","type":"object"},"ArtifactDownloadURL":{"description":"The URL to download an artifact.","properties":{"expires_at":{"description":"The UNIX timestamp when the URL expires.","type":"integer"},"url":{"description":"The URL to download the artifact.","type":"string"}},"required":["url","expires_at"],"title":"ArtifactDownloadURL","type":"object"},"ArtifactMultipartUploadPart":{"description":"Represents an multipart upload's part identified by the upload id and the part number","properties":{"content_length":{"description":"The content length of the part.","type":"integer"},"part_number":{"description":"The part number of the multipart upload.","type":"integer"},"upload_id":{"description":"The upload ID.","type":"string"}},"required":["part_number","upload_id"],"title":"ArtifactMultipartUploadPart"},"ArtifactMultipartUploadParts":{"description":"It represents a part that has been uploaded using multipart uploads. The part is identified by its number and the etag","properties":{"parts":{"items":{"properties":{"etag":{"description":"The ETag of the part","type":"string"},"part_number":{"description":"The part number","type":"integer"}},"required":["part_number","etag"],"type":"object"},"type":"array"},"upload_id":{"description":"The upload ID","type":"string"}},"required":["upload_id","parts"],"title":"ArtifactMultipartUploadParts","type":"object"},"ArtifactMultipartUploadURL":{"description":"The URL to upload a multipart part","properties":{"data":{"properties":{"url":{"description":"The URL to upload the part","type":"string"}},"required":["url"],"type":"object"},"status":{"default":"success","enum":["success"],"type":"string"}},"required":["status","data"],"title":"ArtifactMultipartUploadURL","type":"object"},"ArtifactUploadID":{"description":"The upload has been initiated and a ID is returned to upload the various parts using multi-part uploads","properties":{"data":{"description":"Data that contains ID that's associated with the multipart upload to use when uploading parts","properties":{"upload_id":{"description":"The upload ID","type":"string"}},"required":["upload_id"],"type":"object"},"status":{"default":"success","enum":["success"],"type":"string"}},"required":["status","data"],"title":"ArtifactUploadID","type":"object"},"AuthenticationTokens":{"description":"A pair of access token to authenticate requests and refresh token to generate new access tokens when they expire.","properties":{"access_token":{"description":"API access token.","type":"string"},"refresh_token":{"description":"A token to generate new API access tokens when they expire.","type":"string"}},"required":["access_token","refresh_token"],"title":"AuthenticationTokens","type":"object"},"CacheActionItem":{"description":"Represents an action item stored in the cache.","properties":{"hash":{"description":"The hash that uniquely identifies the artifact in the cache.","type":"string"}},"required":["hash"],"title":"CacheActionItem","type":"object"},"CacheActionItemUploadParams":{"properties":{"hash":{"description":"The hash of the cache action item.","type":"string"}},"title":"CacheActionItemUploadParams","type":"object"},"CacheArtifactDownloadURL":{"description":"The URL to download the artifact from the cache.","properties":{"data":{"properties":{"expires_at":{"description":"The UNIX timestamp when the URL expires.","type":"integer"},"url":{"description":"The URL to download the artifact from the cache.","type":"string"}},"required":["url","expires_at"],"type":"object"},"status":{"default":"success","enum":["success"],"type":"string"}},"required":["status","data"],"title":"CacheArtifactDownloadURL","type":"object"},"CacheArtifactExistence":{"description":"The artifact exists in the cache and can be downloaded","properties":{"data":{"properties":{},"type":"object"},"status":{"default":"success","enum":["success"],"type":"string"}},"title":"CacheArtifactExistence","type":"object"},"CacheArtifactMultipartUploadCompletion":{"description":"This response confirms that the upload has been completed successfully. The cache will now be able to serve the artifact.","properties":{"data":{"properties":{},"type":"object"},"status":{"default":"success","enum":["success"],"type":"string"}},"title":"CacheArtifactMultipartUploadCompletion","type":"object"},"CacheCategory":{"default":"builds","description":"The category of the cache.","enum":["tests","builds"],"title":"CacheCategory","type":"string"},"CommandEvent":{"description":"The schema for the command analytics event.","properties":{"id":{"description":"ID of the command event","type":"number"},"name":{"description":"Name of the command","type":"string"},"url":{"description":"URL to the command event","type":"string"}},"required":["id","name","url"],"title":"CommandEvent","type":"object"},"CommandEventArtifact":{"description":"It represents an artifact that's associated with a command event (e.g. result bundles)","properties":{"name":{"description":"The name of the file. It's used only for certain types such as result_bundle_object","type":"string"},"type":{"description":"The command event artifact type. It can be:\n- result_bundle: A result bundle artifact that represents the whole `.xcresult` bundle\n- invocation_record: An invocation record artifact. This is a root bundle object of the result bundle\n- result_bundle_object: A result bundle object. There are many different bundle objects per result bundle.\n","enum":["result_bundle","invocation_record","result_bundle_object"],"type":"string"}},"required":["type"],"title":"CommandEventArtifact"},"DeviceCodeAuthenticationTokens":{"description":"Token to authenticate the user with.","properties":{"access_token":{"description":"A short-lived token to authenticate API requests as user.","type":"string"},"refresh_token":{"description":"A token to generate new access tokens when they expire.","type":"string"},"token":{"deprecated":true,"description":"User authentication token","type":"string"}},"title":"DeviceCodeAuthenticationTokens","type":"object"},"Error":{"properties":{"message":{"description":"The error message","type":"string"}},"required":["message"],"title":"Error","type":"object"},"Invitation":{"properties":{"id":{"description":"The invitation's unique identifier","type":"number"},"invitee_email":{"description":"The email of the invitee","type":"string"},"inviter":{"$ref":"#/components/schemas/User"},"organization_id":{"description":"The id of the organization the invitee is invited to","type":"number"},"token":{"description":"The token to accept the invitation","type":"string"}},"required":["id","invitee_email","organization_id","inviter","token"],"title":"Invitation","type":"object"},"Module":{"properties":{"hash":{"description":"A hash that represents the module.","type":"string"},"name":{"description":"A name of the module","type":"string"},"project_identifier":{"description":"Project's relative path from the root of the repository","type":"string"}},"required":["name","project_identifier","hash"],"title":"Module","type":"object"},"Organization":{"description":"An organization","properties":{"id":{"description":"The organization's unique identifier","type":"number"},"invitations":{"description":"A list of organization invitations","items":{"$ref":"#/components/schemas/Invitation"},"type":"array"},"members":{"description":"A list of organization members","items":{"$ref":"#/components/schemas/OrganizationMember"},"type":"array"},"name":{"description":"The organization's name","type":"string"},"plan":{"description":"The plan associated with the organization","enum":["air","pro","enterprise","none"],"type":"string"},"sso_organization_id":{"description":"The organization ID associated with the SSO provider","type":"string"},"sso_provider":{"description":"The SSO provider set up for the organization","enum":["google"],"type":"string"}},"required":["id","name","plan","members","invitations"],"title":"Organization","type":"object"},"OrganizationList":{"description":"The list of organizations the authenticated subject is part of.","properties":{"organizations":{"items":{"$ref":"#/components/schemas/Organization"},"type":"array"}},"required":["organizations"],"title":"OrganizationList","type":"object"},"OrganizationMember":{"description":"An organization member","properties":{"email":{"description":"The organization member's email","type":"string"},"id":{"description":"The organization member's unique identifier","type":"number"},"name":{"description":"The organization member's name","type":"string"},"role":{"description":"The organization member's role","enum":["admin","user"],"type":"string"}},"required":["id","email","name","role"],"title":"OrganizationMember","type":"object"},"OrganizationUsage":{"description":"The usage of an organization.","properties":{"current_month_remote_cache_hits":{"description":"The number of remote cache hits in the current month","type":"number"}},"required":["current_month_remote_cache_hits"],"title":"OrganizationUsage","type":"object"},"PreviewArtifactUpload":{"description":"The upload has been initiated and preview and upload unique identifier are returned to upload the various parts using multi-part uploads","properties":{"data":{"description":"Data that contains preview and upload unique identifier associated with the multipart upload to use when uploading parts","properties":{"preview_id":{"description":"The id of the preview.","type":"string"},"upload_id":{"description":"The upload ID","type":"string"}},"required":["upload_id","preview_id"],"type":"object"},"status":{"default":"success","enum":["success"],"type":"string"}},"required":["status","data"],"title":"PreviewArtifactUpload","type":"object"},"PreviewUploadCompletion":{"description":"The preview multipart upload has been completed","properties":{"url":{"description":"The URL to download the preview","type":"string"}},"required":["url"],"title":"PreviewUploadCompletion","type":"object"},"Project":{"properties":{"default_branch":{"description":"The default branch of the project.","example":"main","type":"string"},"full_name":{"description":"The full name of the project (e.g. tuist/tuist)","type":"string"},"id":{"description":"ID of the project","type":"number"},"repository_url":{"description":"The URL of the connected git repository, such as https://github.com/tuist/tuist or https://github.com/tuist/tuist.git","type":"string"},"token":{"deprecated":true,"description":"The token that should be used to authenticate the project. For CI only.","type":"string"}},"required":["id","full_name","token","default_branch"],"title":"Project","type":"object"},"ProjectFullToken":{"description":"A new project token.","properties":{"token":{"description":"The generated project token.","type":"string"}},"required":["token"],"title":"ProjectFullToken","type":"object"},"ProjectToken":{"description":"A token to authenticate API requests as a project.","properties":{"id":{"description":"The token unique identifier.","type":"string"},"inserted_at":{"description":"The timestamp of when the token was created.","format":"date-time","type":"string"}},"required":["id","inserted_at"],"title":"ProjectToken","type":"object"},"Tokens":{"description":"A list of project tokens.","properties":{"tokens":{"items":{"$ref":"#/components/schemas/ProjectToken"},"type":"array"}},"required":["tokens"],"title":"Tokens","type":"object"},"User":{"description":"A user.","properties":{"email":{"description":"The user's email","type":"string"},"id":{"description":"The user's unique identifier","type":"number"},"name":{"description":"The user's name","type":"string"}},"required":["id","email","name"],"title":"User","type":"object"}},"securitySchemes":{"authorization":{"scheme":"bearer","type":"http"},"cookie":{"in":"cookie","name":"_tuist_cloud_key","type":"apiKey"}}},"info":{"title":"Tuist","version":"0.1.0","x-logo":{"altText":"Tuist logo","url":"https://cloud.tuist.io/"}},"openapi":"3.0.0","paths":{"/api/analytics":{"post":{"callbacks":{},"operationId":"createCommandEvent","parameters":[{"description":"The project id.","in":"query","name":"project_id","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"client_id":{"description":"The client id of the command.","type":"string"},"command_arguments":{"description":"The arguments of the command.","items":{"type":"string"},"type":"array"},"duration":{"description":"The duration of the command.","type":"number"},"error_message":{"description":"The error message of the command.","type":"string"},"git_commit_sha":{"description":"The commit SHA.","type":"string"},"git_ref":{"description":"The git ref. When on CI, the value can be equal to remote reference such as `refs/pull/1234/merge`.","type":"string"},"git_remote_url_origin":{"description":"The git remote URL origin.","type":"string"},"is_ci":{"description":"Whether the command was run in a CI environment.","type":"boolean"},"macos_version":{"description":"The version of macOS that ran the command.","type":"string"},"name":{"description":"The name of the command.","type":"string"},"params":{"description":"Extra parameters.","properties":{"cacheable_targets":{"description":"A list of cacheable targets.","items":{"type":"string"},"type":"array"},"local_cache_target_hits":{"description":"A list of local cache target hits.","items":{"type":"string"},"type":"array"},"local_test_target_hits":{"description":"A list of local targets whose tests were skipped.","items":{"type":"string"},"type":"array"},"remote_cache_target_hits":{"description":"A list of remote cache target hits.","items":{"type":"string"},"type":"array"},"remote_test_target_hits":{"description":"A list of remote targets whose tests were skipped.","items":{"type":"string"},"type":"array"},"test_targets":{"description":"The list of targets that were tested.","items":{"type":"string"},"type":"array"}},"type":"object"},"preview_id":{"description":"The preview identifier.","type":"string"},"status":{"description":"The status of the command.","enum":["success","failure"],"type":"string"},"subcommand":{"description":"The subcommand of the command.","type":"string"},"swift_version":{"description":"The version of Swift that ran the command.","type":"string"},"tuist_version":{"description":"The version of Tuist that ran the command.","type":"string"}},"required":["name","duration","tuist_version","swift_version","macos_version","is_ci","client_id"],"type":"object"}}},"description":"Command event params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommandEvent"}}},"description":"The command event was created"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You don't have permission to create command events for the project."}},"summary":"Create a a new command analytics event","tags":["Analytics"]}},"/api/auth":{"post":{"callbacks":{},"description":"This endpoint returns API tokens for a given email and password.","operationId":"authenticate","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"properties":{"email":{"description":"The email to authenticate with.","type":"string"},"password":{"description":"The password to authenticate with.","type":"string"}},"required":["email","password"],"type":"object"}}},"description":"Authentication params.","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationTokens"}}},"description":"Successfully authenticated and returned new API tokens."},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"Invalid email or password."}},"summary":"Authenticate with email and password.","tags":["Authentication"]}},"/api/auth/device_code/{device_code}":{"get":{"callbacks":{},"description":"This endpoint returns a token for a given device code if the device code is authenticated.","operationId":"getDeviceCode","parameters":[{"description":"The device code to query.","in":"path","name":"device_code","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"description":"Token to authenticate the user with.","properties":{"access_token":{"description":"A short-lived token to authenticate API requests as user.","type":"string"},"refresh_token":{"description":"A token to generate new access tokens when they expire.","type":"string"},"token":{"deprecated":true,"description":"User authentication token","type":"string"}},"title":"DeviceCodeAuthenticationTokens","type":"object"}}},"description":"The device code is authenticated"},"202":{"content":{"application/json":{"schema":{"type":"object"}}},"description":"The device code is not authenticated"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The request was not accepted, e.g., when the device code is expired"}},"summary":"Get a specific device code.","tags":["Authentication"]}},"/api/auth/refresh_token":{"post":{"callbacks":{},"description":"This endpoint returns new tokens for a given refresh token if the refresh token is valid.","operationId":"refreshToken","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"properties":{"refresh_token":{"description":"User refresh token","type":"string"}},"required":["refresh_token"],"type":"object"}}},"description":"Token params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthenticationTokens"}}},"description":"Succcessfully generated new API tokens."},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to issue new tokens"}},"summary":"Request new tokens.","tags":["Authentication"]}},"/api/cache":{"get":{"callbacks":{},"description":"This endpoint returns a signed URL that can be used to download an artifact from the cache.","operationId":"downloadCacheArtifact","parameters":[{"description":"The category of the cache. It's used to differentiate between different types of caches.","in":"query","name":"cache_category","required":false,"schema":{"$ref":"#/components/schemas/CacheCategory"}},{"description":"The project identifier '{account_name}/{project_name}'.","in":"query","name":"project_id","required":true,"schema":{"type":"string"}},{"description":"The hash that uniquely identifies the artifact in the cache.","in":"query","name":"hash","required":true,"schema":{"type":"string"}},{"description":"The name of the artifact.","in":"query","name":"name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CacheArtifactDownloadURL"}}},"description":"The artifact exists and is downloadable"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The account has an invalid plan"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project or the cache artifact doesn't exist"}},"summary":"Downloads an artifact from the cache.","tags":["Cache"]}},"/api/cache/exists":{"get":{"callbacks":{},"deprecated":true,"description":"This endpoint checks if an artifact exists in the cache. It returns a 404 status code if the artifact does not exist.","operationId":"cacheArtifactExists","parameters":[{"description":"The category of the cache. It's used to differentiate between different types of caches.","in":"query","name":"cache_category","required":false,"schema":{"$ref":"#/components/schemas/CacheCategory"}},{"description":"The project identifier '{account_name}/{project_name}'.","in":"query","name":"project_id","required":true,"schema":{"type":"string"}},{"description":"The hash that uniquely identifies the artifact in the cache.","in":"query","name":"hash","required":true,"schema":{"type":"string"}},{"description":"The name of the artifact.","in":"query","name":"name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"description":"The artifact exists in the cache and can be downloaded","properties":{"data":{"properties":{},"type":"object"},"status":{"default":"success","enum":["success"],"type":"string"}},"title":"CacheArtifactExistence","type":"object"}}},"description":"The artifact exists"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The account has an invalid plan"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"properties":{"error":{"items":{"properties":{"code":{"default":"not_found","type":"string"},"message":{"type":"string"}},"type":"object"},"type":"array"}},"title":"AbsentCacheArtifact","type":"object"}}},"description":"The artifact doesn't exist"}},"summary":"It checks if an artifact exists in the cache.","tags":["Cache"]}},"/api/cache/multipart/complete":{"post":{"callbacks":{},"description":"Given the upload ID and all the parts with their ETags, this endpoint completes the multipart upload. The cache will then be able to serve the artifact.","operationId":"completeCacheArtifactMultipartUpload","parameters":[{"description":"The category of the cache. It's used to differentiate between different types of caches.","in":"query","name":"cache_category","required":false,"schema":{"$ref":"#/components/schemas/CacheCategory"}},{"description":"The project identifier '{account_name}/{project_name}'.","in":"query","name":"project_id","required":true,"schema":{"type":"string"}},{"description":"The hash that uniquely identifies the artifact in the cache.","in":"query","name":"hash","required":true,"schema":{"type":"string"}},{"description":"The upload ID.","in":"query","name":"upload_id","required":true,"schema":{"type":"string"}},{"description":"The name of the artifact.","in":"query","name":"name","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"parts":{"items":{"properties":{"etag":{"description":"The ETag of the part","type":"string"},"part_number":{"description":"The part number","type":"integer"}},"type":"object"},"type":"array"}},"type":"object"}}},"description":"Multi-part upload parts","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"description":"This response confirms that the upload has been completed successfully. The cache will now be able to serve the artifact.","properties":{"data":{"properties":{},"type":"object"},"status":{"default":"success","enum":["success"],"type":"string"}},"title":"CacheArtifactMultipartUploadCompletion","type":"object"}}},"description":"The upload has been completed"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The account has an invalid plan"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project doesn't exist"}},"summary":"It completes a multi-part upload.","tags":["Cache"]}},"/api/cache/multipart/generate-url":{"post":{"callbacks":{},"description":"Given an upload ID and a part number, this endpoint returns a signed URL that can be used to upload a part of a multipart upload. The URL is short-lived and expires in 120 seconds.","operationId":"generateCacheArtifactMultipartUploadURL","parameters":[{"description":"The category of the cache. It's used to differentiate between different types of caches.","in":"query","name":"cache_category","required":false,"schema":{"$ref":"#/components/schemas/CacheCategory"}},{"description":"The size in bytes of the part that will be uploaded. It's used to generate the signed URL.","in":"query","name":"content_length","required":false,"schema":{"type":"integer"}},{"description":"The project identifier '{account_name}/{project_name}'.","in":"query","name":"project_id","required":true,"schema":{"type":"string"}},{"description":"The hash that uniquely identifies the artifact in the cache.","in":"query","name":"hash","required":true,"schema":{"type":"string"}},{"description":"The part number of the multipart upload.","in":"query","name":"part_number","required":true,"schema":{"type":"integer"}},{"description":"The upload ID.","in":"query","name":"upload_id","required":true,"schema":{"type":"string"}},{"description":"The name of the artifact.","in":"query","name":"name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ArtifactMultipartUploadURL"}}},"description":"The URL has been generated"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The account has an invalid plan"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project doesn't exist"}},"summary":"It generates a signed URL for uploading a part.","tags":["Cache"]}},"/api/cache/multipart/start":{"post":{"callbacks":{},"description":"The endpoint returns an upload ID that can be used to generate URLs for the individual parts and complete the upload.","operationId":"startCacheArtifactMultipartUpload","parameters":[{"description":"The category of the cache. It's used to differentiate between different types of caches.","in":"query","name":"cache_category","required":false,"schema":{"$ref":"#/components/schemas/CacheCategory"}},{"description":"The project identifier '{account_name}/{project_name}'.","in":"query","name":"project_id","required":true,"schema":{"type":"string"}},{"description":"The hash that uniquely identifies the artifact in the cache.","in":"query","name":"hash","required":true,"schema":{"type":"string"}},{"description":"The name of the artifact.","in":"query","name":"name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ArtifactUploadID"}}},"description":"The upload has been started"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The account has an invalid plan"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project doesn't exist"}},"summary":"It initiates a multipart upload in the cache.","tags":["Cache"]}},"/api/organizations":{"get":{"callbacks":{},"description":"Returns all the organizations the authenticated subject is part of.","operationId":"listOrganizations","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"description":"The list of organizations the authenticated subject is part of.","properties":{"organizations":{"items":{"$ref":"#/components/schemas/Organization"},"type":"array"}},"required":["organizations"],"title":"OrganizationList","type":"object"}}},"description":"The list of organizations"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"}},"summary":"Lists the organizations","tags":["Organizations"]},"post":{"callbacks":{},"description":"Creates an organization with the given name.","operationId":"createOrganization","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"properties":{"name":{"description":"The name of the organization that should be created.","type":"string"}},"required":["name"],"type":"object"}}},"description":"Organization params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Organization"}}},"description":"The organization was created"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization could not be created due to a validation error"}},"summary":"Creates an organization","tags":["Organizations"]}},"/api/organizations/{organization_name}":{"delete":{"callbacks":{},"description":"Deletes the organization with the given name.","operationId":"deleteOrganization","parameters":[{"description":"The name of the organization to delete.","in":"path","name":"organization_name","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"The organization was deleted"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization with the given name was not found"}},"summary":"Deletes an organization","tags":["Organizations"]},"get":{"callbacks":{},"description":"Returns the organization with the given identifier.","operationId":"showOrganization","parameters":[{"description":"The name of the organization to show.","in":"path","name":"organization_name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Organization"}}},"description":"The organization"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization with the given name was not found"}},"summary":"Shows an organization","tags":["Organizations"]},"patch":{"callbacks":{},"description":"Updates an organization with given parameters.","operationId":"updateOrganization (2)","parameters":[{"description":"The name of the organization to update.","in":"path","name":"organization_name","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"sso_organization_id":{"description":"The SSO organization ID to be associated with the SSO provider","nullable":true,"type":"string"},"sso_provider":{"description":"The SSO provider to set up for the organization","enum":["google","none"],"type":"string"}},"type":"object"}}},"description":"Organization update params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Organization"}}},"description":"The organization"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization could not be updated due to a validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization with the given name was not found"}},"summary":"Updates an organization","tags":["Organizations"]},"put":{"callbacks":{},"description":"Updates an organization with given parameters.","operationId":"updateOrganization","parameters":[{"description":"The name of the organization to update.","in":"path","name":"organization_name","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"sso_organization_id":{"description":"The SSO organization ID to be associated with the SSO provider","nullable":true,"type":"string"},"sso_provider":{"description":"The SSO provider to set up for the organization","enum":["google","none"],"type":"string"}},"type":"object"}}},"description":"Organization update params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Organization"}}},"description":"The organization"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization could not be updated due to a validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization with the given name was not found"}},"summary":"Updates an organization","tags":["Organizations"]}},"/api/organizations/{organization_name}/invitations":{"delete":{"callbacks":{},"description":"Cancels an invitation for a given invitee email and an organization.","operationId":"cancelInvitation","parameters":[{"description":"The name of the organization.","in":"path","name":"organization_name","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"invitee_email":{"description":"The email of the invitee.","type":"string"}},"required":["invitee_email"],"type":"object"}}},"description":"Invitation params","required":false},"responses":{"204":{"content":{"application/json":{}},"description":"The invitation was cancelled"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The invitation with the given invitee email and organization name was not found"}},"summary":"Cancels an invitation","tags":["Invitations"]},"post":{"callbacks":{},"description":"Invites a user with a given email to a given organization.","operationId":"createInvitation","parameters":[{"description":"The name of the organization.","in":"path","name":"organization_name","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"invitee_email":{"description":"The email of the invitee.","type":"string"}},"required":["invitee_email"],"type":"object"}}},"description":"Invitation params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Invitation"}}},"description":"The user was invited"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The user could not be invited due to a validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization was not found"}},"summary":"Creates an invitation","tags":["Invitations"]}},"/api/organizations/{organization_name}/members/{user_name}":{"delete":{"callbacks":{},"description":"Removes a member with a given username from a given organization","operationId":"removeOrganizationMember","parameters":[{"description":"The name of the organization to remove the member from.","in":"path","name":"organization_name","required":true,"schema":{"type":"string"}},{"description":"The name of the user to remove from the organization.","in":"path","name":"user_name","required":true,"schema":{"type":"string"}}],"responses":{"204":{"content":{"application/json":{}},"description":"The member was removed"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The member could not be removed due to a validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization or the user with the given name was not found"}},"summary":"Removes a member from an organization","tags":["Organizations"]},"put":{"callbacks":{},"description":"Updates a member in a given organization","operationId":"updateOrganizationMember","parameters":[{"description":"The name of the organization to update the member in.","in":"path","name":"organization_name","required":true,"schema":{"type":"string"}},{"description":"The name of the user to update in the organization.","in":"path","name":"user_name","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"role":{"description":"The role to update the member to","enum":["admin","user"],"type":"string"}},"required":["role"],"type":"object"}}},"description":"Member update params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrganizationMember"}}},"description":"The member was updated"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The member could not be updated due to a validation error"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization or the user with the given name was not found"}},"summary":"Updates a member in an organization","tags":["Organizations"]}},"/api/organizations/{organization_name}/usage":{"get":{"callbacks":{},"description":"Returns the usage of the organization with the given identifier. (e.g. number of remote cache hits)","operationId":"showOrganizationUsage","parameters":[{"description":"The name of the organization to show.","in":"path","name":"organization_name","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/OrganizationUsage"}}},"description":"The organization usage"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The organization with the given name was not found"}},"summary":"Shows the usage of an organization","tags":["Organizations"]}},"/api/projects":{"get":{"callbacks":{},"operationId":"listProjects","parameters":[],"responses":{"200":{"content":{"application/json":{"schema":{"properties":{"projects":{"items":{"$ref":"#/components/schemas/Project"},"type":"array"}},"required":["projects"],"type":"object"}}},"description":"List of projects"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"}},"summary":"List projects the authenticated user has access to.","tags":["Projects"]},"post":{"callbacks":{},"operationId":"createProject","parameters":[],"requestBody":{"content":{"application/json":{"schema":{"properties":{"full_handle":{"description":"The full handle of the project that should be created.","example":"tuist/tuist","type":"string"},"name":{"deprecated":true,"description":"The name of the project that should be created.","type":"string"},"organization":{"deprecated":true,"description":"Organization to create the project with. If not specified, the project will be created with the current user's personal account.","type":"string"}},"type":"object"}}},"description":"Projects params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Project"}}},"description":"The project was created"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The account was not found"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"}},"summary":"Create a new project.","tags":["Projects"]}},"/api/projects/{account_handle}/{project_handle}":{"get":{"callbacks":{},"operationId":"showProject","parameters":[{"description":"The name of the account that the project belongs to.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The name of the project to show","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Project"}}},"description":"The project to show"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project was not found"}},"summary":"Returns a project based on the handle.","tags":["Projects"]},"put":{"callbacks":{},"description":"Updates a project with given parameters.","operationId":"updateProject","parameters":[{"description":"The handle of the project's account.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The handle of the project to update.","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"default_branch":{"description":"The default branch for the project.","type":"string"},"repository_url":{"description":"The repository URL for the project.","type":"string"}},"type":"object"}}},"description":"Project update params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Project"}}},"description":"The updated project"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The request is invalid, for example when attempting to link the project to a repository the authenticated user doesn't have access to."},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project with the given account and project handles was not found"}},"summary":"Updates a project","tags":["Projects"]}},"/api/projects/{account_handle}/{project_handle}/cache/ac":{"post":{"callbacks":{},"description":"The endpoint caches a given action item without uploading a file. To upload files, use the multipart upload instead.","operationId":"uploadCacheActionItem","parameters":[{"description":"The name of the account that the project belongs to.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The name of the project to clean cache for","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"hash":{"description":"The hash of the cache action item.","type":"string"}},"title":"CacheActionItemUploadParams","type":"object"}}},"description":"Cache action item upload params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CacheActionItem"}}},"description":"The request is valid but the cache action item already exists"},"201":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CacheActionItem"}}},"description":"The action item was cached"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The request has missing or invalid parameters"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The account has an invalid plan"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project doesn't exist"}},"summary":"It uploads a given cache action item.","tags":["Cache"]}},"/api/projects/{account_handle}/{project_handle}/cache/ac/{hash}":{"get":{"callbacks":{},"description":"This endpoint gets an item from the action cache.","operationId":"getCacheActionItem","parameters":[{"description":"The name of the account that the project belongs to.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The name of the project the cache action item belongs to.","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}},{"description":"The hash that uniquely identifies an item in the action cache.","in":"path","name":"hash","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CacheActionItem"}}},"description":"The item exists in the action cache"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"402":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The account has an invalid plan"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The item doesn't exist in the actino cache"}},"summary":"Get a cache action item.","tags":["Cache"]}},"/api/projects/{account_handle}/{project_handle}/cache/clean":{"put":{"callbacks":{},"operationId":"cleanCache","parameters":[{"description":"The name of the account that the project belongs to.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The name of the project to clean cache for","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"The cache has been successfully cleaned"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project was not found"}},"summary":"Cleans cache for a given project","tags":["Cache"]}},"/api/projects/{account_handle}/{project_handle}/previews/complete":{"post":{"callbacks":{},"description":"Given the upload ID and all the parts with their ETags, this endpoint completes the multipart upload.","operationId":"completePreviewsMultipartUpload","parameters":[{"description":"The handle of the account.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The handle of the project.","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"description":"The request body to complete the multipart upload of a preview.","properties":{"multipart_upload_parts":{"$ref":"#/components/schemas/ArtifactMultipartUploadParts"},"preview_id":{"description":"The id of the preview.","type":"string"}},"required":["multipart_upload_parts","preview_id"],"type":"object"}}},"description":"preview multipart upload completion","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"description":"The preview multipart upload has been completed","properties":{"url":{"description":"The URL to download the preview","type":"string"}},"required":["url"],"title":"PreviewUploadCompletion","type":"object"}}},"description":"The upload has been completed"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project doesn't exist"}},"summary":"It completes a multi-part upload.","tags":["Previews"]}},"/api/projects/{account_handle}/{project_handle}/previews/generate-url":{"post":{"callbacks":{},"description":"Given an upload ID and a part number, this endpoint returns a signed URL that can be used to upload a part of a multipart upload. The URL is short-lived and expires in 120 seconds.","operationId":"generatePreviewsMultipartUploadURL","parameters":[{"description":"The handle of the account.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The handle of the project.","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"multipart_upload_part":{"$ref":"#/components/schemas/ArtifactMultipartUploadPart"},"preview_id":{"description":"The id of the preview.","type":"string"}},"required":["multipart_upload_part","preview_id"],"type":"object"}}},"description":"Artifact to generate a signed URL for","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ArtifactMultipartUploadURL"}}},"description":"The URL has been generated"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project doesn't exist"}},"summary":"It generates a signed URL for uploading a part.","tags":["Previews"]}},"/api/projects/{account_handle}/{project_handle}/previews/start":{"post":{"callbacks":{},"description":"The endpoint returns an upload ID that can be used to generate URLs for the individual parts and complete the upload.","operationId":"startPreviewsMultipartUpload","parameters":[{"description":"The handle of the account.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The handle of the project.","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"bundle_identifier":{"description":"The bundle identifier of the preview.","type":"string"},"display_name":{"description":"The display name of the preview.","type":"string"},"type":{"default":"app_bundle","description":"The type of the preview to upload.","enum":["app_bundle","ipa"],"type":"string"},"version":{"description":"The version of the preview.","type":"string"}},"type":"object"}}},"description":"Preview upload request params","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"description":"The upload has been initiated and preview and upload unique identifier are returned to upload the various parts using multi-part uploads","properties":{"data":{"description":"Data that contains preview and upload unique identifier associated with the multipart upload to use when uploading parts","properties":{"preview_id":{"description":"The id of the preview.","type":"string"},"upload_id":{"description":"The upload ID","type":"string"}},"required":["upload_id","preview_id"],"type":"object"},"status":{"default":"success","enum":["success"],"type":"string"}},"required":["status","data"],"title":"PreviewArtifactUpload","type":"object"}}},"description":"The upload has been started"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project doesn't exist"}},"summary":"It initiates a multipart upload for a preview artifact.","tags":["Previews"]}},"/api/projects/{account_handle}/{project_handle}/previews/{preview_id}":{"get":{"callbacks":{},"description":"This endpoint returns a signed URL that can be used to download a preview.","operationId":"downloadPreview","parameters":[{"description":"The handle of the account.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The handle of the project.","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}},{"description":"The id of the preview.","in":"path","name":"preview_id","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ArtifactDownloadURL"}}},"description":"The preview exists and can be downloaded"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The build doesn't exist"}},"summary":"Downloads a preview.","tags":["Previews"]}},"/api/projects/{account_handle}/{project_handle}/tokens":{"get":{"callbacks":{},"description":"This endpoint returns all tokens for a given project.","operationId":"listProjectTokens","parameters":[{"description":"The account handle.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The project handle.","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"description":"A list of project tokens.","properties":{"tokens":{"items":{"$ref":"#/components/schemas/ProjectToken"},"type":"array"}},"required":["tokens"],"title":"Tokens","type":"object"}}},"description":"A list of project tokens."},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to list tokens"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authorized to list tokens"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project was not found"}},"summary":"List all project tokens.","tags":["Project tokens"]},"post":{"callbacks":{},"description":"This endpoint returns a new project token.","operationId":"createProjectToken","parameters":[{"description":"The account handle.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The project handle.","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}}],"responses":{"200":{"content":{"application/json":{"schema":{"description":"A new project token.","properties":{"token":{"description":"The generated project token.","type":"string"}},"required":["token"],"title":"ProjectFullToken","type":"object"}}},"description":"A project token was generated"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to issue new tokens"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authorized to issue new tokens"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project was not found"}},"summary":"Create a new project token.","tags":["Project tokens"]}},"/api/projects/{account_handle}/{project_handle}/tokens/{id}":{"delete":{"callbacks":{},"operationId":"revokeProjectToken","parameters":[{"description":"The account handle.","in":"path","name":"account_handle","required":true,"schema":{"type":"string"}},{"description":"The project handle.","in":"path","name":"project_handle","required":true,"schema":{"type":"string"}},{"description":"The ID of the project token","in":"path","name":"id","required":true,"schema":{"type":"string"}}],"responses":{"204":{"description":"The project token was revoked"},"400":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The provided token ID is not valid"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project token was not found"}},"summary":"Revokes a project token.","tags":["Project tokens"]}},"/api/projects/{id}":{"delete":{"callbacks":{},"operationId":"deleteProject","parameters":[{"description":"The id of the project to delete.","in":"path","name":"id","required":true,"schema":{"type":"integer"}}],"responses":{"204":{"description":"The project was successfully deleted."},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project was not found"}},"summary":"Deletes a project with a given id.","tags":["Projects"]}},"/api/runs/{run_id}/complete":{"post":{"callbacks":{},"description":"Given the upload ID and all the parts with their ETags, this endpoint completes the multipart upload.","operationId":"completeAnalyticsArtifactMultipartUpload","parameters":[{"description":"The id of the command event.","in":"path","name":"run_id","required":true,"schema":{"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"command_event_artifact":{"$ref":"#/components/schemas/CommandEventArtifact"},"multipart_upload_parts":{"$ref":"#/components/schemas/ArtifactMultipartUploadParts"}},"required":["command_event_artifact","multipart_upload_parts"],"type":"object"}}},"description":"Command event artifact multipart upload completion","required":false},"responses":{"204":{"description":"The upload has been completed"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project doesn't exist"},"500":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"An internal server error occurred"}},"summary":"It completes a multi-part upload.","tags":["Analytics"]}},"/api/runs/{run_id}/complete_artifacts_uploads":{"put":{"callbacks":{},"description":"Given a command event, it marks all artifact uploads as finished and does extra processing of a given command run, such as test flakiness detection.","operationId":"completeAnalyticsArtifactsUploads","parameters":[{"description":"The id of the command event.","in":"path","name":"run_id","required":true,"schema":{"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"modules":{"description":"A list of modules with their metadata.","items":{"$ref":"#/components/schemas/Module"},"type":"array"}},"required":["modules"],"type":"object"}}},"description":"Extra metadata for the post-processing of a command event.","required":false},"responses":{"204":{"description":"The command event artifact uploads were successfully finished"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The command event doesn't exist"}},"summary":"Completes artifacts uploads for a given command event","tags":["Analytics"]}},"/api/runs/{run_id}/generate-url":{"post":{"callbacks":{},"description":"Given an upload ID and a part number, this endpoint returns a signed URL that can be used to upload a part of a multipart upload. The URL is short-lived and expires in 120 seconds.","operationId":"generateAnalyticsArtifactMultipartUploadURL","parameters":[{"description":"The id of the command event.","in":"path","name":"run_id","required":true,"schema":{"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"properties":{"command_event_artifact":{"$ref":"#/components/schemas/CommandEventArtifact"},"multipart_upload_part":{"$ref":"#/components/schemas/ArtifactMultipartUploadPart"}},"required":["command_event_artifact","multipart_upload_part"],"type":"object"}}},"description":"Artifact to generate a signed URL for","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ArtifactMultipartUploadURL"}}},"description":"The URL has been generated"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The project doesn't exist"}},"summary":"It generates a signed URL for uploading a part.","tags":["Analytics"]}},"/api/runs/{run_id}/start":{"post":{"callbacks":{},"description":"The endpoint returns an upload ID that can be used to generate URLs for the individual parts and complete the upload.","operationId":"startAnalyticsArtifactMultipartUpload","parameters":[{"description":"The id of the command event.","in":"path","name":"run_id","required":true,"schema":{"type":"integer"}}],"requestBody":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/CommandEventArtifact"}}},"description":"Artifact to upload","required":false},"responses":{"200":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/ArtifactUploadID"}}},"description":"The upload has been started"},"401":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"You need to be authenticated to access this resource"},"403":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The authenticated subject is not authorized to perform this action"},"404":{"content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}},"description":"The command event doesn't exist"}},"summary":"It initiates a multipart upload for a command event artifact.","tags":["Analytics"]}}},"security":[{"authorization":[]},{"cookie":[]}],"servers":[{"url":"https://cloud.tuist.io","variables":{}}],"tags":[]} \ No newline at end of file +{ + "components": { + "responses": {}, + "schemas": { + "User": { + "description": "A user.", + "properties": { + "email": { + "description": "The user's email", + "type": "string" + }, + "id": { + "description": "The user's unique identifier", + "type": "number" + }, + "name": { + "description": "The user's name", + "type": "string" + } + }, + "required": [ + "id", + "email", + "name" + ], + "title": "User", + "type": "object" + }, + "PreviewIndexPageSize": { + "default": 10, + "description": "The maximum number of preview to return in a single page.", + "maximum": 20, + "minimum": 1, + "title": "PreviewIndexPageSize", + "type": "integer" + }, + "CreateAccountToken": { + "description": "The request to create a new account token.", + "properties": { + "scopes": { + "description": "The scopes for the new account token.", + "items": { + "description": "The scope of the token.", + "enum": [ + "account_registry_read" + ], + "title": "AccountTokenScope", + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "scopes" + ], + "title": "CreateAccountToken", + "type": "object" + }, + "AuthenticationTokens": { + "description": "A pair of access token to authenticate requests and refresh token to generate new access tokens when they expire.", + "properties": { + "access_token": { + "description": "API access token.", + "type": "string" + }, + "refresh_token": { + "description": "A token to generate new API access tokens when they expire.", + "type": "string" + } + }, + "required": [ + "access_token", + "refresh_token" + ], + "title": "AuthenticationTokens", + "type": "object" + }, + "CacheArtifactMultipartUploadCompletion": { + "description": "This response confirms that the upload has been completed successfully. The cache will now be able to serve the artifact.", + "properties": { + "data": { + "properties": {}, + "type": "object" + }, + "status": { + "default": "success", + "enum": [ + "success" + ], + "type": "string" + } + }, + "title": "CacheArtifactMultipartUploadCompletion", + "type": "object" + }, + "ArtifactMultipartUploadURL": { + "description": "The URL to upload a multipart part", + "properties": { + "data": { + "properties": { + "url": { + "description": "The URL to upload the part", + "type": "string" + } + }, + "required": [ + "url" + ], + "type": "object" + }, + "status": { + "default": "success", + "enum": [ + "success" + ], + "type": "string" + } + }, + "required": [ + "status", + "data" + ], + "title": "ArtifactMultipartUploadURL", + "type": "object" + }, + "CacheArtifactExistence": { + "description": "The artifact exists in the cache and can be downloaded", + "properties": { + "data": { + "properties": {}, + "type": "object" + }, + "status": { + "default": "success", + "enum": [ + "success" + ], + "type": "string" + } + }, + "title": "CacheArtifactExistence", + "type": "object" + }, + "Run": { + "description": "The schema for a Tuist run.", + "properties": { + "cacheable_targets": { + "description": "Cacheable targets of the run", + "items": { + "type": "string" + }, + "type": "array" + }, + "command_arguments": { + "description": "Arguments passed to the command", + "items": { + "type": "string" + }, + "type": "array" + }, + "duration": { + "description": "Duration of the run", + "type": "number" + }, + "git_branch": { + "description": "Git branch of the repository", + "type": "string" + }, + "git_commit_sha": { + "description": "Git commit SHA of the repository", + "type": "string" + }, + "git_ref": { + "description": "Git reference of the repository. When run from CI in a pull request, this will be the remote reference to the pull request, such as `refs/pull/23958/merge`.", + "type": "string" + }, + "id": { + "description": "ID of the run", + "type": "number" + }, + "local_cache_target_hits": { + "description": "Local cache target hits of the run", + "items": { + "type": "string" + }, + "type": "array" + }, + "local_test_target_hits": { + "description": "Local test target hits of the run", + "items": { + "type": "string" + }, + "type": "array" + }, + "macos_version": { + "description": "Version of macOS used", + "type": "string" + }, + "name": { + "description": "Command name of the run", + "type": "string" + }, + "preview_id": { + "description": "ID of the associated preview", + "type": "string" + }, + "remote_cache_target_hits": { + "description": "Remote cache target hits of the run", + "items": { + "type": "string" + }, + "type": "array" + }, + "remote_test_target_hits": { + "description": "Remote test target hits of the run", + "items": { + "type": "string" + }, + "type": "array" + }, + "status": { + "description": "Status of the command event", + "type": "string" + }, + "subcommand": { + "description": "Subcommand of the run", + "type": "string" + }, + "swift_version": { + "description": "Version of Swift used", + "type": "string" + }, + "test_targets": { + "description": "Test targets of the run", + "items": { + "type": "string" + }, + "type": "array" + }, + "tuist_version": { + "description": "Version of Tuist used", + "type": "string" + }, + "url": { + "description": "URL to the run", + "type": "string" + } + }, + "required": [ + "id", + "name", + "duration", + "subcommand", + "command_arguments", + "tuist_version", + "swift_version", + "macos_version", + "status", + "git_commit_sha", + "git_ref", + "git_branch", + "url" + ], + "title": "Run", + "type": "object" + }, + "RunsIndexPage": { + "default": 1, + "description": "The page number to return.", + "minimum": 1, + "title": "RunsIndexPage", + "type": "integer" + }, + "AccountToken": { + "description": "A new account token.", + "properties": { + "token": { + "description": "The generated account token.", + "type": "string" + } + }, + "required": [ + "token" + ], + "title": "AccountToken", + "type": "object" + }, + "Error": { + "properties": { + "message": { + "description": "The error message", + "type": "string" + } + }, + "required": [ + "message" + ], + "title": "Error", + "type": "object" + }, + "AbsentCacheArtifact": { + "properties": { + "error": { + "items": { + "properties": { + "code": { + "default": "not_found", + "type": "string" + }, + "message": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "title": "AbsentCacheArtifact", + "type": "object" + }, + "DeviceCodeAuthenticationTokens": { + "description": "Token to authenticate the user with.", + "properties": { + "access_token": { + "description": "A short-lived token to authenticate API requests as user.", + "type": "string" + }, + "refresh_token": { + "description": "A token to generate new access tokens when they expire.", + "type": "string" + }, + "token": { + "deprecated": true, + "description": "User authentication token", + "type": "string" + } + }, + "title": "DeviceCodeAuthenticationTokens", + "type": "object" + }, + "ArtifactUploadURL": { + "description": "The URL to upload an artifact.", + "properties": { + "expires_at": { + "description": "The UNIX timestamp when the URL expires.", + "type": "integer" + }, + "url": { + "description": "The URL to upload the artifact.", + "type": "string" + } + }, + "required": [ + "url", + "expires_at" + ], + "title": "ArtifactUploadURL", + "type": "object" + }, + "PreviewsIndex": { + "properties": { + "previews": { + "description": "Previews list.", + "items": { + "$ref": "#/components/schemas/Preview" + }, + "type": "array" + } + }, + "required": [ + "previews" + ], + "title": "PreviewsIndex", + "type": "object" + }, + "OrganizationUsage": { + "description": "The usage of an organization.", + "properties": { + "current_month_remote_cache_hits": { + "description": "The number of remote cache hits in the current month", + "type": "number" + } + }, + "required": [ + "current_month_remote_cache_hits" + ], + "title": "OrganizationUsage", + "type": "object" + }, + "AccountTokenScope": { + "description": "The scope of the token.", + "enum": [ + "account_registry_read" + ], + "title": "AccountTokenScope", + "type": "string" + }, + "ProjectToken": { + "description": "A token to authenticate API requests as a project.", + "properties": { + "id": { + "description": "The token unique identifier.", + "type": "string" + }, + "inserted_at": { + "description": "The timestamp of when the token was created.", + "format": "date-time", + "type": "string" + } + }, + "required": [ + "id", + "inserted_at" + ], + "title": "ProjectToken", + "type": "object" + }, + "RunsIndexPageSize": { + "default": 20, + "description": "The maximum number of runs to return in a single page.", + "maximum": 100, + "minimum": 1, + "title": "RunsIndexPageSize", + "type": "integer" + }, + "Preview": { + "properties": { + "bundle_identifier": { + "description": "The bundle identifier of the preview", + "type": "string" + }, + "display_name": { + "description": "The display name of the preview", + "type": "string" + }, + "git_branch": { + "description": "The git branch associated with the preview", + "type": "string" + }, + "git_commit_sha": { + "description": "The git commit SHA associated with the preview", + "type": "string" + }, + "icon_url": { + "description": "The URL for the icon image of the preview", + "type": "string" + }, + "id": { + "description": "Unique identifier of the preview.", + "type": "string" + }, + "qr_code_url": { + "description": "The URL for the QR code image to dowload the preview", + "type": "string" + }, + "url": { + "description": "The URL to download the preview", + "type": "string" + } + }, + "required": [ + "id", + "url", + "qr_code_url", + "icon_url" + ], + "title": "Preview", + "type": "object" + }, + "Module": { + "properties": { + "hash": { + "description": "A hash that represents the module.", + "type": "string" + }, + "name": { + "description": "A name of the module", + "type": "string" + }, + "project_identifier": { + "description": "Project's relative path from the root of the repository", + "type": "string" + } + }, + "required": [ + "name", + "project_identifier", + "hash" + ], + "title": "Module", + "type": "object" + }, + "CommandEventArtifact": { + "description": "It represents an artifact that's associated with a command event (e.g. result bundles)", + "properties": { + "name": { + "description": "The name of the file. It's used only for certain types such as result_bundle_object", + "type": "string" + }, + "type": { + "description": "The command event artifact type. It can be:\n- result_bundle: A result bundle artifact that represents the whole `.xcresult` bundle\n- invocation_record: An invocation record artifact. This is a root bundle object of the result bundle\n- result_bundle_object: A result bundle object. There are many different bundle objects per result bundle.\n", + "enum": [ + "result_bundle", + "invocation_record", + "result_bundle_object" + ], + "type": "string" + } + }, + "required": [ + "type" + ], + "title": "CommandEventArtifact", + "type": "object" + }, + "PreviewSupportedPlatform": { + "enum": [ + "ios", + "ios_simulator", + "tvos", + "tvos_simulator", + "watchos", + "watchos_simulator", + "visionos", + "visionos_simulator", + "macos" + ], + "title": "PreviewSupportedPlatform", + "type": "string" + }, + "Organization": { + "description": "An organization", + "properties": { + "id": { + "description": "The organization's unique identifier", + "type": "number" + }, + "invitations": { + "description": "A list of organization invitations", + "items": { + "$ref": "#/components/schemas/Invitation" + }, + "type": "array" + }, + "members": { + "description": "A list of organization members", + "items": { + "$ref": "#/components/schemas/OrganizationMember" + }, + "type": "array" + }, + "name": { + "description": "The organization's name", + "type": "string" + }, + "plan": { + "description": "The plan associated with the organization", + "enum": [ + "air", + "pro", + "enterprise", + "none" + ], + "type": "string" + }, + "sso_organization_id": { + "description": "The organization ID associated with the SSO provider", + "type": "string" + }, + "sso_provider": { + "description": "The SSO provider set up for the organization", + "enum": [ + "google", + "okta" + ], + "type": "string" + } + }, + "required": [ + "id", + "name", + "plan", + "members", + "invitations" + ], + "title": "Organization", + "type": "object" + }, + "OrganizationMember": { + "description": "An organization member", + "properties": { + "email": { + "description": "The organization member's email", + "type": "string" + }, + "id": { + "description": "The organization member's unique identifier", + "type": "number" + }, + "name": { + "description": "The organization member's name", + "type": "string" + }, + "role": { + "description": "The organization member's role", + "enum": [ + "admin", + "user" + ], + "type": "string" + } + }, + "required": [ + "id", + "email", + "name", + "role" + ], + "title": "OrganizationMember", + "type": "object" + }, + "Account": { + "properties": { + "handle": { + "description": "The handle of the account", + "type": "string" + }, + "id": { + "description": "ID of the account", + "type": "number" + } + }, + "required": [ + "id", + "handle" + ], + "title": "Account", + "type": "object" + }, + "PreviewIndexPage": { + "default": 1, + "description": "The page number to return.", + "minimum": 1, + "title": "PreviewIndexPage", + "type": "integer" + }, + "Invitation": { + "properties": { + "id": { + "description": "The invitation's unique identifier", + "type": "number" + }, + "invitee_email": { + "description": "The email of the invitee", + "type": "string" + }, + "inviter": { + "$ref": "#/components/schemas/User" + }, + "organization_id": { + "description": "The id of the organization the invitee is invited to", + "type": "number" + }, + "token": { + "description": "The token to accept the invitation", + "type": "string" + } + }, + "required": [ + "id", + "invitee_email", + "organization_id", + "inviter", + "token" + ], + "title": "Invitation", + "type": "object" + }, + "Project": { + "properties": { + "default_branch": { + "description": "The default branch of the project.", + "example": "main", + "type": "string" + }, + "full_name": { + "description": "The full name of the project (e.g. tuist/tuist)", + "type": "string" + }, + "id": { + "description": "ID of the project", + "type": "number" + }, + "repository_url": { + "description": "The URL of the connected git repository, such as https://github.com/tuist/tuist or https://github.com/tuist/tuist.git", + "type": "string" + }, + "token": { + "deprecated": true, + "description": "The token that should be used to authenticate the project. For CI only.", + "type": "string" + }, + "visibility": { + "description": "The visibility of the project", + "enum": [ + "private", + "public" + ], + "type": "string" + } + }, + "required": [ + "id", + "full_name", + "token", + "default_branch", + "visibility" + ], + "title": "Project", + "type": "object" + }, + "PreviewArtifactUpload": { + "description": "The upload has been initiated and preview and upload unique identifier are returned to upload the various parts using multi-part uploads", + "properties": { + "data": { + "description": "Data that contains preview and upload unique identifier associated with the multipart upload to use when uploading parts", + "properties": { + "preview_id": { + "description": "The id of the preview.", + "type": "string" + }, + "upload_id": { + "description": "The upload ID", + "type": "string" + } + }, + "required": [ + "upload_id", + "preview_id" + ], + "type": "object" + }, + "status": { + "default": "success", + "enum": [ + "success" + ], + "type": "string" + } + }, + "required": [ + "status", + "data" + ], + "title": "PreviewArtifactUpload", + "type": "object" + }, + "ProjectFullToken": { + "description": "A new project token.", + "properties": { + "token": { + "description": "The generated project token.", + "type": "string" + } + }, + "required": [ + "token" + ], + "title": "ProjectFullToken", + "type": "object" + }, + "ArtifactMultipartUploadPart": { + "description": "Represents an multipart upload's part identified by the upload id and the part number", + "properties": { + "content_length": { + "description": "The content length of the part.", + "type": "integer" + }, + "part_number": { + "description": "The part number of the multipart upload.", + "type": "integer" + }, + "upload_id": { + "description": "The upload ID.", + "type": "string" + } + }, + "required": [ + "part_number", + "upload_id" + ], + "title": "ArtifactMultipartUploadPart", + "type": "object" + }, + "CacheActionItemUploadParams": { + "properties": { + "hash": { + "description": "The hash of the cache action item.", + "type": "string" + } + }, + "title": "CacheActionItemUploadParams", + "type": "object" + }, + "CommandEvent": { + "description": "The schema for the command analytics event.", + "properties": { + "id": { + "description": "ID of the command event", + "type": "number" + }, + "name": { + "description": "Name of the command", + "type": "string" + }, + "url": { + "description": "URL to the command event", + "type": "string" + } + }, + "required": [ + "id", + "name", + "url" + ], + "title": "CommandEvent", + "type": "object" + }, + "ArtifactMultipartUploadParts": { + "description": "It represents a part that has been uploaded using multipart uploads. The part is identified by its number and the etag", + "properties": { + "parts": { + "items": { + "properties": { + "etag": { + "description": "The ETag of the part", + "type": "string" + }, + "part_number": { + "description": "The part number", + "type": "integer" + } + }, + "required": [ + "part_number", + "etag" + ], + "type": "object" + }, + "type": "array" + }, + "upload_id": { + "description": "The upload ID", + "type": "string" + } + }, + "required": [ + "upload_id", + "parts" + ], + "title": "ArtifactMultipartUploadParts", + "type": "object" + }, + "Tokens": { + "description": "A list of project tokens.", + "properties": { + "tokens": { + "items": { + "$ref": "#/components/schemas/ProjectToken" + }, + "type": "array" + } + }, + "required": [ + "tokens" + ], + "title": "Tokens", + "type": "object" + }, + "CacheArtifactDownloadURL": { + "description": "The URL to download the artifact from the cache.", + "properties": { + "data": { + "properties": { + "expires_at": { + "description": "The UNIX timestamp when the URL expires.", + "type": "integer" + }, + "url": { + "description": "The URL to download the artifact from the cache.", + "type": "string" + } + }, + "required": [ + "url", + "expires_at" + ], + "type": "object" + }, + "status": { + "default": "success", + "enum": [ + "success" + ], + "type": "string" + } + }, + "required": [ + "status", + "data" + ], + "title": "CacheArtifactDownloadURL", + "type": "object" + }, + "CacheCategory": { + "default": "builds", + "description": "The category of the cache.", + "enum": [ + "tests", + "builds" + ], + "title": "CacheCategory", + "type": "string" + }, + "ArtifactUploadID": { + "description": "The upload has been initiated and a ID is returned to upload the various parts using multi-part uploads", + "properties": { + "data": { + "description": "Data that contains ID that's associated with the multipart upload to use when uploading parts", + "properties": { + "upload_id": { + "description": "The upload ID", + "type": "string" + } + }, + "required": [ + "upload_id" + ], + "type": "object" + }, + "status": { + "default": "success", + "enum": [ + "success" + ], + "type": "string" + } + }, + "required": [ + "status", + "data" + ], + "title": "ArtifactUploadID", + "type": "object" + }, + "OrganizationList": { + "description": "The list of organizations the authenticated subject is part of.", + "properties": { + "organizations": { + "items": { + "$ref": "#/components/schemas/Organization" + }, + "type": "array" + } + }, + "required": [ + "organizations" + ], + "title": "OrganizationList", + "type": "object" + }, + "CacheActionItem": { + "description": "Represents an action item stored in the cache.", + "properties": { + "hash": { + "description": "The hash that uniquely identifies the artifact in the cache.", + "type": "string" + } + }, + "required": [ + "hash" + ], + "title": "CacheActionItem", + "type": "object" + } + } + }, + "info": { + "title": "Tuist", + "version": "0.1.0", + "x-logo": { + "altText": "Tuist logo", + "url": "https://tuist.dev/images/open-graph/squared.png" + } + }, + "openapi": "3.0.0", + "paths": { + "/api/runs/{run_id}/complete_artifacts_uploads": { + "put": { + "callbacks": {}, + "description": "Given a command event, it marks all artifact uploads as finished and does extra processing of a given command run, such as test flakiness detection.", + "operationId": "completeAnalyticsArtifactsUploads", + "parameters": [ + { + "description": "The id of the command event.", + "in": "path", + "name": "run_id", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "modules": { + "description": "A list of modules with their metadata.", + "items": { + "$ref": "#/components/schemas/Module" + }, + "type": "array" + } + }, + "required": [ + "modules" + ], + "type": "object" + } + } + }, + "description": "Extra metadata for the post-processing of a command event.", + "required": false + }, + "responses": { + "204": { + "description": "The command event artifact uploads were successfully finished" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The command event doesn't exist" + } + }, + "summary": "Completes artifacts uploads for a given command event", + "tags": [ + "Analytics" + ] + } + }, + "/api/accounts/{account_handle}": { + "patch": { + "callbacks": {}, + "description": "Updates the given account", + "operationId": "updateAccount", + "parameters": [ + { + "description": "The handle of the account.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "handle": { + "description": "The new account handle.", + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Change account", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Account" + } + } + }, + "description": "Account successfully updated" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "An error occurred while updating the account." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to update your account." + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You don't have permission to update this account." + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "An account with this handle was not found." + } + }, + "summary": "Update account", + "tags": [ + "Account" + ] + } + }, + "/api/projects/{id}": { + "delete": { + "callbacks": {}, + "operationId": "deleteProject", + "parameters": [ + { + "description": "The id of the project to delete.", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "responses": { + "204": { + "description": "The project was successfully deleted." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project was not found" + } + }, + "summary": "Deletes a project with a given id.", + "tags": [ + "Projects" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/previews/complete": { + "post": { + "callbacks": {}, + "description": "Given the upload ID and all the parts with their ETags, this endpoint completes the multipart upload.", + "operationId": "completePreviewsMultipartUpload", + "parameters": [ + { + "description": "The handle of the account.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The handle of the project.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "description": "The request body to complete the multipart upload of a preview.", + "properties": { + "multipart_upload_parts": { + "$ref": "#/components/schemas/ArtifactMultipartUploadParts" + }, + "preview_id": { + "description": "The id of the preview.", + "type": "string" + } + }, + "required": [ + "multipart_upload_parts", + "preview_id" + ], + "type": "object" + } + } + }, + "description": "preview multipart upload completion", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Preview" + } + } + }, + "description": "The upload has been completed" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project or preview doesn't exist" + } + }, + "summary": "It completes a multi-part upload.", + "tags": [ + "Previews" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/previews/{preview_id}/icons": { + "post": { + "callbacks": {}, + "description": "The endpoint uploads a preview icon.", + "operationId": "uploadPreviewIcon", + "parameters": [ + { + "description": "The handle of the account.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The handle of the project.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The preview identifier.", + "in": "path", + "name": "preview_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactUploadURL" + } + } + }, + "description": "The presigned upload URL" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project or preview doesn't exist" + } + }, + "summary": "Uploads a preview icon.", + "tags": [ + "Previews" + ] + } + }, + "/api/organizations/{organization_name}/members/{user_name}": { + "delete": { + "callbacks": {}, + "description": "Removes a member with a given username from a given organization", + "operationId": "removeOrganizationMember", + "parameters": [ + { + "description": "The name of the organization to remove the member from.", + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the user to remove from the organization.", + "in": "path", + "name": "user_name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "content": { + "application/json": {} + }, + "description": "The member was removed" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The member could not be removed due to a validation error" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization or the user with the given name was not found" + } + }, + "summary": "Removes a member from an organization", + "tags": [ + "Organizations" + ] + }, + "put": { + "callbacks": {}, + "description": "Updates a member in a given organization", + "operationId": "updateOrganizationMember", + "parameters": [ + { + "description": "The name of the organization to update the member in.", + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the user to update in the organization.", + "in": "path", + "name": "user_name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "role": { + "description": "The role to update the member to", + "enum": [ + "admin", + "user" + ], + "type": "string" + } + }, + "required": [ + "role" + ], + "type": "object" + } + } + }, + "description": "Member update params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationMember" + } + } + }, + "description": "The member was updated" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The member could not be updated due to a validation error" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization or the user with the given name was not found" + } + }, + "summary": "Updates a member in an organization", + "tags": [ + "Organizations" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/runs": { + "get": { + "callbacks": {}, + "operationId": "listRuns", + "parameters": [ + { + "description": "The handle of the account.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The handle of the project.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the run.", + "in": "query", + "name": "name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "The git ref of the run.", + "in": "query", + "name": "git_ref", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "The git branch of the run.", + "in": "query", + "name": "git_branch", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "The git commit SHA of the run.", + "in": "query", + "name": "git_commit_sha", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "", + "in": "query", + "name": "page_size", + "required": false, + "schema": { + "default": 20, + "description": "The maximum number of runs to return in a single page.", + "maximum": 100, + "minimum": 1, + "title": "RunsIndexPageSize", + "type": "integer" + } + }, + { + "description": "", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "description": "The page number to return.", + "minimum": 1, + "title": "RunsIndexPage", + "type": "integer" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "runs": { + "items": { + "$ref": "#/components/schemas/Run" + }, + "type": "array" + } + }, + "required": [ + "runs" + ], + "type": "object" + } + } + }, + "description": "List of runs" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You don't have permission to access this resource" + } + }, + "summary": "List runs associated with a given project.", + "tags": [] + } + }, + "/api/projects/{account_handle}/{project_handle}": { + "get": { + "callbacks": {}, + "operationId": "showProject", + "parameters": [ + { + "description": "The name of the account that the project belongs to.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the project to show", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Project" + } + } + }, + "description": "The project to show" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project was not found" + } + }, + "summary": "Returns a project based on the handle.", + "tags": [ + "Projects" + ] + }, + "put": { + "callbacks": {}, + "description": "Updates a project with given parameters.", + "operationId": "updateProject", + "parameters": [ + { + "description": "The handle of the project's account.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The handle of the project to update.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "default_branch": { + "description": "The default branch for the project.", + "type": "string" + }, + "repository_url": { + "description": "The repository URL for the project.", + "type": "string" + }, + "visibility": { + "description": "The visibility of the project. Public projects are visible to everyone, private projects are only visible to the project's members.", + "enum": [ + "public", + "private" + ], + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Project update params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Project" + } + } + }, + "description": "The updated project" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request is invalid, for example when attempting to link the project to a repository the authenticated user doesn't have access to." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project with the given account and project handles was not found" + } + }, + "summary": "Updates a project", + "tags": [ + "Projects" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/tokens/{id}": { + "delete": { + "callbacks": {}, + "operationId": "revokeProjectToken", + "parameters": [ + { + "description": "The account handle.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The project handle.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The ID of the project token", + "in": "path", + "name": "id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "The project token was revoked" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The provided token ID is not valid" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project token was not found" + } + }, + "summary": "Revokes a project token.", + "tags": [ + "Project tokens" + ] + } + }, + "/api/cache/exists": { + "get": { + "callbacks": {}, + "deprecated": true, + "description": "This endpoint checks if an artifact exists in the cache. It returns a 404 status code if the artifact does not exist.", + "operationId": "cacheArtifactExists", + "parameters": [ + { + "description": "The category of the cache. It's used to differentiate between different types of caches.", + "in": "query", + "name": "cache_category", + "required": false, + "schema": { + "$ref": "#/components/schemas/CacheCategory" + } + }, + { + "description": "The project identifier '{account_name}/{project_name}'.", + "in": "query", + "name": "project_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The hash that uniquely identifies the artifact in the cache.", + "in": "query", + "name": "hash", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the artifact.", + "in": "query", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "description": "The artifact exists in the cache and can be downloaded", + "properties": { + "data": { + "properties": {}, + "type": "object" + }, + "status": { + "default": "success", + "enum": [ + "success" + ], + "type": "string" + } + }, + "title": "CacheArtifactExistence", + "type": "object" + } + } + }, + "description": "The artifact exists" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account has an invalid plan" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "properties": { + "error": { + "items": { + "properties": { + "code": { + "default": "not_found", + "type": "string" + }, + "message": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "title": "AbsentCacheArtifact", + "type": "object" + } + } + }, + "description": "The artifact doesn't exist" + } + }, + "summary": "It checks if an artifact exists in the cache.", + "tags": [ + "Cache" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/previews/{preview_id}": { + "get": { + "callbacks": {}, + "description": "This endpoint returns a preview with a given id, including the url to download the preview.", + "operationId": "downloadPreview", + "parameters": [ + { + "description": "The handle of the account.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The handle of the project.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The id of the preview.", + "in": "path", + "name": "preview_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Preview" + } + } + }, + "description": "The preview exists and can be downloaded" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The preview does not exist" + } + }, + "summary": "Returns a preview with a given id.", + "tags": [ + "Previews" + ] + } + }, + "/api/organizations": { + "get": { + "callbacks": {}, + "description": "Returns all the organizations the authenticated subject is part of.", + "operationId": "listOrganizations", + "parameters": [], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "description": "The list of organizations the authenticated subject is part of.", + "properties": { + "organizations": { + "items": { + "$ref": "#/components/schemas/Organization" + }, + "type": "array" + } + }, + "required": [ + "organizations" + ], + "title": "OrganizationList", + "type": "object" + } + } + }, + "description": "The list of organizations" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + } + }, + "summary": "Lists the organizations", + "tags": [ + "Organizations" + ] + }, + "post": { + "callbacks": {}, + "description": "Creates an organization with the given name.", + "operationId": "createOrganization", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "name": { + "description": "The name of the organization that should be created.", + "type": "string" + } + }, + "required": [ + "name" + ], + "type": "object" + } + } + }, + "description": "Organization params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Organization" + } + } + }, + "description": "The organization was created" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization could not be created due to a validation error" + } + }, + "summary": "Creates an organization", + "tags": [ + "Organizations" + ] + } + }, + "/api/runs/{run_id}/complete": { + "post": { + "callbacks": {}, + "description": "Given the upload ID and all the parts with their ETags, this endpoint completes the multipart upload.", + "operationId": "completeAnalyticsArtifactMultipartUpload", + "parameters": [ + { + "description": "The id of the command event.", + "in": "path", + "name": "run_id", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "command_event_artifact": { + "$ref": "#/components/schemas/CommandEventArtifact" + }, + "multipart_upload_parts": { + "$ref": "#/components/schemas/ArtifactMultipartUploadParts" + } + }, + "required": [ + "command_event_artifact", + "multipart_upload_parts" + ], + "type": "object" + } + } + }, + "description": "Command event artifact multipart upload completion", + "required": false + }, + "responses": { + "204": { + "description": "The upload has been completed" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project doesn't exist" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "An internal server error occurred" + } + }, + "summary": "It completes a multi-part upload.", + "tags": [ + "Analytics" + ] + } + }, + "/api/cache": { + "get": { + "callbacks": {}, + "description": "This endpoint returns a signed URL that can be used to download an artifact from the cache.", + "operationId": "downloadCacheArtifact", + "parameters": [ + { + "description": "The category of the cache. It's used to differentiate between different types of caches.", + "in": "query", + "name": "cache_category", + "required": false, + "schema": { + "$ref": "#/components/schemas/CacheCategory" + } + }, + { + "description": "The project identifier '{account_name}/{project_name}'.", + "in": "query", + "name": "project_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The hash that uniquely identifies the artifact in the cache.", + "in": "query", + "name": "hash", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the artifact.", + "in": "query", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CacheArtifactDownloadURL" + } + } + }, + "description": "The artifact exists and is downloadable" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account has an invalid plan" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project or the cache artifact doesn't exist" + } + }, + "summary": "Downloads an artifact from the cache.", + "tags": [ + "Cache" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/previews": { + "get": { + "callbacks": {}, + "description": "This endpoint returns a list of previews for a given project.", + "operationId": "listPreviews", + "parameters": [ + { + "description": "The handle of the account.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The handle of the project.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The display name of previews.", + "in": "query", + "name": "display_name", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "The preview version specifier. Currently, accepts a commit SHA, branch name, or latest.", + "in": "query", + "name": "specifier", + "required": false, + "schema": { + "type": "string" + } + }, + { + "description": "", + "in": "query", + "name": "supported_platforms", + "required": false, + "schema": { + "description": "The supported platforms of the preview.", + "items": { + "$ref": "#/components/schemas/PreviewSupportedPlatform" + }, + "type": "array" + } + }, + { + "description": "", + "in": "query", + "name": "page_size", + "required": false, + "schema": { + "default": 10, + "description": "The maximum number of preview to return in a single page.", + "maximum": 20, + "minimum": 1, + "title": "PreviewIndexPageSize", + "type": "integer" + } + }, + { + "description": "", + "in": "query", + "name": "page", + "required": false, + "schema": { + "default": 1, + "description": "The page number to return.", + "minimum": 1, + "title": "PreviewIndexPage", + "type": "integer" + } + }, + { + "description": "Distinct fields – no two previews will be returned with this field having the same value.", + "in": "query", + "name": "distinct_field", + "required": false, + "schema": { + "enum": [ + "bundle_identifier" + ], + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "previews": { + "description": "Previews list.", + "items": { + "$ref": "#/components/schemas/Preview" + }, + "type": "array" + } + }, + "required": [ + "previews" + ], + "title": "PreviewsIndex", + "type": "object" + } + } + }, + "description": "Successful response for listing previews." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + } + }, + "summary": "List previews.", + "tags": [ + "Previews" + ] + } + }, + "/api/organizations/{organization_name}/invitations": { + "delete": { + "callbacks": {}, + "description": "Cancels an invitation for a given invitee email and an organization.", + "operationId": "cancelInvitation", + "parameters": [ + { + "description": "The name of the organization.", + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "invitee_email": { + "description": "The email of the invitee.", + "type": "string" + } + }, + "required": [ + "invitee_email" + ], + "type": "object" + } + } + }, + "description": "Invitation params", + "required": false + }, + "responses": { + "204": { + "description": "The invitation was cancelled" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The invitation with the given invitee email and organization name was not found" + } + }, + "summary": "Cancels an invitation", + "tags": [ + "Invitations" + ] + }, + "post": { + "callbacks": {}, + "description": "Invites a user with a given email to a given organization.", + "operationId": "createInvitation", + "parameters": [ + { + "description": "The name of the organization.", + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "invitee_email": { + "description": "The email of the invitee.", + "type": "string" + } + }, + "required": [ + "invitee_email" + ], + "type": "object" + } + } + }, + "description": "Invitation params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Invitation" + } + } + }, + "description": "The user was invited" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The user could not be invited due to a validation error" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization was not found" + } + }, + "summary": "Creates an invitation", + "tags": [ + "Invitations" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/cache/clean": { + "put": { + "callbacks": {}, + "operationId": "cleanCache", + "parameters": [ + { + "description": "The name of the account that the project belongs to.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the project to clean cache for", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "The cache has been successfully cleaned" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project was not found" + } + }, + "summary": "Cleans cache for a given project", + "tags": [ + "Cache" + ] + } + }, + "/api/runs/{run_id}/generate-url": { + "post": { + "callbacks": {}, + "description": "Given an upload ID and a part number, this endpoint returns a signed URL that can be used to upload a part of a multipart upload. The URL is short-lived and expires in 120 seconds.", + "operationId": "generateAnalyticsArtifactMultipartUploadURL", + "parameters": [ + { + "description": "The id of the command event.", + "in": "path", + "name": "run_id", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "command_event_artifact": { + "$ref": "#/components/schemas/CommandEventArtifact" + }, + "multipart_upload_part": { + "$ref": "#/components/schemas/ArtifactMultipartUploadPart" + } + }, + "required": [ + "command_event_artifact", + "multipart_upload_part" + ], + "type": "object" + } + } + }, + "description": "Artifact to generate a signed URL for", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactMultipartUploadURL" + } + } + }, + "description": "The URL has been generated" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project doesn't exist" + } + }, + "summary": "It generates a signed URL for uploading a part.", + "tags": [ + "Analytics" + ] + } + }, + "/api/accounts/{account_handle}/tokens": { + "post": { + "callbacks": {}, + "description": "This endpoint returns a new account token.", + "operationId": "createAccountToken", + "parameters": [ + { + "description": "The account handle.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "description": "The request to create a new account token.", + "properties": { + "scopes": { + "description": "The scopes for the new account token.", + "items": { + "description": "The scope of the token.", + "enum": [ + "account_registry_read" + ], + "title": "AccountTokenScope", + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "scopes" + ], + "title": "CreateAccountToken", + "type": "object" + } + } + }, + "description": "Create account token params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "description": "A new account token.", + "properties": { + "token": { + "description": "The generated account token.", + "type": "string" + } + }, + "required": [ + "token" + ], + "title": "AccountToken", + "type": "object" + } + } + }, + "description": "An account token was generated" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to issue new tokens" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authorized to issue new tokens" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account was not found" + } + }, + "summary": "Create a new account token.", + "tags": [] + } + }, + "/api/projects/{account_handle}/{project_handle}/previews/generate-url": { + "post": { + "callbacks": {}, + "description": "Given an upload ID and a part number, this endpoint returns a signed URL that can be used to upload a part of a multipart upload. The URL is short-lived and expires in 120 seconds.", + "operationId": "generatePreviewsMultipartUploadURL", + "parameters": [ + { + "description": "The handle of the account.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The handle of the project.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "multipart_upload_part": { + "$ref": "#/components/schemas/ArtifactMultipartUploadPart" + }, + "preview_id": { + "description": "The id of the preview.", + "type": "string" + } + }, + "required": [ + "multipart_upload_part", + "preview_id" + ], + "type": "object" + } + } + }, + "description": "Artifact to generate a signed URL for", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactMultipartUploadURL" + } + } + }, + "description": "The URL has been generated" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project doesn't exist" + } + }, + "summary": "It generates a signed URL for uploading a part.", + "tags": [ + "Previews" + ] + } + }, + "/api/organizations/{organization_name}": { + "delete": { + "callbacks": {}, + "description": "Deletes the organization with the given name.", + "operationId": "deleteOrganization", + "parameters": [ + { + "description": "The name of the organization to delete.", + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "The organization was deleted" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization with the given name was not found" + } + }, + "summary": "Deletes an organization", + "tags": [ + "Organizations" + ] + }, + "get": { + "callbacks": {}, + "description": "Returns the organization with the given identifier.", + "operationId": "showOrganization", + "parameters": [ + { + "description": "The name of the organization to show.", + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Organization" + } + } + }, + "description": "The organization" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization with the given name was not found" + } + }, + "summary": "Shows an organization", + "tags": [ + "Organizations" + ] + }, + "patch": { + "callbacks": {}, + "description": "Updates an organization with given parameters.", + "operationId": "updateOrganization (2)", + "parameters": [ + { + "description": "The name of the organization to update.", + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "sso_organization_id": { + "description": "The SSO organization ID to be associated with the SSO provider", + "nullable": true, + "type": "string" + }, + "sso_provider": { + "description": "The SSO provider to set up for the organization", + "enum": [ + "google", + "okta", + "none" + ], + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Organization update params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Organization" + } + } + }, + "description": "The organization" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization could not be updated due to a validation error" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization with the given name was not found" + } + }, + "summary": "Updates an organization", + "tags": [ + "Organizations" + ] + }, + "put": { + "callbacks": {}, + "description": "Updates an organization with given parameters.", + "operationId": "updateOrganization", + "parameters": [ + { + "description": "The name of the organization to update.", + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "sso_organization_id": { + "description": "The SSO organization ID to be associated with the SSO provider", + "nullable": true, + "type": "string" + }, + "sso_provider": { + "description": "The SSO provider to set up for the organization", + "enum": [ + "google", + "okta", + "none" + ], + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Organization update params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Organization" + } + } + }, + "description": "The organization" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization could not be updated due to a validation error" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization with the given name was not found" + } + }, + "summary": "Updates an organization", + "tags": [ + "Organizations" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/cache/ac": { + "post": { + "callbacks": {}, + "description": "The endpoint caches a given action item without uploading a file. To upload files, use the multipart upload instead.", + "operationId": "uploadCacheActionItem", + "parameters": [ + { + "description": "The name of the account that the project belongs to.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the project to clean cache for", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "hash": { + "description": "The hash of the cache action item.", + "type": "string" + } + }, + "title": "CacheActionItemUploadParams", + "type": "object" + } + } + }, + "description": "Cache action item upload params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CacheActionItem" + } + } + }, + "description": "The request is valid but the cache action item already exists" + }, + "201": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CacheActionItem" + } + } + }, + "description": "The action item was cached" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request has missing or invalid parameters" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account has an invalid plan" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project doesn't exist" + } + }, + "summary": "It uploads a given cache action item.", + "tags": [ + "Cache" + ] + } + }, + "/api/cache/multipart/generate-url": { + "post": { + "callbacks": {}, + "description": "Given an upload ID and a part number, this endpoint returns a signed URL that can be used to upload a part of a multipart upload. The URL is short-lived and expires in 120 seconds.", + "operationId": "generateCacheArtifactMultipartUploadURL", + "parameters": [ + { + "description": "The category of the cache. It's used to differentiate between different types of caches.", + "in": "query", + "name": "cache_category", + "required": false, + "schema": { + "$ref": "#/components/schemas/CacheCategory" + } + }, + { + "description": "The size in bytes of the part that will be uploaded. It's used to generate the signed URL.", + "in": "query", + "name": "content_length", + "required": false, + "schema": { + "type": "integer" + } + }, + { + "description": "The project identifier '{account_name}/{project_name}'.", + "in": "query", + "name": "project_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The hash that uniquely identifies the artifact in the cache.", + "in": "query", + "name": "hash", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The part number of the multipart upload.", + "in": "query", + "name": "part_number", + "required": true, + "schema": { + "type": "integer" + } + }, + { + "description": "The upload ID.", + "in": "query", + "name": "upload_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the artifact.", + "in": "query", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactMultipartUploadURL" + } + } + }, + "description": "The URL has been generated" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account has an invalid plan" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project doesn't exist" + } + }, + "summary": "It generates a signed URL for uploading a part.", + "tags": [ + "Cache" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/cache/ac/{hash}": { + "get": { + "callbacks": {}, + "description": "This endpoint gets an item from the action cache.", + "operationId": "getCacheActionItem", + "parameters": [ + { + "description": "The name of the account that the project belongs to.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the project the cache action item belongs to.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The hash that uniquely identifies an item in the action cache.", + "in": "path", + "name": "hash", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CacheActionItem" + } + } + }, + "description": "The item exists in the action cache" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account has an invalid plan" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The item doesn't exist in the actino cache" + } + }, + "summary": "Get a cache action item.", + "tags": [ + "Cache" + ] + } + }, + "/api/cache/multipart/start": { + "post": { + "callbacks": {}, + "description": "The endpoint returns an upload ID that can be used to generate URLs for the individual parts and complete the upload.", + "operationId": "startCacheArtifactMultipartUpload", + "parameters": [ + { + "description": "The category of the cache. It's used to differentiate between different types of caches.", + "in": "query", + "name": "cache_category", + "required": false, + "schema": { + "$ref": "#/components/schemas/CacheCategory" + } + }, + { + "description": "The project identifier '{account_name}/{project_name}'.", + "in": "query", + "name": "project_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The hash that uniquely identifies the artifact in the cache.", + "in": "query", + "name": "hash", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the artifact.", + "in": "query", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactUploadID" + } + } + }, + "description": "The upload has been started" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account has an invalid plan" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project doesn't exist" + } + }, + "summary": "It initiates a multipart upload in the cache.", + "tags": [ + "Cache" + ] + } + }, + "/api/organizations/{organization_name}/usage": { + "get": { + "callbacks": {}, + "description": "Returns the usage of the organization with the given identifier. (e.g. number of remote cache hits)", + "operationId": "showOrganizationUsage", + "parameters": [ + { + "description": "The name of the organization to show.", + "in": "path", + "name": "organization_name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/OrganizationUsage" + } + } + }, + "description": "The organization usage" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The organization with the given name was not found" + } + }, + "summary": "Shows the usage of an organization", + "tags": [ + "Organizations" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/tokens": { + "get": { + "callbacks": {}, + "description": "This endpoint returns all tokens for a given project.", + "operationId": "listProjectTokens", + "parameters": [ + { + "description": "The account handle.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The project handle.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "description": "A list of project tokens.", + "properties": { + "tokens": { + "items": { + "$ref": "#/components/schemas/ProjectToken" + }, + "type": "array" + } + }, + "required": [ + "tokens" + ], + "title": "Tokens", + "type": "object" + } + } + }, + "description": "A list of project tokens." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to list tokens" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authorized to list tokens" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project was not found" + } + }, + "summary": "List all project tokens.", + "tags": [ + "Project tokens" + ] + }, + "post": { + "callbacks": {}, + "description": "This endpoint returns a new project token.", + "operationId": "createProjectToken", + "parameters": [ + { + "description": "The account handle.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The project handle.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "description": "A new project token.", + "properties": { + "token": { + "description": "The generated project token.", + "type": "string" + } + }, + "required": [ + "token" + ], + "title": "ProjectFullToken", + "type": "object" + } + } + }, + "description": "A project token was generated" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to issue new tokens" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authorized to issue new tokens" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project was not found" + } + }, + "summary": "Create a new project token.", + "tags": [ + "Project tokens" + ] + } + }, + "/api/projects": { + "get": { + "callbacks": {}, + "operationId": "listProjects", + "parameters": [], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "properties": { + "projects": { + "items": { + "$ref": "#/components/schemas/Project" + }, + "type": "array" + } + }, + "required": [ + "projects" + ], + "type": "object" + } + } + }, + "description": "List of projects" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + } + }, + "summary": "List projects the authenticated user has access to.", + "tags": [ + "Projects" + ] + }, + "post": { + "callbacks": {}, + "operationId": "createProject", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "full_handle": { + "description": "The full handle of the project that should be created.", + "example": "tuist/tuist", + "type": "string" + }, + "name": { + "deprecated": true, + "description": "The name of the project that should be created.", + "type": "string" + }, + "organization": { + "deprecated": true, + "description": "Organization to create the project with. If not specified, the project will be created with the current user's personal account.", + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Projects params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Project" + } + } + }, + "description": "The project was created" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account was not found" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + } + }, + "summary": "Create a new project.", + "tags": [ + "Projects" + ] + } + }, + "/api/runs/{run_id}/start": { + "post": { + "callbacks": {}, + "description": "The endpoint returns an upload ID that can be used to generate URLs for the individual parts and complete the upload.", + "operationId": "startAnalyticsArtifactMultipartUpload", + "parameters": [ + { + "description": "The id of the command event.", + "in": "path", + "name": "run_id", + "required": true, + "schema": { + "type": "integer" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CommandEventArtifact" + } + } + }, + "description": "Artifact to upload", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ArtifactUploadID" + } + } + }, + "description": "The upload has been started" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The command event doesn't exist" + } + }, + "summary": "It initiates a multipart upload for a command event artifact.", + "tags": [ + "Analytics" + ] + } + }, + "/api/auth/device_code/{device_code}": { + "get": { + "callbacks": {}, + "description": "This endpoint returns a token for a given device code if the device code is authenticated.", + "operationId": "getDeviceCode", + "parameters": [ + { + "description": "The device code to query.", + "in": "path", + "name": "device_code", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "description": "Token to authenticate the user with.", + "properties": { + "access_token": { + "description": "A short-lived token to authenticate API requests as user.", + "type": "string" + }, + "refresh_token": { + "description": "A token to generate new access tokens when they expire.", + "type": "string" + }, + "token": { + "deprecated": true, + "description": "User authentication token", + "type": "string" + } + }, + "title": "DeviceCodeAuthenticationTokens", + "type": "object" + } + } + }, + "description": "The device code is authenticated" + }, + "202": { + "content": { + "application/json": { + "schema": { + "type": "object" + } + } + }, + "description": "The device code is not authenticated" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The request was not accepted, e.g., when the device code is expired" + } + }, + "summary": "Get a specific device code.", + "tags": [ + "Authentication" + ] + } + }, + "/api/auth/refresh_token": { + "post": { + "callbacks": {}, + "description": "This endpoint returns new tokens for a given refresh token if the refresh token is valid.", + "operationId": "refreshToken", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "refresh_token": { + "description": "User refresh token", + "type": "string" + } + }, + "required": [ + "refresh_token" + ], + "type": "object" + } + } + }, + "description": "Token params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthenticationTokens" + } + } + }, + "description": "Succcessfully generated new API tokens." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to issue new tokens" + } + }, + "summary": "Request new tokens.", + "tags": [ + "Authentication" + ] + } + }, + "/api/auth": { + "post": { + "callbacks": {}, + "description": "This endpoint returns API tokens for a given email and password.", + "operationId": "authenticate", + "parameters": [], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "email": { + "description": "The email to authenticate with.", + "type": "string" + }, + "password": { + "description": "The password to authenticate with.", + "type": "string" + } + }, + "required": [ + "email", + "password" + ], + "type": "object" + } + } + }, + "description": "Authentication params.", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/AuthenticationTokens" + } + } + }, + "description": "Successfully authenticated and returned new API tokens." + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "Invalid email or password." + } + }, + "summary": "Authenticate with email and password.", + "tags": [ + "Authentication" + ] + } + }, + "/api/projects/{account_handle}/{project_handle}/previews/start": { + "post": { + "callbacks": {}, + "description": "The endpoint returns an upload ID that can be used to generate URLs for the individual parts and complete the upload.", + "operationId": "startPreviewsMultipartUpload", + "parameters": [ + { + "description": "The handle of the account.", + "in": "path", + "name": "account_handle", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The handle of the project.", + "in": "path", + "name": "project_handle", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "bundle_identifier": { + "description": "The bundle identifier of the preview.", + "type": "string" + }, + "display_name": { + "description": "The display name of the preview.", + "type": "string" + }, + "supported_platforms": { + "description": "The supported platforms of the preview.", + "items": { + "$ref": "#/components/schemas/PreviewSupportedPlatform" + }, + "type": "array" + }, + "type": { + "default": "app_bundle", + "description": "The type of the preview to upload.", + "enum": [ + "app_bundle", + "ipa" + ], + "type": "string" + }, + "version": { + "description": "The version of the preview.", + "type": "string" + } + }, + "type": "object" + } + } + }, + "description": "Preview upload request params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "description": "The upload has been initiated and preview and upload unique identifier are returned to upload the various parts using multi-part uploads", + "properties": { + "data": { + "description": "Data that contains preview and upload unique identifier associated with the multipart upload to use when uploading parts", + "properties": { + "preview_id": { + "description": "The id of the preview.", + "type": "string" + }, + "upload_id": { + "description": "The upload ID", + "type": "string" + } + }, + "required": [ + "upload_id", + "preview_id" + ], + "type": "object" + }, + "status": { + "default": "success", + "enum": [ + "success" + ], + "type": "string" + } + }, + "required": [ + "status", + "data" + ], + "title": "PreviewArtifactUpload", + "type": "object" + } + } + }, + "description": "The upload has been started" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project doesn't exist" + } + }, + "summary": "It initiates a multipart upload for a preview artifact.", + "tags": [ + "Previews" + ] + } + }, + "/api/analytics": { + "post": { + "callbacks": {}, + "operationId": "createCommandEvent", + "parameters": [ + { + "description": "The project id.", + "in": "query", + "name": "project_id", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "client_id": { + "description": "The client id of the command.", + "type": "string" + }, + "command_arguments": { + "description": "The arguments of the command.", + "items": { + "type": "string" + }, + "type": "array" + }, + "duration": { + "description": "The duration of the command.", + "type": "number" + }, + "error_message": { + "description": "The error message of the command.", + "type": "string" + }, + "git_branch": { + "description": "The git branch.", + "type": "string" + }, + "git_commit_sha": { + "description": "The commit SHA.", + "type": "string" + }, + "git_ref": { + "description": "The git ref. When on CI, the value can be equal to remote reference such as `refs/pull/1234/merge`.", + "type": "string" + }, + "git_remote_url_origin": { + "description": "The git remote URL origin.", + "type": "string" + }, + "is_ci": { + "description": "Whether the command was run in a CI environment.", + "type": "boolean" + }, + "macos_version": { + "description": "The version of macOS that ran the command.", + "type": "string" + }, + "name": { + "description": "The name of the command.", + "type": "string" + }, + "params": { + "description": "Extra parameters.", + "properties": { + "cacheable_targets": { + "description": "A list of cacheable targets.", + "items": { + "type": "string" + }, + "type": "array" + }, + "local_cache_target_hits": { + "description": "A list of local cache target hits.", + "items": { + "type": "string" + }, + "type": "array" + }, + "local_test_target_hits": { + "description": "A list of local targets whose tests were skipped.", + "items": { + "type": "string" + }, + "type": "array" + }, + "remote_cache_target_hits": { + "description": "A list of remote cache target hits.", + "items": { + "type": "string" + }, + "type": "array" + }, + "remote_test_target_hits": { + "description": "A list of remote targets whose tests were skipped.", + "items": { + "type": "string" + }, + "type": "array" + }, + "test_targets": { + "description": "The list of targets that were tested.", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "type": "object" + }, + "preview_id": { + "description": "The preview identifier.", + "type": "string" + }, + "status": { + "description": "The status of the command.", + "enum": [ + "success", + "failure" + ], + "type": "string" + }, + "subcommand": { + "description": "The subcommand of the command.", + "type": "string" + }, + "swift_version": { + "description": "The version of Swift that ran the command.", + "type": "string" + }, + "tuist_version": { + "description": "The version of Tuist that ran the command.", + "type": "string" + } + }, + "required": [ + "name", + "duration", + "tuist_version", + "swift_version", + "macos_version", + "is_ci", + "client_id" + ], + "type": "object" + } + } + }, + "description": "Command event params", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/CommandEvent" + } + } + }, + "description": "The command event was created" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You don't have permission to create command events for the project." + } + }, + "summary": "Create a a new command analytics event", + "tags": [ + "Analytics" + ] + } + }, + "/api/cache/multipart/complete": { + "post": { + "callbacks": {}, + "description": "Given the upload ID and all the parts with their ETags, this endpoint completes the multipart upload. The cache will then be able to serve the artifact.", + "operationId": "completeCacheArtifactMultipartUpload", + "parameters": [ + { + "description": "The category of the cache. It's used to differentiate between different types of caches.", + "in": "query", + "name": "cache_category", + "required": false, + "schema": { + "$ref": "#/components/schemas/CacheCategory" + } + }, + { + "description": "The project identifier '{account_name}/{project_name}'.", + "in": "query", + "name": "project_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The hash that uniquely identifies the artifact in the cache.", + "in": "query", + "name": "hash", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The upload ID.", + "in": "query", + "name": "upload_id", + "required": true, + "schema": { + "type": "string" + } + }, + { + "description": "The name of the artifact.", + "in": "query", + "name": "name", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "properties": { + "parts": { + "items": { + "properties": { + "etag": { + "description": "The ETag of the part", + "type": "string" + }, + "part_number": { + "description": "The part number", + "type": "integer" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "type": "object" + } + } + }, + "description": "Multi-part upload parts", + "required": false + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "description": "This response confirms that the upload has been completed successfully. The cache will now be able to serve the artifact.", + "properties": { + "data": { + "properties": {}, + "type": "object" + }, + "status": { + "default": "success", + "enum": [ + "success" + ], + "type": "string" + } + }, + "title": "CacheArtifactMultipartUploadCompletion", + "type": "object" + } + } + }, + "description": "The upload has been completed" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "You need to be authenticated to access this resource" + }, + "402": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The account has an invalid plan" + }, + "403": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The authenticated subject is not authorized to perform this action" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/Error" + } + } + }, + "description": "The project doesn't exist" + } + }, + "summary": "It completes a multi-part upload.", + "tags": [ + "Cache" + ] + } + } + }, + "servers": [ + { + "url": "https://tuist.dev", + "variables": {} + } + ], + "tags": [] +} diff --git a/internal/agent/http_cache/tuistcache/tuistcache.go b/internal/agent/http_cache/tuistcache/tuistcache.go index 846eee8b..aa09d50e 100644 --- a/internal/agent/http_cache/tuistcache/tuistcache.go +++ b/internal/agent/http_cache/tuistcache/tuistcache.go @@ -16,16 +16,6 @@ import ( const APIMountPoint = "/tuistcache" -type NoSecurity struct{} - -func (NoSecurity) HandleAuthorization(ctx context.Context, _ string, _ tuistapi.Authorization) (context.Context, error) { - return ctx, nil -} - -func (NoSecurity) HandleCookie(ctx context.Context, _ string, _ tuistapi.Cookie) (context.Context, error) { - return ctx, nil -} - type TuistCache struct { server *tuistapi.Server @@ -35,7 +25,7 @@ type TuistCache struct { func New() (*TuistCache, error) { tc := &TuistCache{} - server, err := tuistapi.NewServer(tc, NoSecurity{}) + server, err := tuistapi.NewServer(tc) if err != nil { return nil, err } diff --git a/internal/agent/http_cache/tuistcache/tuistcache_test.go b/internal/agent/http_cache/tuistcache/tuistcache_test.go index 689eab9a..0f8f5008 100644 --- a/internal/agent/http_cache/tuistcache/tuistcache_test.go +++ b/internal/agent/http_cache/tuistcache/tuistcache_test.go @@ -16,16 +16,6 @@ import ( "testing" ) -type NoSecurity struct{} - -func (NoSecurity) Authorization(_ context.Context, _ string) (tuistapi.Authorization, error) { - return tuistapi.Authorization{}, nil -} - -func (NoSecurity) Cookie(_ context.Context, _ string) (tuistapi.Cookie, error) { - return tuistapi.Cookie{}, nil -} - func TestTuistCache(t *testing.T) { testutil.NeedsContainerization(t) @@ -38,7 +28,7 @@ func TestTuistCache(t *testing.T) { tuistCacheURL := tuistcache.URL(http_cache.Start(http_cache.WithTuistCache(tuistCache))) - tuistCacheClient, err := tuistapi.NewClient(tuistCacheURL, NoSecurity{}) + tuistCacheClient, err := tuistapi.NewClient(tuistCacheURL) require.NoError(t, err) projectID := "account-name/project-name" diff --git a/internal/agent/http_cache/tuistcache/update-schema.sh b/internal/agent/http_cache/tuistcache/update-schema.sh new file mode 100644 index 00000000..4342fd6e --- /dev/null +++ b/internal/agent/http_cache/tuistcache/update-schema.sh @@ -0,0 +1,3 @@ +#!/bin/bash + +curl https://cloud.tuist.io/api/spec | jq 'del(.security, .components.securitySchemes)' > openapi.json