Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support diregapic LRO #1150

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
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

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
// Copyright 2021 Google LLC.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// This file contains custom annotations that are used by GAPIC generators to
// handle Long Running Operation methods (LRO) that are NOT compliant with
// https://google.aip.dev/151. These annotations are public for technical
// reasons only. Please DO NOT USE them in your protos.
syntax = "proto3";

package google.cloud;

import "google/protobuf/descriptor.proto";

option go_package = "google.golang.org/genproto/googleapis/cloud/extendedops;extendedops";
option java_multiple_files = true;
option java_outer_classname = "ExtendedOperationsProto";
option java_package = "com.google.cloud";
option objc_class_prefix = "GAPI";

// FieldOptions to match corresponding fields in the initial request,
// polling request and operation response messages.
//
// Example:
//
// In an API-specific operation message:
//
// message MyOperation {
// string http_error_message = 1 [(operation_field) = ERROR_MESSAGE];
// int32 http_error_status_code = 2 [(operation_field) = ERROR_CODE];
// string id = 3 [(operation_field) = NAME];
// Status status = 4 [(operation_field) = STATUS];
// }
//
// In a polling request message (the one which is used to poll for an LRO
// status):
//
// message MyPollingRequest {
// string operation = 1 [(operation_response_field) = "id"];
// string project = 2;
// string region = 3;
// }
//
// In an initial request message (the one which starts an LRO):
//
// message MyInitialRequest {
// string my_project = 2 [(operation_request_field) = "project"];
// string my_region = 3 [(operation_request_field) = "region"];
// }
//
extend google.protobuf.FieldOptions {
// A field annotation that maps fields in an API-specific Operation object to
// their standard counterparts in google.longrunning.Operation. See
// OperationResponseMapping enum definition.
OperationResponseMapping operation_field = 1149;

// A field annotation that maps fields in the initial request message
// (the one which started the LRO) to their counterparts in the polling
// request message. For non-standard LRO, the polling response may be missing
// some of the information needed to make a subsequent polling request. The
// missing information (for example, project or region ID) is contained in the
// fields of the initial request message that this annotation must be applied
// to. The string value of the annotation corresponds to the name of the
// counterpart field in the polling request message that the annotated field's
// value will be copied to.
string operation_request_field = 1150;

// A field annotation that maps fields in the polling request message to their
// counterparts in the initial and/or polling response message. The initial
// and the polling methods return an API-specific Operation object. Some of
// the fields from that response object must be reused in the subsequent
// request (like operation name/ID) to fully identify the polled operation.
// This annotation must be applied to the fields in the polling request
// message, the string value of the annotation must correspond to the name of
// the counterpart field in the Operation response object whose value will be
// copied to the annotated field.
string operation_response_field = 1151;
}

// MethodOptions to identify the actual service and method used for operation
// status polling.
//
// Example:
//
// In a method, which starts an LRO:
//
// service MyService {
// rpc Foo(MyInitialRequest) returns (MyOperation) {
// option (operation_service) = "MyPollingService";
// }
// }
//
// In a polling method:
//
// service MyPollingService {
// rpc Get(MyPollingRequest) returns (MyOperation) {
// option (operation_polling_method) = true;
// }
// }
extend google.protobuf.MethodOptions {
// A method annotation that maps an LRO method (the one which starts an LRO)
// to the service, which will be used to poll for the operation status. The
// annotation must be applied to the method which starts an LRO, the string
// value of the annotation must correspond to the name of the service used to
// poll for the operation status.
string operation_service = 1249;

// A method annotation that marks methods that can be used for polling
// operation status (e.g. the MyPollingService.Get(MyPollingRequest) method).
bool operation_polling_method = 1250;
}

