diff --git a/src/converters/_sandboxenvironments_converters.ts b/src/converters/_sandboxenvironments_converters.ts index 810641b8..78b8404c 100644 --- a/src/converters/_sandboxenvironments_converters.ts +++ b/src/converters/_sandboxenvironments_converters.ts @@ -193,3 +193,29 @@ export function listAgentEngineSandboxesRequestParametersToVertex( return toObject; } + +export function pauseAgentEngineSandboxRequestParametersToVertex( + fromObject: types.PauseAgentEngineSandboxRequestParameters, +): Record { + const toObject: Record = {}; + + const fromName = common.getValueByPath(fromObject, ['name']); + if (fromName != null) { + common.setValueByPath(toObject, ['_url', 'name'], fromName); + } + + return toObject; +} + +export function resumeAgentEngineSandboxRequestParametersToVertex( + fromObject: types.ResumeAgentEngineSandboxRequestParameters, +): Record { + const toObject: Record = {}; + + const fromName = common.getValueByPath(fromObject, ['name']); + if (fromName != null) { + common.setValueByPath(toObject, ['_url', 'name'], fromName); + } + + return toObject; +} diff --git a/src/converters/_sandboxes_converters.ts b/src/converters/_sandboxes_converters.ts index 810641b8..78b8404c 100644 --- a/src/converters/_sandboxes_converters.ts +++ b/src/converters/_sandboxes_converters.ts @@ -193,3 +193,29 @@ export function listAgentEngineSandboxesRequestParametersToVertex( return toObject; } + +export function pauseAgentEngineSandboxRequestParametersToVertex( + fromObject: types.PauseAgentEngineSandboxRequestParameters, +): Record { + const toObject: Record = {}; + + const fromName = common.getValueByPath(fromObject, ['name']); + if (fromName != null) { + common.setValueByPath(toObject, ['_url', 'name'], fromName); + } + + return toObject; +} + +export function resumeAgentEngineSandboxRequestParametersToVertex( + fromObject: types.ResumeAgentEngineSandboxRequestParameters, +): Record { + const toObject: Record = {}; + + const fromName = common.getValueByPath(fromObject, ['name']); + if (fromName != null) { + common.setValueByPath(toObject, ['_url', 'name'], fromName); + } + + return toObject; +} diff --git a/src/sandboxenvironments.ts b/src/sandboxenvironments.ts index 66a51af7..7012146c 100644 --- a/src/sandboxenvironments.ts +++ b/src/sandboxenvironments.ts @@ -344,4 +344,88 @@ export class SandboxEnvironments extends BaseModule { ); } } + + async pauseInternal( + params: types.PauseAgentEngineSandboxRequestParameters, + ): Promise { + let response: Promise; + + let path: string = ''; + let queryParams: Record = {}; + if (this.apiClient.isVertexAI()) { + const body = + converters.pauseAgentEngineSandboxRequestParametersToVertex(params); + path = common.formatMap( + '{name}/:pause', + body['_url'] as Record, + ); + queryParams = body['_query'] as Record; + delete body['_url']; + delete body['_query']; + delete body['config']; + + response = this.apiClient + .request({ + path: path, + queryParams: queryParams, + body: JSON.stringify(body), + httpMethod: 'POST', + httpOptions: params.config?.httpOptions, + abortSignal: params.config?.abortSignal, + }) + .then((httpResponse) => { + return httpResponse.json(); + }) as Promise; + + return response.then((resp) => { + return resp as types.AgentEngineSandboxOperation; + }); + } else { + throw new Error( + 'This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).', + ); + } + } + + async resumeInternal( + params: types.ResumeAgentEngineSandboxRequestParameters, + ): Promise { + let response: Promise; + + let path: string = ''; + let queryParams: Record = {}; + if (this.apiClient.isVertexAI()) { + const body = + converters.resumeAgentEngineSandboxRequestParametersToVertex(params); + path = common.formatMap( + '{name}/:resume', + body['_url'] as Record, + ); + queryParams = body['_query'] as Record; + delete body['_url']; + delete body['_query']; + delete body['config']; + + response = this.apiClient + .request({ + path: path, + queryParams: queryParams, + body: JSON.stringify(body), + httpMethod: 'POST', + httpOptions: params.config?.httpOptions, + abortSignal: params.config?.abortSignal, + }) + .then((httpResponse) => { + return httpResponse.json(); + }) as Promise; + + return response.then((resp) => { + return resp as types.AgentEngineSandboxOperation; + }); + } else { + throw new Error( + 'This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).', + ); + } + } } diff --git a/src/sandboxes.ts b/src/sandboxes.ts index 28bd1aee..f80ce0bb 100644 --- a/src/sandboxes.ts +++ b/src/sandboxes.ts @@ -354,4 +354,88 @@ export class Sandboxes extends BaseModule { ); } } + + async pauseInternal( + params: types.PauseAgentEngineSandboxRequestParameters, + ): Promise { + let response: Promise; + + let path: string = ''; + let queryParams: Record = {}; + if (this.apiClient.isVertexAI()) { + const body = + converters.pauseAgentEngineSandboxRequestParametersToVertex(params); + path = common.formatMap( + '{name}/:pause', + body['_url'] as Record, + ); + queryParams = body['_query'] as Record; + delete body['_url']; + delete body['_query']; + delete body['config']; + + response = this.apiClient + .request({ + path: path, + queryParams: queryParams, + body: JSON.stringify(body), + httpMethod: 'POST', + httpOptions: params.config?.httpOptions, + abortSignal: params.config?.abortSignal, + }) + .then((httpResponse) => { + return httpResponse.json(); + }) as Promise; + + return response.then((resp) => { + return resp as types.AgentEngineSandboxOperation; + }); + } else { + throw new Error( + 'This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).', + ); + } + } + + async resumeInternal( + params: types.ResumeAgentEngineSandboxRequestParameters, + ): Promise { + let response: Promise; + + let path: string = ''; + let queryParams: Record = {}; + if (this.apiClient.isVertexAI()) { + const body = + converters.resumeAgentEngineSandboxRequestParametersToVertex(params); + path = common.formatMap( + '{name}/:resume', + body['_url'] as Record, + ); + queryParams = body['_query'] as Record; + delete body['_url']; + delete body['_query']; + delete body['config']; + + response = this.apiClient + .request({ + path: path, + queryParams: queryParams, + body: JSON.stringify(body), + httpMethod: 'POST', + httpOptions: params.config?.httpOptions, + abortSignal: params.config?.abortSignal, + }) + .then((httpResponse) => { + return httpResponse.json(); + }) as Promise; + + return response.then((resp) => { + return resp as types.AgentEngineSandboxOperation; + }); + } else { + throw new Error( + 'This method is only supported by the Gemini Enterprise Agent Platform (previously known as Vertex AI).', + ); + } + } } diff --git a/src/types/common.ts b/src/types/common.ts index d3f1047e..1a08bb0b 100644 --- a/src/types/common.ts +++ b/src/types/common.ts @@ -2533,6 +2533,50 @@ export declare interface GetAgentEngineSandboxOperationParameters { config?: GetAgentEngineOperationConfig; } +/** Config for pausing an Agent Engine sandbox. */ +export declare interface PauseAgentEngineSandboxConfig { + /** Used to override HTTP request options. */ + httpOptions?: genaiTypes.HttpOptions; + /** Abort signal which can be used to cancel the request. + + NOTE: AbortSignal is a client-only operation. Using it to cancel an + operation will not cancel the request in the service. You will still + be charged usage for any applicable operations. + */ + abortSignal?: AbortSignal; + /** Waits for the operation to complete before returning. */ + waitForCompletion?: boolean; +} + +/** Parameters for pausing an Agent Engine sandbox. */ +export declare interface PauseAgentEngineSandboxRequestParameters { + /** Name of the agent engine sandbox to pause. */ + name: string; + config?: PauseAgentEngineSandboxConfig; +} + +/** Config for resuming an Agent Engine sandbox. */ +export declare interface ResumeAgentEngineSandboxConfig { + /** Used to override HTTP request options. */ + httpOptions?: genaiTypes.HttpOptions; + /** Abort signal which can be used to cancel the request. + + NOTE: AbortSignal is a client-only operation. Using it to cancel an + operation will not cancel the request in the service. You will still + be charged usage for any applicable operations. + */ + abortSignal?: AbortSignal; + /** Waits for the operation to complete before returning. */ + waitForCompletion?: boolean; +} + +/** Parameters for resuming an Agent Engine sandbox. */ +export declare interface ResumeAgentEngineSandboxRequestParameters { + /** Name of the agent engine sandbox to resume. */ + name: string; + config?: ResumeAgentEngineSandboxConfig; +} + /** Specification for deploying from a custom container image. */ export declare interface SandboxEnvironmentTemplateCustomContainerSpec { /** Required. The Artifact Registry Docker image URI (e.g., us-central1-docker.pkg.dev/my-project/my-repo/my-image:tag) of the container image that is to be run on each worker replica. */