Skip to content

Commit

Permalink
docs: minor updates in comments (#3687)
Browse files Browse the repository at this point in the history
* docs: minor updates in comments

PiperOrigin-RevId: 491785685

Source-Link: googleapis/googleapis@e8bd0c4

Source-Link: googleapis/googleapis-gen@9691e0c
Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLXRwdS8uT3dsQm90LnlhbWwiLCJoIjoiOTY5MWUwY2M5OTFhNmUwNDgzNDkyYTJmZDZkODlkZGMxOTJlNjIyMyJ9

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: sofisl <[email protected]>
  • Loading branch information
3 people authored Nov 30, 2022
1 parent 6b2c4d1 commit 9d40b8e
Show file tree
Hide file tree
Showing 4 changed files with 779 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Google LLC
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -88,7 +88,7 @@ service Tpu {
};
}

// Stops a node.
// Stops a node, this operation is only available with single TPU nodes.
rpc StopNode(StopNodeRequest) returns (google.longrunning.Operation) {
option (google.api.http) = {
post: "/v1/{name=projects/*/locations/*/nodes/*}:stop"
Expand Down Expand Up @@ -178,7 +178,7 @@ message Node {
// TPU node is being created.
CREATING = 1;

// TPU node has been created and is fully usable.
// TPU node has been created.
READY = 2;

// TPU node is restarting.
Expand Down Expand Up @@ -550,11 +550,6 @@ message ListAcceleratorTypesResponse {
repeated string unreachable = 3;
}

// Note: the following OperationMetadata message was added manually.
// This is caused by a conflict with some other message and will
// be resolved separately. Please make sure to add this message back
// if it's removed during public proto regeneration.

// Metadata describing an [Operation][google.longrunning.Operation]
message OperationMetadata {
// The time the operation was created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
"regionTag": "tpu_v1_generated_Tpu_StopNode_async",
"title": "Tpu stopNode Sample",
"origin": "API_DEFINITION",
"description": " Stops a node.",
"description": " Stops a node, this operation is only available with single TPU nodes.",
"canonical": true,
"file": "tpu.stop_node.js",
"language": "JAVASCRIPT",
Expand Down
267 changes: 266 additions & 1 deletion packages/google-cloud-tpu/src/v1/tpu_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import type {
LROperation,
PaginationCallback,
GaxCall,
LocationsClient,
LocationProtos,
} from 'google-gax';
import {Transform} from 'stream';
import * as protos from '../../protos/protos';
Expand Down Expand Up @@ -63,6 +65,7 @@ export class TpuClient {
};
warn: (code: string, message: string, warnType?: string) => void;
innerApiCalls: {[name: string]: Function};
locationsClient: LocationsClient;
pathTemplates: {[name: string]: gax.PathTemplate};
operationsClient: gax.OperationsClient;
tpuStub?: Promise<{[name: string]: Function}>;
Expand Down Expand Up @@ -157,6 +160,10 @@ export class TpuClient {
if (servicePath === staticMembers.servicePath) {
this.auth.defaultScopes = staticMembers.scopes;
}
this.locationsClient = new this._gaxModule.LocationsClient(
this._gaxGrpc,
opts
);

// Determine the client header string.
const clientHeader = [`gax/${this._gaxModule.version}`, `gapic/${version}`];
Expand Down Expand Up @@ -1145,7 +1152,7 @@ export class TpuClient {
>;
}
/**
* Stops a node.
* Stops a node, this operation is only available with single TPU nodes.
*
* @param {Object} request
* The request object that will be sent.
Expand Down Expand Up @@ -2007,6 +2014,263 @@ export class TpuClient {
callSettings
) as AsyncIterable<protos.google.cloud.tpu.v1.IAcceleratorType>;
}
/**
* Gets information about a location.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* Resource name for the location.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [Location]{@link google.cloud.location.Location}.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods)
* for more details and examples.
* @example
* ```
* const [response] = await client.getLocation(request);
* ```
*/
getLocation(
request: LocationProtos.google.cloud.location.IGetLocationRequest,
options?:
| gax.CallOptions
| Callback<
LocationProtos.google.cloud.location.ILocation,
| LocationProtos.google.cloud.location.IGetLocationRequest
| null
| undefined,
{} | null | undefined
>,
callback?: Callback<
LocationProtos.google.cloud.location.ILocation,
| LocationProtos.google.cloud.location.IGetLocationRequest
| null
| undefined,
{} | null | undefined
>
): Promise<LocationProtos.google.cloud.location.ILocation> {
return this.locationsClient.getLocation(request, options, callback);
}

/**
* Lists information about the supported locations for this service. Returns an iterable object.
*
* `for`-`await`-`of` syntax is used with the iterable to get response elements on-demand.
* @param {Object} request
* The request object that will be sent.
* @param {string} request.name
* The resource that owns the locations collection, if applicable.
* @param {string} request.filter
* The standard list filter.
* @param {number} request.pageSize
* The standard list page size.
* @param {string} request.pageToken
* The standard list page token.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that allows [async iteration](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols).
* When you iterate the returned iterable, each element will be an object representing
* [Location]{@link google.cloud.location.Location}. The API will be called under the hood as needed, once per the page,
* so you can stop the iteration when you don't need more results.
* Please see the
* [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#auto-pagination)
* for more details and examples.
* @example
* ```
* const iterable = client.listLocationsAsync(request);
* for await (const response of iterable) {
* // process response
* }
* ```
*/
listLocationsAsync(
request: LocationProtos.google.cloud.location.IListLocationsRequest,
options?: CallOptions
): AsyncIterable<LocationProtos.google.cloud.location.ILocation> {
return this.locationsClient.listLocationsAsync(request, options);
}

/**
* Gets the latest state of a long-running operation. Clients can use this
* method to poll the operation result at intervals as recommended by the API
* service.
*
* @param {Object} request - The request object that will be sent.
* @param {string} request.name - The name of the operation resource.
* @param {Object=} options
* Optional parameters. You can override the default settings for this call,
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
* details.
* @param {function(?Error, ?Object)=} callback
* The function which will be called with the result of the API call.
*
* The second parameter to the callback is an object representing
* [google.longrunning.Operation]{@link
* external:"google.longrunning.Operation"}.
* @return {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing
* [google.longrunning.Operation]{@link
* external:"google.longrunning.Operation"}. The promise has a method named
* "cancel" which cancels the ongoing API call.
*
* @example
* ```
* const client = longrunning.operationsClient();
* const name = '';
* const [response] = await client.getOperation({name});
* // doThingsWith(response)
* ```
*/
getOperation(
request: protos.google.longrunning.GetOperationRequest,
options?:
| gax.CallOptions
| Callback<
protos.google.longrunning.Operation,
protos.google.longrunning.GetOperationRequest,
{} | null | undefined
>,
callback?: Callback<
protos.google.longrunning.Operation,
protos.google.longrunning.GetOperationRequest,
{} | null | undefined
>
): Promise<[protos.google.longrunning.Operation]> {
return this.operationsClient.getOperation(request, options, callback);
}
/**
* Lists operations that match the specified filter in the request. If the
* server doesn't support this method, it returns `UNIMPLEMENTED`. Returns an iterable object.
*
* For-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request - The request object that will be sent.
* @param {string} request.name - The name of the operation collection.
* @param {string} request.filter - The standard list filter.
* @param {number=} request.pageSize -
* The maximum number of resources contained in the underlying API
* response. If page streaming is performed per-resource, this
* parameter does not affect the return value. If page streaming is
* performed per-page, this determines the maximum number of
* resources in a page.
* @param {Object=} options
* Optional parameters. You can override the default settings for this call,
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
* details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*
* @example
* ```
* const client = longrunning.operationsClient();
* for await (const response of client.listOperationsAsync(request));
* // doThingsWith(response)
* ```
*/
listOperationsAsync(
request: protos.google.longrunning.ListOperationsRequest,
options?: gax.CallOptions
): AsyncIterable<protos.google.longrunning.ListOperationsResponse> {
return this.operationsClient.listOperationsAsync(request, options);
}
/**
* Starts asynchronous cancellation on a long-running operation. The server
* makes a best effort to cancel the operation, but success is not
* guaranteed. If the server doesn't support this method, it returns
* `google.rpc.Code.UNIMPLEMENTED`. Clients can use
* {@link Operations.GetOperation} or
* other methods to check whether the cancellation succeeded or whether the
* operation completed despite cancellation. On successful cancellation,
* the operation is not deleted; instead, it becomes an operation with
* an {@link Operation.error} value with a {@link google.rpc.Status.code} of
* 1, corresponding to `Code.CANCELLED`.
*
* @param {Object} request - The request object that will be sent.
* @param {string} request.name - The name of the operation resource to be cancelled.
* @param {Object=} options
* Optional parameters. You can override the default settings for this call,
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
* details.
* @param {function(?Error)=} callback
* The function which will be called with the result of the API call.
* @return {Promise} - The promise which resolves when API call finishes.
* The promise has a method named "cancel" which cancels the ongoing API
* call.
*
* @example
* ```
* const client = longrunning.operationsClient();
* await client.cancelOperation({name: ''});
* ```
*/
cancelOperation(
request: protos.google.longrunning.CancelOperationRequest,
options?:
| gax.CallOptions
| Callback<
protos.google.protobuf.Empty,
protos.google.longrunning.CancelOperationRequest,
{} | undefined | null
>,
callback?: Callback<
protos.google.longrunning.CancelOperationRequest,
protos.google.protobuf.Empty,
{} | undefined | null
>
): Promise<protos.google.protobuf.Empty> {
return this.operationsClient.cancelOperation(request, options, callback);
}

/**
* Deletes a long-running operation. This method indicates that the client is
* no longer interested in the operation result. It does not cancel the
* operation. If the server doesn't support this method, it returns
* `google.rpc.Code.UNIMPLEMENTED`.
*
* @param {Object} request - The request object that will be sent.
* @param {string} request.name - The name of the operation resource to be deleted.
* @param {Object=} options
* Optional parameters. You can override the default settings for this call,
* e.g, timeout, retries, paginations, etc. See [gax.CallOptions]{@link
* https://googleapis.github.io/gax-nodejs/global.html#CallOptions} for the
* details.
* @param {function(?Error)=} callback
* The function which will be called with the result of the API call.
* @return {Promise} - The promise which resolves when API call finishes.
* The promise has a method named "cancel" which cancels the ongoing API
* call.
*
* @example
* ```
* const client = longrunning.operationsClient();
* await client.deleteOperation({name: ''});
* ```
*/
deleteOperation(
request: protos.google.longrunning.DeleteOperationRequest,
options?:
| gax.CallOptions
| Callback<
protos.google.protobuf.Empty,
protos.google.longrunning.DeleteOperationRequest,
{} | null | undefined
>,
callback?: Callback<
protos.google.protobuf.Empty,
protos.google.longrunning.DeleteOperationRequest,
{} | null | undefined
>
): Promise<protos.google.protobuf.Empty> {
return this.operationsClient.deleteOperation(request, options, callback);
}

// --------------------
// -- Path templates --
// --------------------
Expand Down Expand Up @@ -2250,6 +2514,7 @@ export class TpuClient {
return this.tpuStub.then(stub => {
this._terminated = true;
stub.close();
this.locationsClient.close();
this.operationsClient.close();
});
}
Expand Down
Loading

0 comments on commit 9d40b8e

Please sign in to comment.