Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/converters/_sandboxenvironments_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,29 @@ export function listAgentEngineSandboxesRequestParametersToVertex(

return toObject;
}

export function pauseAgentEngineSandboxRequestParametersToVertex(
fromObject: types.PauseAgentEngineSandboxRequestParameters,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

const fromName = common.getValueByPath(fromObject, ['name']);
if (fromName != null) {
common.setValueByPath(toObject, ['_url', 'name'], fromName);
}

return toObject;
}

export function resumeAgentEngineSandboxRequestParametersToVertex(
fromObject: types.ResumeAgentEngineSandboxRequestParameters,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

const fromName = common.getValueByPath(fromObject, ['name']);
if (fromName != null) {
common.setValueByPath(toObject, ['_url', 'name'], fromName);
}

return toObject;
}
26 changes: 26 additions & 0 deletions src/converters/_sandboxes_converters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,29 @@ export function listAgentEngineSandboxesRequestParametersToVertex(

return toObject;
}

export function pauseAgentEngineSandboxRequestParametersToVertex(
fromObject: types.PauseAgentEngineSandboxRequestParameters,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

const fromName = common.getValueByPath(fromObject, ['name']);
if (fromName != null) {
common.setValueByPath(toObject, ['_url', 'name'], fromName);
}

return toObject;
}

export function resumeAgentEngineSandboxRequestParametersToVertex(
fromObject: types.ResumeAgentEngineSandboxRequestParameters,
): Record<string, unknown> {
const toObject: Record<string, unknown> = {};

const fromName = common.getValueByPath(fromObject, ['name']);
if (fromName != null) {
common.setValueByPath(toObject, ['_url', 'name'], fromName);
}

return toObject;
}
84 changes: 84 additions & 0 deletions src/sandboxenvironments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -344,4 +344,88 @@ export class SandboxEnvironments extends BaseModule {
);
}
}

async pauseInternal(
params: types.PauseAgentEngineSandboxRequestParameters,
): Promise<types.AgentEngineSandboxOperation> {
let response: Promise<types.AgentEngineSandboxOperation>;

let path: string = '';
let queryParams: Record<string, string> = {};
if (this.apiClient.isVertexAI()) {
const body =
converters.pauseAgentEngineSandboxRequestParametersToVertex(params);
path = common.formatMap(
'{name}/:pause',
body['_url'] as Record<string, unknown>,
);
queryParams = body['_query'] as Record<string, string>;
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<types.AgentEngineSandboxOperation>;

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<types.AgentEngineSandboxOperation> {
let response: Promise<types.AgentEngineSandboxOperation>;

let path: string = '';
let queryParams: Record<string, string> = {};
if (this.apiClient.isVertexAI()) {
const body =
converters.resumeAgentEngineSandboxRequestParametersToVertex(params);
path = common.formatMap(
'{name}/:resume',
body['_url'] as Record<string, unknown>,
);
queryParams = body['_query'] as Record<string, string>;
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<types.AgentEngineSandboxOperation>;

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).',
);
}
}
}
84 changes: 84 additions & 0 deletions src/sandboxes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,4 +354,88 @@ export class Sandboxes extends BaseModule {
);
}
}

async pauseInternal(
params: types.PauseAgentEngineSandboxRequestParameters,
): Promise<types.AgentEngineSandboxOperation> {
let response: Promise<types.AgentEngineSandboxOperation>;

let path: string = '';
let queryParams: Record<string, string> = {};
if (this.apiClient.isVertexAI()) {
const body =
converters.pauseAgentEngineSandboxRequestParametersToVertex(params);
path = common.formatMap(
'{name}/:pause',
body['_url'] as Record<string, unknown>,
);
queryParams = body['_query'] as Record<string, string>;
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<types.AgentEngineSandboxOperation>;

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<types.AgentEngineSandboxOperation> {
let response: Promise<types.AgentEngineSandboxOperation>;

let path: string = '';
let queryParams: Record<string, string> = {};
if (this.apiClient.isVertexAI()) {
const body =
converters.resumeAgentEngineSandboxRequestParametersToVertex(params);
path = common.formatMap(
'{name}/:resume',
body['_url'] as Record<string, unknown>,
);
queryParams = body['_query'] as Record<string, string>;
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<types.AgentEngineSandboxOperation>;

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).',
);
}
}
}
44 changes: 44 additions & 0 deletions src/types/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Loading