From c2558d49a2b5b7b8a89487c2eb55d1c48aa64f30 Mon Sep 17 00:00:00 2001 From: MasterPtato <23087326+MasterPtato@users.noreply.github.com> Date: Wed, 27 Nov 2024 01:34:07 +0000 Subject: [PATCH] feat: add batch actor upgrade (#1480) Fixes RVT-4155 ## Changes --- packages/api/actor/src/route/actors.rs | 126 +++++++++++++- packages/api/actor/src/route/mod.rs | 25 +++ .../ds/src/ops/server/list_for_env.rs | 3 +- .../api/fern/definition/actor/__package__.yml | 22 +++ sdks/api/full/go/actor/actor.go | 60 +++++++ sdks/api/full/go/actor/client/client.go | 90 ++++++++++ sdks/api/full/go/actor/types.go | 19 +++ sdks/api/full/openapi/openapi.yml | 85 ++++++++++ sdks/api/full/openapi_compat/openapi.yml | 85 ++++++++++ .../full/rust-cli/.openapi-generator/FILES | 4 + sdks/api/full/rust-cli/README.md | 3 + sdks/api/full/rust-cli/docs/ActorApi.md | 33 ++++ .../docs/ActorUpgradeAllActorsRequest.md | 13 ++ .../docs/ActorUpgradeAllActorsResponse.md | 11 ++ sdks/api/full/rust-cli/src/apis/actor_api.rs | 51 ++++++ .../actor_upgrade_all_actors_request.rs | 34 ++++ .../actor_upgrade_all_actors_response.rs | 28 ++++ sdks/api/full/rust-cli/src/models/mod.rs | 4 + sdks/api/full/rust/.openapi-generator/FILES | 4 + sdks/api/full/rust/README.md | 3 + sdks/api/full/rust/docs/ActorApi.md | 33 ++++ .../rust/docs/ActorUpgradeAllActorsRequest.md | 13 ++ .../docs/ActorUpgradeAllActorsResponse.md | 11 ++ sdks/api/full/rust/src/apis/actor_api.rs | 65 ++++++++ .../actor_upgrade_all_actors_request.rs | 34 ++++ .../actor_upgrade_all_actors_response.rs | 21 +++ sdks/api/full/rust/src/models/mod.rs | 4 + .../src/api/resources/actor/client/Client.ts | 157 ++++++++++++++++++ .../requests/UpgradeAllActorsRequestQuery.ts | 27 +++ .../resources/actor/client/requests/index.ts | 1 + sdks/api/runtime/go/actor/actor.go | 60 +++++++ sdks/api/runtime/go/actor/client/client.go | 90 ++++++++++ sdks/api/runtime/go/actor/types.go | 19 +++ sdks/api/runtime/openapi/openapi.yml | 85 ++++++++++ sdks/api/runtime/openapi_compat/openapi.yml | 85 ++++++++++ .../api/runtime/rust/.openapi-generator/FILES | 4 + sdks/api/runtime/rust/README.md | 3 + sdks/api/runtime/rust/docs/ActorApi.md | 33 ++++ .../rust/docs/ActorUpgradeAllActorsRequest.md | 13 ++ .../docs/ActorUpgradeAllActorsResponse.md | 11 ++ sdks/api/runtime/rust/src/apis/actor_api.rs | 51 ++++++ .../actor_upgrade_all_actors_request.rs | 34 ++++ .../actor_upgrade_all_actors_response.rs | 28 ++++ sdks/api/runtime/rust/src/models/mod.rs | 4 + .../src/api/resources/actor/client/Client.ts | 157 ++++++++++++++++++ .../requests/UpgradeAllActorsRequestQuery.ts | 27 +++ .../resources/actor/client/requests/index.ts | 1 + 47 files changed, 1764 insertions(+), 10 deletions(-) create mode 100644 sdks/api/full/rust-cli/docs/ActorUpgradeAllActorsRequest.md create mode 100644 sdks/api/full/rust-cli/docs/ActorUpgradeAllActorsResponse.md create mode 100644 sdks/api/full/rust-cli/src/models/actor_upgrade_all_actors_request.rs create mode 100644 sdks/api/full/rust-cli/src/models/actor_upgrade_all_actors_response.rs create mode 100644 sdks/api/full/rust/docs/ActorUpgradeAllActorsRequest.md create mode 100644 sdks/api/full/rust/docs/ActorUpgradeAllActorsResponse.md create mode 100644 sdks/api/full/rust/src/models/actor_upgrade_all_actors_request.rs create mode 100644 sdks/api/full/rust/src/models/actor_upgrade_all_actors_response.rs create mode 100644 sdks/api/full/typescript/src/api/resources/actor/client/requests/UpgradeAllActorsRequestQuery.ts create mode 100644 sdks/api/runtime/rust/docs/ActorUpgradeAllActorsRequest.md create mode 100644 sdks/api/runtime/rust/docs/ActorUpgradeAllActorsResponse.md create mode 100644 sdks/api/runtime/rust/src/models/actor_upgrade_all_actors_request.rs create mode 100644 sdks/api/runtime/rust/src/models/actor_upgrade_all_actors_response.rs create mode 100644 sdks/api/runtime/typescript/src/api/resources/actor/client/requests/UpgradeAllActorsRequestQuery.ts diff --git a/packages/api/actor/src/route/actors.rs b/packages/api/actor/src/route/actors.rs index e5f74413a9..b18d09d17d 100644 --- a/packages/api/actor/src/route/actors.rs +++ b/packages/api/actor/src/route/actors.rs @@ -1,4 +1,5 @@ use api_helper::{anchor::WatchIndexQuery, ctx::Ctx}; +use futures_util::{StreamExt, TryStreamExt}; use proto::backend; use rivet_api::models; use rivet_convert::{ApiInto, ApiTryInto}; @@ -439,6 +440,98 @@ pub async fn upgrade( Ok(json!({})) } +// MARK: POST /actors/upgrade +pub async fn upgrade_all( + ctx: Ctx, + body: models::ActorUpgradeAllActorsRequest, + query: GlobalQuery, +) -> GlobalResult { + let CheckOutput { env_id, .. } = ctx.auth().check(ctx.op_ctx(), &query, false).await?; + + let tags = unwrap_with!(body.tags, API_BAD_BODY, error = "missing property `tags`"); + + ensure_with!( + tags.as_object().map(|x| x.len()).unwrap_or_default() <= 64, + API_BAD_BODY, + error = "Too many tags (max 64)." + ); + + let tags = unwrap_with!( + serde_json::from_value::>(tags).ok(), + API_BAD_BODY, + error = "`tags` must be `Map`" + ); + + for (k, v) in &tags { + ensure_with!( + k.len() <= 256, + API_BAD_BODY, + error = format!( + "tags[{:?}]: Tag label too large (max 256 bytes).", + &k[..256] + ), + ); + + ensure_with!( + v.len() <= 1024, + API_BAD_BODY, + error = format!("tags[{k:?}]: Tag value too large (max 1024 bytes)."), + ); + } + + let build_id = resolve_build_id(&ctx, env_id, body.build, body.build_tags.flatten()).await?; + + // Work in batches + let mut count = 0; + let mut cursor = None; + loop { + let list_res = ctx + .op(ds::ops::server::list_for_env::Input { + env_id, + tags: tags.clone(), + include_destroyed: false, + cursor, + limit: 10_000, + }) + .await?; + + count += list_res.server_ids.len(); + cursor = list_res.server_ids.last().cloned(); + + let subs = futures_util::stream::iter(list_res.server_ids.clone()) + .map(|server_id| { + ctx.subscribe::(("server_id", server_id)) + }) + .buffer_unordered(32) + .try_collect::>() + .await?; + + futures_util::stream::iter(list_res.server_ids) + .map(|server_id| { + ctx.signal(ds::workflows::server::Upgrade { image_id: build_id }) + .tag("server_id", server_id) + .send() + }) + .buffer_unordered(32) + .try_collect::>() + .await?; + + futures_util::stream::iter(subs) + .map(|mut sub| async move { sub.next().await }) + .buffer_unordered(32) + .try_collect::>() + .await?; + + if count % 10_000 != 0 { + break; + } + } + + Ok(models::ActorUpgradeAllActorsResponse { + count: count.try_into()?, + }) +} + // MARK: GET /actors #[derive(Debug, Clone, Deserialize)] pub struct ListQuery { @@ -464,15 +557,26 @@ async fn list_actors_inner( ) -> GlobalResult { let CheckOutput { env_id, .. } = ctx.auth().check(ctx.op_ctx(), &query.global, false).await?; + let include_destroyed = query.include_destroyed.unwrap_or(false); + + let tags = unwrap_with!( + query + .tags_json + .as_deref() + .map_or(Ok(HashMap::new()), serde_json::from_str) + .ok(), + API_BAD_QUERY_PARAMETER, + parameter = "tags_json", + error = "must be `Map`" + ); + let list_res = ctx .op(ds::ops::server::list_for_env::Input { env_id, - tags: query - .tags_json - .as_deref() - .map_or(Ok(HashMap::new()), serde_json::from_str)?, - include_destroyed: query.include_destroyed.unwrap_or(false), + tags, + include_destroyed, cursor: query.cursor, + limit: if include_destroyed { 64 } else { 10_000 }, }) .await?; @@ -636,18 +740,22 @@ async fn resolve_build_id( (Some(build_id), None) => Ok(build_id), // Resolve build from tags (None, Some(build_tags)) => { - let build_tags = serde_json::from_value::>(build_tags)?; + let build_tags = unwrap_with!( + serde_json::from_value::>(build_tags).ok(), + API_BAD_BODY, + error = "`build_tags` must be `Map`" + ); ensure_with!( build_tags.len() < 64, - ACTOR_FAILED_TO_CREATE, + API_BAD_BODY, error = "Too many build tags (max 64)." ); for (k, v) in &build_tags { ensure_with!( k.len() < 128, - ACTOR_FAILED_TO_CREATE, + API_BAD_BODY, error = format!( "build_tags[{:?}]: Build tag label too large (max 128 bytes).", &k[..128] @@ -655,7 +763,7 @@ async fn resolve_build_id( ); ensure_with!( v.len() < 256, - ACTOR_FAILED_TO_CREATE, + API_BAD_BODY, error = format!("build_tags[{k:?}]: Build tag value too large (max 256 bytes).") ); diff --git a/packages/api/actor/src/route/mod.rs b/packages/api/actor/src/route/mod.rs index 2a195e5d82..7332868ced 100644 --- a/packages/api/actor/src/route/mod.rs +++ b/packages/api/actor/src/route/mod.rs @@ -68,6 +68,18 @@ define_router! { ), }, + "actors" / "upgrade": { + POST: actors::upgrade_all( + query: GlobalQuery, + body: models::ActorUpgradeAllActorsRequest, + opt_auth: true, + rate_limit: { + buckets: [ + { count: 1_000, bucket: duration::minutes(1) }, + ], + }, + ), + }, "actors" / Uuid: { GET: actors::get( @@ -91,6 +103,19 @@ define_router! { ), }, + "actors" / Uuid / "upgrade": { + POST: actors::upgrade( + query: GlobalQuery, + body: models::ActorUpgradeActorRequest, + opt_auth: true, + rate_limit: { + buckets: [ + { count: 1_000, bucket: duration::minutes(1) }, + ], + }, + ), + }, + "actors" / Uuid / "logs": { GET: logs::get_logs( query: logs::GetActorLogsQuery, diff --git a/packages/services/ds/src/ops/server/list_for_env.rs b/packages/services/ds/src/ops/server/list_for_env.rs index 69e1c490aa..af64dc3ee3 100644 --- a/packages/services/ds/src/ops/server/list_for_env.rs +++ b/packages/services/ds/src/ops/server/list_for_env.rs @@ -8,6 +8,7 @@ pub struct Input { pub tags: HashMap, pub include_destroyed: bool, pub cursor: Option, + pub limit: usize, } #[derive(Debug)] @@ -44,7 +45,7 @@ pub async fn ds_server_list_for_env(ctx: &OperationCtx, input: &Input) -> Global input.include_destroyed, input.cursor, // TODO: Add pagination when OpenGB lobbies no longer uses polling RVTEE-492 - if input.include_destroyed { 64 } else { 10_000 }, + i64::try_from(input.limit)?, ) .await? .into_iter() diff --git a/sdks/api/fern/definition/actor/__package__.yml b/sdks/api/fern/definition/actor/__package__.yml index 83a482bf4c..4ab34f2bbf 100644 --- a/sdks/api/fern/definition/actor/__package__.yml +++ b/sdks/api/fern/definition/actor/__package__.yml @@ -89,6 +89,18 @@ service: body: UpgradeActorRequest response: UpgradeActorResponse + upgradeAll: + path: /upgrade + method: POST + docs: Upgrades a dynamic actor. + request: + name: UpgradeAllActorsRequestQuery + query-parameters: + project: optional + environment: optional + body: UpgradeAllActorsRequest + response: UpgradeAllActorsResponse + types: GetActorResponse: properties: @@ -138,6 +150,16 @@ types: UpgradeActorResponse: properties: {} + UpgradeAllActorsRequest: + properties: + tags: unknown + build: optional + buildTags: optional + + UpgradeAllActorsResponse: + properties: + count: long + ListActorsResponse: properties: actors: diff --git a/sdks/api/full/go/actor/actor.go b/sdks/api/full/go/actor/actor.go index ae247e2a39..2753b66fd5 100644 --- a/sdks/api/full/go/actor/actor.go +++ b/sdks/api/full/go/actor/actor.go @@ -217,3 +217,63 @@ func (u *UpgradeActorResponse) String() string { } return fmt.Sprintf("%#v", u) } + +type UpgradeAllActorsRequest struct { + Tags interface{} `json:"tags,omitempty"` + Build *uuid.UUID `json:"build,omitempty"` + BuildTags interface{} `json:"buildTags,omitempty"` + + _rawJSON json.RawMessage +} + +func (u *UpgradeAllActorsRequest) UnmarshalJSON(data []byte) error { + type unmarshaler UpgradeAllActorsRequest + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpgradeAllActorsRequest(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UpgradeAllActorsRequest) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UpgradeAllActorsResponse struct { + Count int64 `json:"count"` + + _rawJSON json.RawMessage +} + +func (u *UpgradeAllActorsResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UpgradeAllActorsResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpgradeAllActorsResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UpgradeAllActorsResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/sdks/api/full/go/actor/client/client.go b/sdks/api/full/go/actor/client/client.go index e5adae2d60..83bfb4caa2 100644 --- a/sdks/api/full/go/actor/client/client.go +++ b/sdks/api/full/go/actor/client/client.go @@ -509,3 +509,93 @@ func (c *Client) Upgrade(ctx context.Context, actor uuid.UUID, request *sdkactor } return response, nil } + +// Upgrades a dynamic actor. +func (c *Client) UpgradeAll(ctx context.Context, request *sdkactor.UpgradeAllActorsRequestQuery) (*sdkactor.UpgradeAllActorsResponse, error) { + baseURL := "https://api.rivet.gg" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "actors/upgrade" + + queryParams := make(url.Values) + if request.Project != nil { + queryParams.Add("project", fmt.Sprintf("%v", *request.Project)) + } + if request.Environment != nil { + queryParams.Add("environment", fmt.Sprintf("%v", *request.Environment)) + } + if len(queryParams) > 0 { + endpointURL += "?" + queryParams.Encode() + } + + errorDecoder := func(statusCode int, body io.Reader) error { + raw, err := io.ReadAll(body) + if err != nil { + return err + } + apiError := core.NewAPIError(statusCode, errors.New(string(raw))) + decoder := json.NewDecoder(bytes.NewReader(raw)) + switch statusCode { + case 500: + value := new(sdk.InternalError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 429: + value := new(sdk.RateLimitError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 403: + value := new(sdk.ForbiddenError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 408: + value := new(sdk.UnauthorizedError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 404: + value := new(sdk.NotFoundError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 400: + value := new(sdk.BadRequestError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + } + return apiError + } + + var response *sdkactor.UpgradeAllActorsResponse + if err := c.caller.Call( + ctx, + &core.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: c.header, + Request: request, + Response: &response, + ErrorDecoder: errorDecoder, + }, + ); err != nil { + return nil, err + } + return response, nil +} diff --git a/sdks/api/full/go/actor/types.go b/sdks/api/full/go/actor/types.go index 482ff0a647..9359e0961a 100644 --- a/sdks/api/full/go/actor/types.go +++ b/sdks/api/full/go/actor/types.go @@ -671,3 +671,22 @@ func (u *UpgradeActorRequestQuery) UnmarshalJSON(data []byte) error { func (u *UpgradeActorRequestQuery) MarshalJSON() ([]byte, error) { return json.Marshal(u.Body) } + +type UpgradeAllActorsRequestQuery struct { + Project *string `json:"-"` + Environment *string `json:"-"` + Body *UpgradeAllActorsRequest `json:"-"` +} + +func (u *UpgradeAllActorsRequestQuery) UnmarshalJSON(data []byte) error { + body := new(UpgradeAllActorsRequest) + if err := json.Unmarshal(data, &body); err != nil { + return err + } + u.Body = body + return nil +} + +func (u *UpgradeAllActorsRequestQuery) MarshalJSON() ([]byte, error) { + return json.Marshal(u.Body) +} diff --git a/sdks/api/full/openapi/openapi.yml b/sdks/api/full/openapi/openapi.yml index 1d9a0edfaa..87b0ceedc8 100644 --- a/sdks/api/full/openapi/openapi.yml +++ b/sdks/api/full/openapi/openapi.yml @@ -368,6 +368,73 @@ paths: application/json: schema: $ref: '#/components/schemas/ActorUpgradeActorRequest' + /actors/upgrade: + post: + description: Upgrades a dynamic actor. + operationId: actor_upgradeAll + tags: + - Actor + parameters: + - name: project + in: query + required: false + schema: + type: string + - name: environment + in: query + required: false + schema: + type: string + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ActorUpgradeAllActorsResponse' + '400': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '403': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '404': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '408': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '429': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '500': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + security: *ref_0 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ActorUpgradeAllActorsRequest' /cloud/bootstrap: get: description: Returns the basic information required to use the cloud APIs. @@ -8706,6 +8773,24 @@ components: ActorUpgradeActorResponse: type: object properties: {} + ActorUpgradeAllActorsRequest: + type: object + properties: + tags: {} + build: + type: string + format: uuid + buildTags: {} + required: + - tags + ActorUpgradeAllActorsResponse: + type: object + properties: + count: + type: integer + format: int64 + required: + - count ActorListActorsResponse: type: object properties: diff --git a/sdks/api/full/openapi_compat/openapi.yml b/sdks/api/full/openapi_compat/openapi.yml index adcc45e7d7..d1b3cc22eb 100644 --- a/sdks/api/full/openapi_compat/openapi.yml +++ b/sdks/api/full/openapi_compat/openapi.yml @@ -384,6 +384,24 @@ components: ActorUpgradeActorResponse: properties: {} type: object + ActorUpgradeAllActorsRequest: + properties: + build: + format: uuid + type: string + buildTags: {} + tags: {} + required: + - tags + type: object + ActorUpgradeAllActorsResponse: + properties: + count: + format: int64 + type: integer + required: + - count + type: object AuthCompleteStatus: description: Represents the state of an external account linking process. enum: @@ -4882,6 +4900,73 @@ paths: security: *id001 tags: - Actor + /actors/upgrade: + post: + description: Upgrades a dynamic actor. + operationId: actor_upgradeAll + parameters: + - in: query + name: project + required: false + schema: + type: string + - in: query + name: environment + required: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ActorUpgradeAllActorsRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ActorUpgradeAllActorsResponse' + description: '' + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '408': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + security: *id001 + tags: + - Actor /actors/{actor}: delete: description: Destroy a dynamic actor. diff --git a/sdks/api/full/rust-cli/.openapi-generator/FILES b/sdks/api/full/rust-cli/.openapi-generator/FILES index 6c4f2a1ad3..b09f3bce45 100644 --- a/sdks/api/full/rust-cli/.openapi-generator/FILES +++ b/sdks/api/full/rust-cli/.openapi-generator/FILES @@ -39,6 +39,8 @@ docs/ActorRegionsApi.md docs/ActorResources.md docs/ActorRuntime.md docs/ActorUpgradeActorRequest.md +docs/ActorUpgradeAllActorsRequest.md +docs/ActorUpgradeAllActorsResponse.md docs/AuthCompleteStatus.md docs/AuthIdentityCompleteEmailVerificationRequest.md docs/AuthIdentityCompleteEmailVerificationResponse.md @@ -449,6 +451,8 @@ src/models/actor_region.rs src/models/actor_resources.rs src/models/actor_runtime.rs src/models/actor_upgrade_actor_request.rs +src/models/actor_upgrade_all_actors_request.rs +src/models/actor_upgrade_all_actors_response.rs src/models/auth_complete_status.rs src/models/auth_identity_complete_email_verification_request.rs src/models/auth_identity_complete_email_verification_response.rs diff --git a/sdks/api/full/rust-cli/README.md b/sdks/api/full/rust-cli/README.md index 711ee32e03..7bd6b316b6 100644 --- a/sdks/api/full/rust-cli/README.md +++ b/sdks/api/full/rust-cli/README.md @@ -30,6 +30,7 @@ Class | Method | HTTP request | Description *ActorApi* | [**actor_get**](docs/ActorApi.md#actor_get) | **GET** /actors/{actor} | *ActorApi* | [**actor_list**](docs/ActorApi.md#actor_list) | **GET** /actors | *ActorApi* | [**actor_upgrade**](docs/ActorApi.md#actor_upgrade) | **POST** /actors/{actor}/upgrade | +*ActorApi* | [**actor_upgrade_all**](docs/ActorApi.md#actor_upgrade_all) | **POST** /actors/upgrade | *ActorBuildsApi* | [**actor_builds_complete**](docs/ActorBuildsApi.md#actor_builds_complete) | **POST** /builds/{build}/complete | *ActorBuildsApi* | [**actor_builds_get**](docs/ActorBuildsApi.md#actor_builds_get) | **GET** /builds/{build} | *ActorBuildsApi* | [**actor_builds_list**](docs/ActorBuildsApi.md#actor_builds_list) | **GET** /builds | @@ -195,6 +196,8 @@ Class | Method | HTTP request | Description - [ActorResources](docs/ActorResources.md) - [ActorRuntime](docs/ActorRuntime.md) - [ActorUpgradeActorRequest](docs/ActorUpgradeActorRequest.md) + - [ActorUpgradeAllActorsRequest](docs/ActorUpgradeAllActorsRequest.md) + - [ActorUpgradeAllActorsResponse](docs/ActorUpgradeAllActorsResponse.md) - [AuthCompleteStatus](docs/AuthCompleteStatus.md) - [AuthIdentityCompleteEmailVerificationRequest](docs/AuthIdentityCompleteEmailVerificationRequest.md) - [AuthIdentityCompleteEmailVerificationResponse](docs/AuthIdentityCompleteEmailVerificationResponse.md) diff --git a/sdks/api/full/rust-cli/docs/ActorApi.md b/sdks/api/full/rust-cli/docs/ActorApi.md index 6c5e8a3821..c54fe6d3ff 100644 --- a/sdks/api/full/rust-cli/docs/ActorApi.md +++ b/sdks/api/full/rust-cli/docs/ActorApi.md @@ -9,6 +9,7 @@ Method | HTTP request | Description [**actor_get**](ActorApi.md#actor_get) | **GET** /actors/{actor} | [**actor_list**](ActorApi.md#actor_list) | **GET** /actors | [**actor_upgrade**](ActorApi.md#actor_upgrade) | **POST** /actors/{actor}/upgrade | +[**actor_upgrade_all**](ActorApi.md#actor_upgrade_all) | **POST** /actors/upgrade | @@ -175,3 +176,35 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +## actor_upgrade_all + +> crate::models::ActorUpgradeAllActorsResponse actor_upgrade_all(actor_upgrade_all_actors_request, project, environment) + + +Upgrades a dynamic actor. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**actor_upgrade_all_actors_request** | [**ActorUpgradeAllActorsRequest**](ActorUpgradeAllActorsRequest.md) | | [required] | +**project** | Option<**String**> | | | +**environment** | Option<**String**> | | | + +### Return type + +[**crate::models::ActorUpgradeAllActorsResponse**](ActorUpgradeAllActorsResponse.md) + +### Authorization + +[BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/sdks/api/full/rust-cli/docs/ActorUpgradeAllActorsRequest.md b/sdks/api/full/rust-cli/docs/ActorUpgradeAllActorsRequest.md new file mode 100644 index 0000000000..d623c0e764 --- /dev/null +++ b/sdks/api/full/rust-cli/docs/ActorUpgradeAllActorsRequest.md @@ -0,0 +1,13 @@ +# ActorUpgradeAllActorsRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**build** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**build_tags** | Option<[**serde_json::Value**](.md)> | | [optional] +**tags** | Option<[**serde_json::Value**](.md)> | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/sdks/api/full/rust-cli/docs/ActorUpgradeAllActorsResponse.md b/sdks/api/full/rust-cli/docs/ActorUpgradeAllActorsResponse.md new file mode 100644 index 0000000000..eebdd3e19d --- /dev/null +++ b/sdks/api/full/rust-cli/docs/ActorUpgradeAllActorsResponse.md @@ -0,0 +1,11 @@ +# ActorUpgradeAllActorsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**count** | **i64** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/sdks/api/full/rust-cli/src/apis/actor_api.rs b/sdks/api/full/rust-cli/src/apis/actor_api.rs index f5130a4de6..329ce72a09 100644 --- a/sdks/api/full/rust-cli/src/apis/actor_api.rs +++ b/sdks/api/full/rust-cli/src/apis/actor_api.rs @@ -80,6 +80,19 @@ pub enum ActorUpgradeError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`actor_upgrade_all`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActorUpgradeAllError { + Status400(crate::models::ErrorBody), + Status403(crate::models::ErrorBody), + Status404(crate::models::ErrorBody), + Status408(crate::models::ErrorBody), + Status429(crate::models::ErrorBody), + Status500(crate::models::ErrorBody), + UnknownValue(serde_json::Value), +} + /// Create a new dynamic actor. pub async fn actor_create(configuration: &configuration::Configuration, actor_create_actor_request: crate::models::ActorCreateActorRequest, project: Option<&str>, environment: Option<&str>) -> Result> { @@ -280,3 +293,41 @@ pub async fn actor_upgrade(configuration: &configuration::Configuration, actor: } } +/// Upgrades a dynamic actor. +pub async fn actor_upgrade_all(configuration: &configuration::Configuration, actor_upgrade_all_actors_request: crate::models::ActorUpgradeAllActorsRequest, project: Option<&str>, environment: Option<&str>) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/actors/upgrade", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = project { + local_var_req_builder = local_var_req_builder.query(&[("project", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = environment { + local_var_req_builder = local_var_req_builder.query(&[("environment", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&actor_upgrade_all_actors_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/sdks/api/full/rust-cli/src/models/actor_upgrade_all_actors_request.rs b/sdks/api/full/rust-cli/src/models/actor_upgrade_all_actors_request.rs new file mode 100644 index 0000000000..ebaff39fa7 --- /dev/null +++ b/sdks/api/full/rust-cli/src/models/actor_upgrade_all_actors_request.rs @@ -0,0 +1,34 @@ +/* + * Rivet API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ActorUpgradeAllActorsRequest { + #[serde(rename = "build", skip_serializing_if = "Option::is_none")] + pub build: Option, + #[serde(rename = "buildTags", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub build_tags: Option>, + #[serde(rename = "tags", deserialize_with = "Option::deserialize")] + pub tags: Option, +} + +impl ActorUpgradeAllActorsRequest { + pub fn new(tags: Option) -> ActorUpgradeAllActorsRequest { + ActorUpgradeAllActorsRequest { + build: None, + build_tags: None, + tags, + } + } +} + + diff --git a/sdks/api/full/rust-cli/src/models/actor_upgrade_all_actors_response.rs b/sdks/api/full/rust-cli/src/models/actor_upgrade_all_actors_response.rs new file mode 100644 index 0000000000..344888fa58 --- /dev/null +++ b/sdks/api/full/rust-cli/src/models/actor_upgrade_all_actors_response.rs @@ -0,0 +1,28 @@ +/* + * Rivet API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ActorUpgradeAllActorsResponse { + #[serde(rename = "count")] + pub count: i64, +} + +impl ActorUpgradeAllActorsResponse { + pub fn new(count: i64) -> ActorUpgradeAllActorsResponse { + ActorUpgradeAllActorsResponse { + count, + } + } +} + + diff --git a/sdks/api/full/rust-cli/src/models/mod.rs b/sdks/api/full/rust-cli/src/models/mod.rs index 5ce68caa4e..2bf903d4a6 100644 --- a/sdks/api/full/rust-cli/src/models/mod.rs +++ b/sdks/api/full/rust-cli/src/models/mod.rs @@ -62,6 +62,10 @@ pub mod actor_runtime; pub use self::actor_runtime::ActorRuntime; pub mod actor_upgrade_actor_request; pub use self::actor_upgrade_actor_request::ActorUpgradeActorRequest; +pub mod actor_upgrade_all_actors_request; +pub use self::actor_upgrade_all_actors_request::ActorUpgradeAllActorsRequest; +pub mod actor_upgrade_all_actors_response; +pub use self::actor_upgrade_all_actors_response::ActorUpgradeAllActorsResponse; pub mod auth_complete_status; pub use self::auth_complete_status::AuthCompleteStatus; pub mod auth_identity_complete_email_verification_request; diff --git a/sdks/api/full/rust/.openapi-generator/FILES b/sdks/api/full/rust/.openapi-generator/FILES index 6c4f2a1ad3..b09f3bce45 100644 --- a/sdks/api/full/rust/.openapi-generator/FILES +++ b/sdks/api/full/rust/.openapi-generator/FILES @@ -39,6 +39,8 @@ docs/ActorRegionsApi.md docs/ActorResources.md docs/ActorRuntime.md docs/ActorUpgradeActorRequest.md +docs/ActorUpgradeAllActorsRequest.md +docs/ActorUpgradeAllActorsResponse.md docs/AuthCompleteStatus.md docs/AuthIdentityCompleteEmailVerificationRequest.md docs/AuthIdentityCompleteEmailVerificationResponse.md @@ -449,6 +451,8 @@ src/models/actor_region.rs src/models/actor_resources.rs src/models/actor_runtime.rs src/models/actor_upgrade_actor_request.rs +src/models/actor_upgrade_all_actors_request.rs +src/models/actor_upgrade_all_actors_response.rs src/models/auth_complete_status.rs src/models/auth_identity_complete_email_verification_request.rs src/models/auth_identity_complete_email_verification_response.rs diff --git a/sdks/api/full/rust/README.md b/sdks/api/full/rust/README.md index 711ee32e03..7bd6b316b6 100644 --- a/sdks/api/full/rust/README.md +++ b/sdks/api/full/rust/README.md @@ -30,6 +30,7 @@ Class | Method | HTTP request | Description *ActorApi* | [**actor_get**](docs/ActorApi.md#actor_get) | **GET** /actors/{actor} | *ActorApi* | [**actor_list**](docs/ActorApi.md#actor_list) | **GET** /actors | *ActorApi* | [**actor_upgrade**](docs/ActorApi.md#actor_upgrade) | **POST** /actors/{actor}/upgrade | +*ActorApi* | [**actor_upgrade_all**](docs/ActorApi.md#actor_upgrade_all) | **POST** /actors/upgrade | *ActorBuildsApi* | [**actor_builds_complete**](docs/ActorBuildsApi.md#actor_builds_complete) | **POST** /builds/{build}/complete | *ActorBuildsApi* | [**actor_builds_get**](docs/ActorBuildsApi.md#actor_builds_get) | **GET** /builds/{build} | *ActorBuildsApi* | [**actor_builds_list**](docs/ActorBuildsApi.md#actor_builds_list) | **GET** /builds | @@ -195,6 +196,8 @@ Class | Method | HTTP request | Description - [ActorResources](docs/ActorResources.md) - [ActorRuntime](docs/ActorRuntime.md) - [ActorUpgradeActorRequest](docs/ActorUpgradeActorRequest.md) + - [ActorUpgradeAllActorsRequest](docs/ActorUpgradeAllActorsRequest.md) + - [ActorUpgradeAllActorsResponse](docs/ActorUpgradeAllActorsResponse.md) - [AuthCompleteStatus](docs/AuthCompleteStatus.md) - [AuthIdentityCompleteEmailVerificationRequest](docs/AuthIdentityCompleteEmailVerificationRequest.md) - [AuthIdentityCompleteEmailVerificationResponse](docs/AuthIdentityCompleteEmailVerificationResponse.md) diff --git a/sdks/api/full/rust/docs/ActorApi.md b/sdks/api/full/rust/docs/ActorApi.md index 6c5e8a3821..c54fe6d3ff 100644 --- a/sdks/api/full/rust/docs/ActorApi.md +++ b/sdks/api/full/rust/docs/ActorApi.md @@ -9,6 +9,7 @@ Method | HTTP request | Description [**actor_get**](ActorApi.md#actor_get) | **GET** /actors/{actor} | [**actor_list**](ActorApi.md#actor_list) | **GET** /actors | [**actor_upgrade**](ActorApi.md#actor_upgrade) | **POST** /actors/{actor}/upgrade | +[**actor_upgrade_all**](ActorApi.md#actor_upgrade_all) | **POST** /actors/upgrade | @@ -175,3 +176,35 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +## actor_upgrade_all + +> crate::models::ActorUpgradeAllActorsResponse actor_upgrade_all(actor_upgrade_all_actors_request, project, environment) + + +Upgrades a dynamic actor. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**actor_upgrade_all_actors_request** | [**ActorUpgradeAllActorsRequest**](ActorUpgradeAllActorsRequest.md) | | [required] | +**project** | Option<**String**> | | | +**environment** | Option<**String**> | | | + +### Return type + +[**crate::models::ActorUpgradeAllActorsResponse**](ActorUpgradeAllActorsResponse.md) + +### Authorization + +[BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/sdks/api/full/rust/docs/ActorUpgradeAllActorsRequest.md b/sdks/api/full/rust/docs/ActorUpgradeAllActorsRequest.md new file mode 100644 index 0000000000..d623c0e764 --- /dev/null +++ b/sdks/api/full/rust/docs/ActorUpgradeAllActorsRequest.md @@ -0,0 +1,13 @@ +# ActorUpgradeAllActorsRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**build** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**build_tags** | Option<[**serde_json::Value**](.md)> | | [optional] +**tags** | Option<[**serde_json::Value**](.md)> | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/sdks/api/full/rust/docs/ActorUpgradeAllActorsResponse.md b/sdks/api/full/rust/docs/ActorUpgradeAllActorsResponse.md new file mode 100644 index 0000000000..eebdd3e19d --- /dev/null +++ b/sdks/api/full/rust/docs/ActorUpgradeAllActorsResponse.md @@ -0,0 +1,11 @@ +# ActorUpgradeAllActorsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**count** | **i64** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/sdks/api/full/rust/src/apis/actor_api.rs b/sdks/api/full/rust/src/apis/actor_api.rs index 9565c1b95b..cbf77cf509 100644 --- a/sdks/api/full/rust/src/apis/actor_api.rs +++ b/sdks/api/full/rust/src/apis/actor_api.rs @@ -78,6 +78,19 @@ pub enum ActorUpgradeError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`actor_upgrade_all`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActorUpgradeAllError { + Status400(crate::models::ErrorBody), + Status403(crate::models::ErrorBody), + Status404(crate::models::ErrorBody), + Status408(crate::models::ErrorBody), + Status429(crate::models::ErrorBody), + Status500(crate::models::ErrorBody), + UnknownValue(serde_json::Value), +} + /// Create a new dynamic actor. pub async fn actor_create( configuration: &configuration::Configuration, @@ -365,3 +378,55 @@ pub async fn actor_upgrade( Err(Error::ResponseError(local_var_error)) } } + +/// Upgrades a dynamic actor. +pub async fn actor_upgrade_all( + configuration: &configuration::Configuration, + actor_upgrade_all_actors_request: crate::models::ActorUpgradeAllActorsRequest, + project: Option<&str>, + environment: Option<&str>, +) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/actors/upgrade", local_var_configuration.base_path); + let mut local_var_req_builder = + local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = project { + local_var_req_builder = + local_var_req_builder.query(&[("project", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = environment { + local_var_req_builder = + local_var_req_builder.query(&[("environment", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = + local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&actor_upgrade_all_actors_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = + serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { + status: local_var_status, + content: local_var_content, + entity: local_var_entity, + }; + Err(Error::ResponseError(local_var_error)) + } +} diff --git a/sdks/api/full/rust/src/models/actor_upgrade_all_actors_request.rs b/sdks/api/full/rust/src/models/actor_upgrade_all_actors_request.rs new file mode 100644 index 0000000000..776a4d9a61 --- /dev/null +++ b/sdks/api/full/rust/src/models/actor_upgrade_all_actors_request.rs @@ -0,0 +1,34 @@ +/* + * Rivet API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ActorUpgradeAllActorsRequest { + #[serde(rename = "build", skip_serializing_if = "Option::is_none")] + pub build: Option, + #[serde( + rename = "buildTags", + default, + with = "::serde_with::rust::double_option", + skip_serializing_if = "Option::is_none" + )] + pub build_tags: Option>, + #[serde(rename = "tags", deserialize_with = "Option::deserialize")] + pub tags: Option, +} + +impl ActorUpgradeAllActorsRequest { + pub fn new(tags: Option) -> ActorUpgradeAllActorsRequest { + ActorUpgradeAllActorsRequest { + build: None, + build_tags: None, + tags, + } + } +} diff --git a/sdks/api/full/rust/src/models/actor_upgrade_all_actors_response.rs b/sdks/api/full/rust/src/models/actor_upgrade_all_actors_response.rs new file mode 100644 index 0000000000..5ade5194c8 --- /dev/null +++ b/sdks/api/full/rust/src/models/actor_upgrade_all_actors_response.rs @@ -0,0 +1,21 @@ +/* + * Rivet API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * + * Generated by: https://openapi-generator.tech + */ + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ActorUpgradeAllActorsResponse { + #[serde(rename = "count")] + pub count: i64, +} + +impl ActorUpgradeAllActorsResponse { + pub fn new(count: i64) -> ActorUpgradeAllActorsResponse { + ActorUpgradeAllActorsResponse { count } + } +} diff --git a/sdks/api/full/rust/src/models/mod.rs b/sdks/api/full/rust/src/models/mod.rs index 5ce68caa4e..2bf903d4a6 100644 --- a/sdks/api/full/rust/src/models/mod.rs +++ b/sdks/api/full/rust/src/models/mod.rs @@ -62,6 +62,10 @@ pub mod actor_runtime; pub use self::actor_runtime::ActorRuntime; pub mod actor_upgrade_actor_request; pub use self::actor_upgrade_actor_request::ActorUpgradeActorRequest; +pub mod actor_upgrade_all_actors_request; +pub use self::actor_upgrade_all_actors_request::ActorUpgradeAllActorsRequest; +pub mod actor_upgrade_all_actors_response; +pub use self::actor_upgrade_all_actors_response::ActorUpgradeAllActorsResponse; pub mod auth_complete_status; pub use self::auth_complete_status::AuthCompleteStatus; pub mod auth_identity_complete_email_verification_request; diff --git a/sdks/api/full/typescript/src/api/resources/actor/client/Client.ts b/sdks/api/full/typescript/src/api/resources/actor/client/Client.ts index 044874c07f..98ab2b6551 100644 --- a/sdks/api/full/typescript/src/api/resources/actor/client/Client.ts +++ b/sdks/api/full/typescript/src/api/resources/actor/client/Client.ts @@ -828,6 +828,163 @@ export class Actor { } } + /** + * Upgrades a dynamic actor. + * + * @param {RivetClient.actor.UpgradeAllActorsRequestQuery} request + * @param {Actor.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link RivetClient.InternalError} + * @throws {@link RivetClient.RateLimitError} + * @throws {@link RivetClient.ForbiddenError} + * @throws {@link RivetClient.UnauthorizedError} + * @throws {@link RivetClient.NotFoundError} + * @throws {@link RivetClient.BadRequestError} + * + * @example + * await client.actor.upgradeAll({ + * project: "string", + * environment: "string", + * body: { + * tags: { + * "key": "value" + * }, + * build: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + * buildTags: { + * "key": "value" + * } + * } + * }) + */ + public async upgradeAll( + request: RivetClient.actor.UpgradeAllActorsRequestQuery, + requestOptions?: Actor.RequestOptions + ): Promise { + const { project, environment, body: _body } = request; + const _queryParams: Record = {}; + if (project != null) { + _queryParams["project"] = project; + } + + if (environment != null) { + _queryParams["environment"] = environment; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.RivetClientEnvironment.Production, + "/actors/upgrade" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + body: serializers.actor.UpgradeAllActorsRequest.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 180000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return serializers.actor.UpgradeAllActorsResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 500: + throw new RivetClient.InternalError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new RivetClient.RateLimitError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 403: + throw new RivetClient.ForbiddenError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 408: + throw new RivetClient.UnauthorizedError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new RivetClient.NotFoundError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 400: + throw new RivetClient.BadRequestError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.RivetClientError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RivetClientError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RivetClientTimeoutError(); + case "unknown": + throw new errors.RivetClientError({ + message: _response.error.errorMessage, + }); + } + } + protected _builds: Builds | undefined; public get builds(): Builds { diff --git a/sdks/api/full/typescript/src/api/resources/actor/client/requests/UpgradeAllActorsRequestQuery.ts b/sdks/api/full/typescript/src/api/resources/actor/client/requests/UpgradeAllActorsRequestQuery.ts new file mode 100644 index 0000000000..be92ebb52d --- /dev/null +++ b/sdks/api/full/typescript/src/api/resources/actor/client/requests/UpgradeAllActorsRequestQuery.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as RivetClient from "../../../../index"; + +/** + * @example + * { + * project: "string", + * environment: "string", + * body: { + * tags: { + * "key": "value" + * }, + * build: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + * buildTags: { + * "key": "value" + * } + * } + * } + */ +export interface UpgradeAllActorsRequestQuery { + project?: string; + environment?: string; + body: RivetClient.actor.UpgradeAllActorsRequest; +} diff --git a/sdks/api/full/typescript/src/api/resources/actor/client/requests/index.ts b/sdks/api/full/typescript/src/api/resources/actor/client/requests/index.ts index 16cd8d026c..8953e26e0c 100644 --- a/sdks/api/full/typescript/src/api/resources/actor/client/requests/index.ts +++ b/sdks/api/full/typescript/src/api/resources/actor/client/requests/index.ts @@ -3,3 +3,4 @@ export { type GetActorsRequestQuery } from "./GetActorsRequestQuery"; export { type CreateActorRequestQuery } from "./CreateActorRequestQuery"; export { type DestroyActorRequestQuery } from "./DestroyActorRequestQuery"; export { type UpgradeActorRequestQuery } from "./UpgradeActorRequestQuery"; +export { type UpgradeAllActorsRequestQuery } from "./UpgradeAllActorsRequestQuery"; diff --git a/sdks/api/runtime/go/actor/actor.go b/sdks/api/runtime/go/actor/actor.go index ae247e2a39..2753b66fd5 100644 --- a/sdks/api/runtime/go/actor/actor.go +++ b/sdks/api/runtime/go/actor/actor.go @@ -217,3 +217,63 @@ func (u *UpgradeActorResponse) String() string { } return fmt.Sprintf("%#v", u) } + +type UpgradeAllActorsRequest struct { + Tags interface{} `json:"tags,omitempty"` + Build *uuid.UUID `json:"build,omitempty"` + BuildTags interface{} `json:"buildTags,omitempty"` + + _rawJSON json.RawMessage +} + +func (u *UpgradeAllActorsRequest) UnmarshalJSON(data []byte) error { + type unmarshaler UpgradeAllActorsRequest + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpgradeAllActorsRequest(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UpgradeAllActorsRequest) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} + +type UpgradeAllActorsResponse struct { + Count int64 `json:"count"` + + _rawJSON json.RawMessage +} + +func (u *UpgradeAllActorsResponse) UnmarshalJSON(data []byte) error { + type unmarshaler UpgradeAllActorsResponse + var value unmarshaler + if err := json.Unmarshal(data, &value); err != nil { + return err + } + *u = UpgradeAllActorsResponse(value) + u._rawJSON = json.RawMessage(data) + return nil +} + +func (u *UpgradeAllActorsResponse) String() string { + if len(u._rawJSON) > 0 { + if value, err := core.StringifyJSON(u._rawJSON); err == nil { + return value + } + } + if value, err := core.StringifyJSON(u); err == nil { + return value + } + return fmt.Sprintf("%#v", u) +} diff --git a/sdks/api/runtime/go/actor/client/client.go b/sdks/api/runtime/go/actor/client/client.go index e5adae2d60..83bfb4caa2 100644 --- a/sdks/api/runtime/go/actor/client/client.go +++ b/sdks/api/runtime/go/actor/client/client.go @@ -509,3 +509,93 @@ func (c *Client) Upgrade(ctx context.Context, actor uuid.UUID, request *sdkactor } return response, nil } + +// Upgrades a dynamic actor. +func (c *Client) UpgradeAll(ctx context.Context, request *sdkactor.UpgradeAllActorsRequestQuery) (*sdkactor.UpgradeAllActorsResponse, error) { + baseURL := "https://api.rivet.gg" + if c.baseURL != "" { + baseURL = c.baseURL + } + endpointURL := baseURL + "/" + "actors/upgrade" + + queryParams := make(url.Values) + if request.Project != nil { + queryParams.Add("project", fmt.Sprintf("%v", *request.Project)) + } + if request.Environment != nil { + queryParams.Add("environment", fmt.Sprintf("%v", *request.Environment)) + } + if len(queryParams) > 0 { + endpointURL += "?" + queryParams.Encode() + } + + errorDecoder := func(statusCode int, body io.Reader) error { + raw, err := io.ReadAll(body) + if err != nil { + return err + } + apiError := core.NewAPIError(statusCode, errors.New(string(raw))) + decoder := json.NewDecoder(bytes.NewReader(raw)) + switch statusCode { + case 500: + value := new(sdk.InternalError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 429: + value := new(sdk.RateLimitError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 403: + value := new(sdk.ForbiddenError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 408: + value := new(sdk.UnauthorizedError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 404: + value := new(sdk.NotFoundError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + case 400: + value := new(sdk.BadRequestError) + value.APIError = apiError + if err := decoder.Decode(value); err != nil { + return apiError + } + return value + } + return apiError + } + + var response *sdkactor.UpgradeAllActorsResponse + if err := c.caller.Call( + ctx, + &core.CallParams{ + URL: endpointURL, + Method: http.MethodPost, + Headers: c.header, + Request: request, + Response: &response, + ErrorDecoder: errorDecoder, + }, + ); err != nil { + return nil, err + } + return response, nil +} diff --git a/sdks/api/runtime/go/actor/types.go b/sdks/api/runtime/go/actor/types.go index 482ff0a647..9359e0961a 100644 --- a/sdks/api/runtime/go/actor/types.go +++ b/sdks/api/runtime/go/actor/types.go @@ -671,3 +671,22 @@ func (u *UpgradeActorRequestQuery) UnmarshalJSON(data []byte) error { func (u *UpgradeActorRequestQuery) MarshalJSON() ([]byte, error) { return json.Marshal(u.Body) } + +type UpgradeAllActorsRequestQuery struct { + Project *string `json:"-"` + Environment *string `json:"-"` + Body *UpgradeAllActorsRequest `json:"-"` +} + +func (u *UpgradeAllActorsRequestQuery) UnmarshalJSON(data []byte) error { + body := new(UpgradeAllActorsRequest) + if err := json.Unmarshal(data, &body); err != nil { + return err + } + u.Body = body + return nil +} + +func (u *UpgradeAllActorsRequestQuery) MarshalJSON() ([]byte, error) { + return json.Marshal(u.Body) +} diff --git a/sdks/api/runtime/openapi/openapi.yml b/sdks/api/runtime/openapi/openapi.yml index eceb9e393e..185e9ab96f 100644 --- a/sdks/api/runtime/openapi/openapi.yml +++ b/sdks/api/runtime/openapi/openapi.yml @@ -368,6 +368,73 @@ paths: application/json: schema: $ref: '#/components/schemas/ActorUpgradeActorRequest' + /actors/upgrade: + post: + description: Upgrades a dynamic actor. + operationId: actor_upgradeAll + tags: + - Actor + parameters: + - name: project + in: query + required: false + schema: + type: string + - name: environment + in: query + required: false + schema: + type: string + responses: + '200': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ActorUpgradeAllActorsResponse' + '400': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '403': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '404': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '408': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '429': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + '500': + description: '' + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + security: *ref_0 + requestBody: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/ActorUpgradeAllActorsRequest' /builds/{build}: get: description: Get a build. @@ -922,6 +989,24 @@ components: ActorUpgradeActorResponse: type: object properties: {} + ActorUpgradeAllActorsRequest: + type: object + properties: + tags: {} + build: + type: string + format: uuid + buildTags: {} + required: + - tags + ActorUpgradeAllActorsResponse: + type: object + properties: + count: + type: integer + format: int64 + required: + - count ActorListActorsResponse: type: object properties: diff --git a/sdks/api/runtime/openapi_compat/openapi.yml b/sdks/api/runtime/openapi_compat/openapi.yml index ff98ea3788..787eecb4f4 100644 --- a/sdks/api/runtime/openapi_compat/openapi.yml +++ b/sdks/api/runtime/openapi_compat/openapi.yml @@ -382,6 +382,24 @@ components: ActorUpgradeActorResponse: properties: {} type: object + ActorUpgradeAllActorsRequest: + properties: + build: + format: uuid + type: string + buildTags: {} + tags: {} + required: + - tags + type: object + ActorUpgradeAllActorsResponse: + properties: + count: + format: int64 + type: integer + required: + - count + type: object ErrorBody: properties: code: @@ -614,6 +632,73 @@ paths: security: *id001 tags: - Actor + /actors/upgrade: + post: + description: Upgrades a dynamic actor. + operationId: actor_upgradeAll + parameters: + - in: query + name: project + required: false + schema: + type: string + - in: query + name: environment + required: false + schema: + type: string + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ActorUpgradeAllActorsRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ActorUpgradeAllActorsResponse' + description: '' + '400': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '403': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '404': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '408': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '429': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + '500': + content: + application/json: + schema: + $ref: '#/components/schemas/ErrorBody' + description: '' + security: *id001 + tags: + - Actor /actors/{actor}: delete: description: Destroy a dynamic actor. diff --git a/sdks/api/runtime/rust/.openapi-generator/FILES b/sdks/api/runtime/rust/.openapi-generator/FILES index 831c1a632e..e2a984c6f6 100644 --- a/sdks/api/runtime/rust/.openapi-generator/FILES +++ b/sdks/api/runtime/rust/.openapi-generator/FILES @@ -39,6 +39,8 @@ docs/ActorRegionsApi.md docs/ActorResources.md docs/ActorRuntime.md docs/ActorUpgradeActorRequest.md +docs/ActorUpgradeAllActorsRequest.md +docs/ActorUpgradeAllActorsResponse.md docs/ErrorBody.md docs/UploadPrepareFile.md docs/UploadPresignedRequest.md @@ -83,6 +85,8 @@ src/models/actor_region.rs src/models/actor_resources.rs src/models/actor_runtime.rs src/models/actor_upgrade_actor_request.rs +src/models/actor_upgrade_all_actors_request.rs +src/models/actor_upgrade_all_actors_response.rs src/models/error_body.rs src/models/mod.rs src/models/upload_prepare_file.rs diff --git a/sdks/api/runtime/rust/README.md b/sdks/api/runtime/rust/README.md index b7c8118dac..0a243aa6b0 100644 --- a/sdks/api/runtime/rust/README.md +++ b/sdks/api/runtime/rust/README.md @@ -30,6 +30,7 @@ Class | Method | HTTP request | Description *ActorApi* | [**actor_get**](docs/ActorApi.md#actor_get) | **GET** /actors/{actor} | *ActorApi* | [**actor_list**](docs/ActorApi.md#actor_list) | **GET** /actors | *ActorApi* | [**actor_upgrade**](docs/ActorApi.md#actor_upgrade) | **POST** /actors/{actor}/upgrade | +*ActorApi* | [**actor_upgrade_all**](docs/ActorApi.md#actor_upgrade_all) | **POST** /actors/upgrade | *ActorBuildsApi* | [**actor_builds_complete**](docs/ActorBuildsApi.md#actor_builds_complete) | **POST** /builds/{build}/complete | *ActorBuildsApi* | [**actor_builds_get**](docs/ActorBuildsApi.md#actor_builds_get) | **GET** /builds/{build} | *ActorBuildsApi* | [**actor_builds_list**](docs/ActorBuildsApi.md#actor_builds_list) | **GET** /builds | @@ -73,6 +74,8 @@ Class | Method | HTTP request | Description - [ActorResources](docs/ActorResources.md) - [ActorRuntime](docs/ActorRuntime.md) - [ActorUpgradeActorRequest](docs/ActorUpgradeActorRequest.md) + - [ActorUpgradeAllActorsRequest](docs/ActorUpgradeAllActorsRequest.md) + - [ActorUpgradeAllActorsResponse](docs/ActorUpgradeAllActorsResponse.md) - [ErrorBody](docs/ErrorBody.md) - [UploadPrepareFile](docs/UploadPrepareFile.md) - [UploadPresignedRequest](docs/UploadPresignedRequest.md) diff --git a/sdks/api/runtime/rust/docs/ActorApi.md b/sdks/api/runtime/rust/docs/ActorApi.md index 6c5e8a3821..c54fe6d3ff 100644 --- a/sdks/api/runtime/rust/docs/ActorApi.md +++ b/sdks/api/runtime/rust/docs/ActorApi.md @@ -9,6 +9,7 @@ Method | HTTP request | Description [**actor_get**](ActorApi.md#actor_get) | **GET** /actors/{actor} | [**actor_list**](ActorApi.md#actor_list) | **GET** /actors | [**actor_upgrade**](ActorApi.md#actor_upgrade) | **POST** /actors/{actor}/upgrade | +[**actor_upgrade_all**](ActorApi.md#actor_upgrade_all) | **POST** /actors/upgrade | @@ -175,3 +176,35 @@ Name | Type | Description | Required | Notes [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + +## actor_upgrade_all + +> crate::models::ActorUpgradeAllActorsResponse actor_upgrade_all(actor_upgrade_all_actors_request, project, environment) + + +Upgrades a dynamic actor. + +### Parameters + + +Name | Type | Description | Required | Notes +------------- | ------------- | ------------- | ------------- | ------------- +**actor_upgrade_all_actors_request** | [**ActorUpgradeAllActorsRequest**](ActorUpgradeAllActorsRequest.md) | | [required] | +**project** | Option<**String**> | | | +**environment** | Option<**String**> | | | + +### Return type + +[**crate::models::ActorUpgradeAllActorsResponse**](ActorUpgradeAllActorsResponse.md) + +### Authorization + +[BearerAuth](../README.md#BearerAuth) + +### HTTP request headers + +- **Content-Type**: application/json +- **Accept**: application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) + diff --git a/sdks/api/runtime/rust/docs/ActorUpgradeAllActorsRequest.md b/sdks/api/runtime/rust/docs/ActorUpgradeAllActorsRequest.md new file mode 100644 index 0000000000..d623c0e764 --- /dev/null +++ b/sdks/api/runtime/rust/docs/ActorUpgradeAllActorsRequest.md @@ -0,0 +1,13 @@ +# ActorUpgradeAllActorsRequest + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**build** | Option<[**uuid::Uuid**](uuid::Uuid.md)> | | [optional] +**build_tags** | Option<[**serde_json::Value**](.md)> | | [optional] +**tags** | Option<[**serde_json::Value**](.md)> | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/sdks/api/runtime/rust/docs/ActorUpgradeAllActorsResponse.md b/sdks/api/runtime/rust/docs/ActorUpgradeAllActorsResponse.md new file mode 100644 index 0000000000..eebdd3e19d --- /dev/null +++ b/sdks/api/runtime/rust/docs/ActorUpgradeAllActorsResponse.md @@ -0,0 +1,11 @@ +# ActorUpgradeAllActorsResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**count** | **i64** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/sdks/api/runtime/rust/src/apis/actor_api.rs b/sdks/api/runtime/rust/src/apis/actor_api.rs index f5130a4de6..329ce72a09 100644 --- a/sdks/api/runtime/rust/src/apis/actor_api.rs +++ b/sdks/api/runtime/rust/src/apis/actor_api.rs @@ -80,6 +80,19 @@ pub enum ActorUpgradeError { UnknownValue(serde_json::Value), } +/// struct for typed errors of method [`actor_upgrade_all`] +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(untagged)] +pub enum ActorUpgradeAllError { + Status400(crate::models::ErrorBody), + Status403(crate::models::ErrorBody), + Status404(crate::models::ErrorBody), + Status408(crate::models::ErrorBody), + Status429(crate::models::ErrorBody), + Status500(crate::models::ErrorBody), + UnknownValue(serde_json::Value), +} + /// Create a new dynamic actor. pub async fn actor_create(configuration: &configuration::Configuration, actor_create_actor_request: crate::models::ActorCreateActorRequest, project: Option<&str>, environment: Option<&str>) -> Result> { @@ -280,3 +293,41 @@ pub async fn actor_upgrade(configuration: &configuration::Configuration, actor: } } +/// Upgrades a dynamic actor. +pub async fn actor_upgrade_all(configuration: &configuration::Configuration, actor_upgrade_all_actors_request: crate::models::ActorUpgradeAllActorsRequest, project: Option<&str>, environment: Option<&str>) -> Result> { + let local_var_configuration = configuration; + + let local_var_client = &local_var_configuration.client; + + let local_var_uri_str = format!("{}/actors/upgrade", local_var_configuration.base_path); + let mut local_var_req_builder = local_var_client.request(reqwest::Method::POST, local_var_uri_str.as_str()); + + if let Some(ref local_var_str) = project { + local_var_req_builder = local_var_req_builder.query(&[("project", &local_var_str.to_string())]); + } + if let Some(ref local_var_str) = environment { + local_var_req_builder = local_var_req_builder.query(&[("environment", &local_var_str.to_string())]); + } + if let Some(ref local_var_user_agent) = local_var_configuration.user_agent { + local_var_req_builder = local_var_req_builder.header(reqwest::header::USER_AGENT, local_var_user_agent.clone()); + } + if let Some(ref local_var_token) = local_var_configuration.bearer_access_token { + local_var_req_builder = local_var_req_builder.bearer_auth(local_var_token.to_owned()); + }; + local_var_req_builder = local_var_req_builder.json(&actor_upgrade_all_actors_request); + + let local_var_req = local_var_req_builder.build()?; + let local_var_resp = local_var_client.execute(local_var_req).await?; + + let local_var_status = local_var_resp.status(); + let local_var_content = local_var_resp.text().await?; + + if !local_var_status.is_client_error() && !local_var_status.is_server_error() { + serde_json::from_str(&local_var_content).map_err(Error::from) + } else { + let local_var_entity: Option = serde_json::from_str(&local_var_content).ok(); + let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity }; + Err(Error::ResponseError(local_var_error)) + } +} + diff --git a/sdks/api/runtime/rust/src/models/actor_upgrade_all_actors_request.rs b/sdks/api/runtime/rust/src/models/actor_upgrade_all_actors_request.rs new file mode 100644 index 0000000000..ebaff39fa7 --- /dev/null +++ b/sdks/api/runtime/rust/src/models/actor_upgrade_all_actors_request.rs @@ -0,0 +1,34 @@ +/* + * Rivet API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ActorUpgradeAllActorsRequest { + #[serde(rename = "build", skip_serializing_if = "Option::is_none")] + pub build: Option, + #[serde(rename = "buildTags", default, with = "::serde_with::rust::double_option", skip_serializing_if = "Option::is_none")] + pub build_tags: Option>, + #[serde(rename = "tags", deserialize_with = "Option::deserialize")] + pub tags: Option, +} + +impl ActorUpgradeAllActorsRequest { + pub fn new(tags: Option) -> ActorUpgradeAllActorsRequest { + ActorUpgradeAllActorsRequest { + build: None, + build_tags: None, + tags, + } + } +} + + diff --git a/sdks/api/runtime/rust/src/models/actor_upgrade_all_actors_response.rs b/sdks/api/runtime/rust/src/models/actor_upgrade_all_actors_response.rs new file mode 100644 index 0000000000..344888fa58 --- /dev/null +++ b/sdks/api/runtime/rust/src/models/actor_upgrade_all_actors_response.rs @@ -0,0 +1,28 @@ +/* + * Rivet API + * + * No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) + * + * The version of the OpenAPI document: 0.0.1 + * + * Generated by: https://openapi-generator.tech + */ + + + + +#[derive(Clone, Debug, PartialEq, Default, Serialize, Deserialize)] +pub struct ActorUpgradeAllActorsResponse { + #[serde(rename = "count")] + pub count: i64, +} + +impl ActorUpgradeAllActorsResponse { + pub fn new(count: i64) -> ActorUpgradeAllActorsResponse { + ActorUpgradeAllActorsResponse { + count, + } + } +} + + diff --git a/sdks/api/runtime/rust/src/models/mod.rs b/sdks/api/runtime/rust/src/models/mod.rs index a893c21add..efd72938a5 100644 --- a/sdks/api/runtime/rust/src/models/mod.rs +++ b/sdks/api/runtime/rust/src/models/mod.rs @@ -62,6 +62,10 @@ pub mod actor_runtime; pub use self::actor_runtime::ActorRuntime; pub mod actor_upgrade_actor_request; pub use self::actor_upgrade_actor_request::ActorUpgradeActorRequest; +pub mod actor_upgrade_all_actors_request; +pub use self::actor_upgrade_all_actors_request::ActorUpgradeAllActorsRequest; +pub mod actor_upgrade_all_actors_response; +pub use self::actor_upgrade_all_actors_response::ActorUpgradeAllActorsResponse; pub mod error_body; pub use self::error_body::ErrorBody; pub mod upload_prepare_file; diff --git a/sdks/api/runtime/typescript/src/api/resources/actor/client/Client.ts b/sdks/api/runtime/typescript/src/api/resources/actor/client/Client.ts index 6ba24388b8..27ada30cea 100644 --- a/sdks/api/runtime/typescript/src/api/resources/actor/client/Client.ts +++ b/sdks/api/runtime/typescript/src/api/resources/actor/client/Client.ts @@ -828,6 +828,163 @@ export class Actor { } } + /** + * Upgrades a dynamic actor. + * + * @param {RivetClient.actor.UpgradeAllActorsRequestQuery} request + * @param {Actor.RequestOptions} requestOptions - Request-specific configuration. + * + * @throws {@link RivetClient.InternalError} + * @throws {@link RivetClient.RateLimitError} + * @throws {@link RivetClient.ForbiddenError} + * @throws {@link RivetClient.UnauthorizedError} + * @throws {@link RivetClient.NotFoundError} + * @throws {@link RivetClient.BadRequestError} + * + * @example + * await client.actor.upgradeAll({ + * project: "string", + * environment: "string", + * body: { + * tags: { + * "key": "value" + * }, + * build: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + * buildTags: { + * "key": "value" + * } + * } + * }) + */ + public async upgradeAll( + request: RivetClient.actor.UpgradeAllActorsRequestQuery, + requestOptions?: Actor.RequestOptions + ): Promise { + const { project, environment, body: _body } = request; + const _queryParams: Record = {}; + if (project != null) { + _queryParams["project"] = project; + } + + if (environment != null) { + _queryParams["environment"] = environment; + } + + const _response = await (this._options.fetcher ?? core.fetcher)({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.RivetClientEnvironment.Production, + "/actors/upgrade" + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-Runtime": core.RUNTIME.type, + "X-Fern-Runtime-Version": core.RUNTIME.version, + }, + contentType: "application/json", + queryParameters: _queryParams, + requestType: "json", + body: serializers.actor.UpgradeAllActorsRequest.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 180000, + maxRetries: requestOptions?.maxRetries, + abortSignal: requestOptions?.abortSignal, + }); + if (_response.ok) { + return serializers.actor.UpgradeAllActorsResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 500: + throw new RivetClient.InternalError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 429: + throw new RivetClient.RateLimitError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 403: + throw new RivetClient.ForbiddenError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 408: + throw new RivetClient.UnauthorizedError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 404: + throw new RivetClient.NotFoundError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + case 400: + throw new RivetClient.BadRequestError( + serializers.ErrorBody.parseOrThrow(_response.error.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + skipValidation: true, + breadcrumbsPrefix: ["response"], + }) + ); + default: + throw new errors.RivetClientError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RivetClientError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RivetClientTimeoutError(); + case "unknown": + throw new errors.RivetClientError({ + message: _response.error.errorMessage, + }); + } + } + protected _builds: Builds | undefined; public get builds(): Builds { diff --git a/sdks/api/runtime/typescript/src/api/resources/actor/client/requests/UpgradeAllActorsRequestQuery.ts b/sdks/api/runtime/typescript/src/api/resources/actor/client/requests/UpgradeAllActorsRequestQuery.ts new file mode 100644 index 0000000000..be92ebb52d --- /dev/null +++ b/sdks/api/runtime/typescript/src/api/resources/actor/client/requests/UpgradeAllActorsRequestQuery.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as RivetClient from "../../../../index"; + +/** + * @example + * { + * project: "string", + * environment: "string", + * body: { + * tags: { + * "key": "value" + * }, + * build: "d5e9c84f-c2b2-4bf4-b4b0-7ffd7a9ffc32", + * buildTags: { + * "key": "value" + * } + * } + * } + */ +export interface UpgradeAllActorsRequestQuery { + project?: string; + environment?: string; + body: RivetClient.actor.UpgradeAllActorsRequest; +} diff --git a/sdks/api/runtime/typescript/src/api/resources/actor/client/requests/index.ts b/sdks/api/runtime/typescript/src/api/resources/actor/client/requests/index.ts index 16cd8d026c..8953e26e0c 100644 --- a/sdks/api/runtime/typescript/src/api/resources/actor/client/requests/index.ts +++ b/sdks/api/runtime/typescript/src/api/resources/actor/client/requests/index.ts @@ -3,3 +3,4 @@ export { type GetActorsRequestQuery } from "./GetActorsRequestQuery"; export { type CreateActorRequestQuery } from "./CreateActorRequestQuery"; export { type DestroyActorRequestQuery } from "./DestroyActorRequestQuery"; export { type UpgradeActorRequestQuery } from "./UpgradeActorRequestQuery"; +export { type UpgradeAllActorsRequestQuery } from "./UpgradeAllActorsRequestQuery";