// An enum to be used to mark the essential (for polling) fields in an
// API-specific Operation object. A custom Operation object may contain many
// different fields, but only few of them are essential to conduct a successful
// polling process.
enum OperationResponseMapping {
// Do not use.
UNDEFINED = 0;

// A field in an API-specific (custom) Operation object which carries the same
// meaning as google.longrunning.Operation.name.
NAME = 1;

// A field in an API-specific (custom) Operation object which carries the same
// meaning as google.longrunning.Operation.done. If the annotated field is of
// an enum type, `annotated_field_name == EnumType.DONE` semantics should be
// equivalent to `Operation.done == true`. If the annotated field is of type
// boolean, then it should follow the same semantics as Operation.done.
// Otherwise, a non-empty value should be treated as `Operation.done == true`.
STATUS = 2;

// A field in an API-specific (custom) Operation object which carries the same
// meaning as google.longrunning.Operation.error.code.
ERROR_CODE = 3;

// A field in an API-specific (custom) Operation object which carries the same
// meaning as google.longrunning.Operation.error.message.
ERROR_MESSAGE = 4;
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'use strict';

function main(project) {
// [START compute_v1_generated_Addresses_AggregatedList_async]
// [START compute_v1small_generated_Addresses_AggregatedList_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
Expand Down Expand Up @@ -56,7 +56,7 @@ function main(project) {
// const project = 'my-project'

// Imports the Compute library
const {AddressesClient} = require('@google-cloud/compute').v1;
const {AddressesClient} = require('@google-cloud/compute').v1small;

// Instantiates a client
const computeClient = new AddressesClient();
Expand All @@ -75,7 +75,7 @@ function main(project) {
}

callAggregatedList();
// [END compute_v1_generated_Addresses_AggregatedList_async]
// [END compute_v1small_generated_Addresses_AggregatedList_async]
}

process.on('unhandledRejection', err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'use strict';

function main(address, project, region) {
// [START compute_v1_generated_Addresses_Delete_async]
// [START compute_v1small_generated_Addresses_Delete_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
Expand All @@ -45,7 +45,7 @@ function main(address, project, region) {
// const requestId = 'abc123'

// Imports the Compute library
const {AddressesClient} = require('@google-cloud/compute').v1;
const {AddressesClient} = require('@google-cloud/compute').v1small;

// Instantiates a client
const computeClient = new AddressesClient();
Expand All @@ -64,7 +64,7 @@ function main(address, project, region) {
}

callDelete();
// [END compute_v1_generated_Addresses_Delete_async]
// [END compute_v1small_generated_Addresses_Delete_async]
}

process.on('unhandledRejection', err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'use strict';

function main(addressResource, project, region) {
// [START compute_v1_generated_Addresses_Insert_async]
// [START compute_v1small_generated_Addresses_Insert_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
Expand All @@ -45,7 +45,7 @@ function main(addressResource, project, region) {
// const requestId = 'abc123'

// Imports the Compute library
const {AddressesClient} = require('@google-cloud/compute').v1;
const {AddressesClient} = require('@google-cloud/compute').v1small;

// Instantiates a client
const computeClient = new AddressesClient();
Expand All @@ -64,7 +64,7 @@ function main(addressResource, project, region) {
}

callInsert();
// [END compute_v1_generated_Addresses_Insert_async]
// [END compute_v1small_generated_Addresses_Insert_async]
}

process.on('unhandledRejection', err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'use strict';

function main(orderBy, project, region) {
// [START compute_v1_generated_Addresses_List_async]
// [START compute_v1small_generated_Addresses_List_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
Expand Down Expand Up @@ -56,7 +56,7 @@ function main(orderBy, project, region) {
// const region = 'us-central1'

// Imports the Compute library
const {AddressesClient} = require('@google-cloud/compute').v1;
const {AddressesClient} = require('@google-cloud/compute').v1small;

// Instantiates a client
const computeClient = new AddressesClient();
Expand All @@ -77,7 +77,7 @@ function main(orderBy, project, region) {
}

callList();
// [END compute_v1_generated_Addresses_List_async]
// [END compute_v1small_generated_Addresses_List_async]
}

process.on('unhandledRejection', err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'use strict';

function main(operation, project, region) {
// [START compute_v1_generated_RegionOperations_Get_async]
// [START compute_v1small_generated_RegionOperations_Get_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
Expand All @@ -39,7 +39,7 @@ function main(operation, project, region) {
// const region = 'us-central1'

// Imports the Compute library
const {RegionOperationsClient} = require('@google-cloud/compute').v1;
const {RegionOperationsClient} = require('@google-cloud/compute').v1small;

// Instantiates a client
const computeClient = new RegionOperationsClient();
Expand All @@ -58,7 +58,7 @@ function main(operation, project, region) {
}

callGet();
// [END compute_v1_generated_RegionOperations_Get_async]
// [END compute_v1small_generated_RegionOperations_Get_async]
}

process.on('unhandledRejection', err => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
'use strict';

function main(operation, project, region) {
// [START compute_v1_generated_RegionOperations_Wait_async]
// [START compute_v1small_generated_RegionOperations_Wait_async]
/**
* TODO(developer): Uncomment these variables before running the sample.
*/
Expand All @@ -39,7 +39,7 @@ function main(operation, project, region) {
// const region = 'us-central1'

// Imports the Compute library
const {RegionOperationsClient} = require('@google-cloud/compute').v1;
const {RegionOperationsClient} = require('@google-cloud/compute').v1small;

// Instantiates a client
const computeClient = new RegionOperationsClient();
Expand All @@ -58,7 +58,7 @@ function main(operation, project, region) {
}

callWait();
// [END compute_v1_generated_RegionOperations_Wait_async]
// [END compute_v1small_generated_RegionOperations_Wait_async]
}

process.on('unhandledRejection', err => {
Expand Down
Loading