Skip to content

Commit

Permalink
feat: enable --iam-service options for including IAM methods (#375)
Browse files Browse the repository at this point in the history
* add iam_service baseline test

* IAM methods added to the client logic

* add baseline test data

* take gax IAM service

* merge conflicts & update baseline

* compile pass against IAM service

* template message

* lint fix

* update baseline

* change gax back for generator itself

* iamClient public

* Revert "iamClient public"

This reverts commit 394df81.

* feedback

* clean up

* jsdoc for IAM methods

* add unit test for IAM methods

* pick up chang & add unit test with callback

* udpate callback

* update baseline

* update baseline & gax dependency

* update from master

* combine IAM test w/kms baseline test

* remove iam-service baseline test

* move IAM template to a separate file
  • Loading branch information
xiaozhenliu-gg5 committed Apr 10, 2020
1 parent 590de1b commit 5a105ee
Show file tree
Hide file tree
Showing 16 changed files with 744 additions and 29 deletions.
145 changes: 144 additions & 1 deletion baselines/kms/src/v1/key_management_service_client.ts.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// ** All changes to this file may be overwritten. **

import * as gax from 'google-gax';
import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall} from 'google-gax';
import {Callback, CallOptions, Descriptors, ClientOptions, PaginationCallback, GaxCall, IamClient, IamProtos} from 'google-gax';
import * as path from 'path';

import { Transform } from 'stream';
Expand Down Expand Up @@ -52,6 +52,7 @@ export class KeyManagementServiceClient {
auth: gax.GoogleAuth;
descriptors: Descriptors = {page: {}, stream: {}, longrunning: {}, batching: {}};
innerApiCalls: {[name: string]: Function};
iamClient: IamClient;
keyManagementServiceStub?: Promise<{[name: string]: Function}>;

/**
Expand Down Expand Up @@ -115,6 +116,8 @@ export class KeyManagementServiceClient {

// Save the auth object to the client, for use by other methods.
this.auth = (this._gaxGrpc.auth as gax.GoogleAuth);
this.iamClient = new IamClient(this._gaxGrpc, opts);


// Determine the client header string.
const clientHeader = [
Expand Down Expand Up @@ -2533,6 +2536,146 @@ export class KeyManagementServiceClient {
callSettings
) as AsyncIterable<protos.google.cloud.kms.v1.IImportJob>;
}
/**
* Gets the access control policy for a resource. Returns an empty policy
* if the resource exists and does not have a policy set.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.resource
* REQUIRED: The resource for which the policy is being requested.
* See the operation documentation for the appropriate value for this field.
* @param {Object} [request.options]
* OPTIONAL: A `GetPolicyOptions` object for specifying options to
* `GetIamPolicy`. This field is only used by Cloud IAM.
*
* This object should have the same structure as [GetPolicyOptions]{@link google.iam.v1.GetPolicyOptions}
* @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/interfaces/CallOptions.html} 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 [Policy]{@link google.iam.v1.Policy}.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [Policy]{@link google.iam.v1.Policy}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
getIamPolicy(
request: IamProtos.google.iam.v1.GetIamPolicyRequest,
options?:
| gax.CallOptions
| Callback<
IamProtos.google.iam.v1.Policy,
IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined,
{} | null | undefined
>,
callback?: Callback<
IamProtos.google.iam.v1.Policy,
IamProtos.google.iam.v1.GetIamPolicyRequest | null | undefined,
{} | null | undefined
>
):Promise<IamProtos.google.iam.v1.Policy> {
return this.iamClient.getIamPolicy(request, options, callback);
}

/**
* Returns permissions that a caller has on the specified resource. If the
* resource does not exist, this will return an empty set of
* permissions, not a NOT_FOUND error.
*
* Note: This operation is designed to be used for building
* permission-aware UIs and command-line tools, not for authorization
* checking. This operation may "fail open" without warning.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.resource
* REQUIRED: The resource for which the policy detail is being requested.
* See the operation documentation for the appropriate value for this field.
* @param {string[]} request.permissions
* The set of permissions to check for the `resource`. Permissions with
* wildcards (such as '*' or 'storage.*') are not allowed. For more
* information see
* [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
* @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*/
setIamPolicy(
request: IamProtos.google.iam.v1.SetIamPolicyRequest,
options?:
| gax.CallOptions
| Callback<
IamProtos.google.iam.v1.Policy,
IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined,
{} | null | undefined
>,
callback?: Callback<
IamProtos.google.iam.v1.Policy,
IamProtos.google.iam.v1.SetIamPolicyRequest | null | undefined,
{} | null | undefined
>
):Promise<IamProtos.google.iam.v1.Policy> {
return this.iamClient.setIamPolicy(request, options, callback);
}

/**
* Returns permissions that a caller has on the specified resource. If the
* resource does not exist, this will return an empty set of
* permissions, not a NOT_FOUND error.
*
* Note: This operation is designed to be used for building
* permission-aware UIs and command-line tools, not for authorization
* checking. This operation may "fail open" without warning.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.resource
* REQUIRED: The resource for which the policy detail is being requested.
* See the operation documentation for the appropriate value for this field.
* @param {string[]} request.permissions
* The set of permissions to check for the `resource`. Permissions with
* wildcards (such as '*' or 'storage.*') are not allowed. For more
* information see
* [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
* @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/interfaces/CallOptions.html} 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 [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}.
* @returns {Promise} - The promise which resolves to an array.
* The first element of the array is an object representing [TestIamPermissionsResponse]{@link google.iam.v1.TestIamPermissionsResponse}.
* The promise has a method named "cancel" which cancels the ongoing API call.
*
*/
testIamPermissions(
request: IamProtos.google.iam.v1.TestIamPermissionsRequest,
options?:
| gax.CallOptions
| Callback<
IamProtos.google.iam.v1.TestIamPermissionsResponse,
IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined,
{} | null | undefined
>,
callback?: Callback<
IamProtos.google.iam.v1.TestIamPermissionsResponse,
IamProtos.google.iam.v1.TestIamPermissionsRequest | null | undefined,
{} | null | undefined
>
):Promise<IamProtos.google.iam.v1.TestIamPermissionsResponse> {
return this.iamClient.testIamPermissions(request, options, callback);
}


/**
* Terminate the GRPC channel and close the client.
Expand Down

0 comments on commit 5a105ee

Please sign in to comment.