@google-cloud/storage-control 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -95,6 +95,21 @@
95
95
  "updateOrganizationIntelligenceConfig"
96
96
  ]
97
97
  },
98
+ "GetIamPolicy": {
99
+ "methods": [
100
+ "getIamPolicy"
101
+ ]
102
+ },
103
+ "SetIamPolicy": {
104
+ "methods": [
105
+ "setIamPolicy"
106
+ ]
107
+ },
108
+ "TestIamPermissions": {
109
+ "methods": [
110
+ "testIamPermissions"
111
+ ]
112
+ },
98
113
  "RenameFolder": {
99
114
  "methods": [
100
115
  "renameFolder"
@@ -221,6 +236,21 @@
221
236
  "updateOrganizationIntelligenceConfig"
222
237
  ]
223
238
  },
239
+ "GetIamPolicy": {
240
+ "methods": [
241
+ "getIamPolicy"
242
+ ]
243
+ },
244
+ "SetIamPolicy": {
245
+ "methods": [
246
+ "setIamPolicy"
247
+ ]
248
+ },
249
+ "TestIamPermissions": {
250
+ "methods": [
251
+ "testIamPermissions"
252
+ ]
253
+ },
224
254
  "RenameFolder": {
225
255
  "methods": [
226
256
  "renameFolder"
@@ -645,6 +645,111 @@ export declare class StorageControlClient {
645
645
  ]>;
646
646
  updateOrganizationIntelligenceConfig(request: protos.google.storage.control.v2.IUpdateOrganizationIntelligenceConfigRequest, options: CallOptions, callback: Callback<protos.google.storage.control.v2.IIntelligenceConfig, protos.google.storage.control.v2.IUpdateOrganizationIntelligenceConfigRequest | null | undefined, {} | null | undefined>): void;
647
647
  updateOrganizationIntelligenceConfig(request: protos.google.storage.control.v2.IUpdateOrganizationIntelligenceConfigRequest, callback: Callback<protos.google.storage.control.v2.IIntelligenceConfig, protos.google.storage.control.v2.IUpdateOrganizationIntelligenceConfigRequest | null | undefined, {} | null | undefined>): void;
648
+ /**
649
+ * Gets the IAM policy for a specified bucket.
650
+ * The `resource` field in the request should be
651
+ * `projects/_/buckets/{bucket}` for a bucket, or
652
+ * `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
653
+ * for a managed folder.
654
+ *
655
+ * @param {Object} request
656
+ * The request object that will be sent.
657
+ * @param {string} request.resource
658
+ * REQUIRED: The resource for which the policy is being requested.
659
+ * See the operation documentation for the appropriate value for this field.
660
+ * @param {google.iam.v1.GetPolicyOptions} request.options
661
+ * OPTIONAL: A `GetPolicyOptions` object for specifying options to
662
+ * `GetIamPolicy`.
663
+ * @param {object} [options]
664
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
665
+ * @returns {Promise} - The promise which resolves to an array.
666
+ * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}.
667
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
668
+ * for more details and examples.
669
+ * @example <caption>include:samples/generated/v2/storage_control.get_iam_policy.js</caption>
670
+ * region_tag:storage_v2_generated_StorageControl_GetIamPolicy_async
671
+ */
672
+ getIamPolicy(request?: protos.google.iam.v1.IGetIamPolicyRequest, options?: CallOptions): Promise<[
673
+ protos.google.iam.v1.IPolicy,
674
+ protos.google.iam.v1.IGetIamPolicyRequest | undefined,
675
+ {} | undefined
676
+ ]>;
677
+ getIamPolicy(request: protos.google.iam.v1.IGetIamPolicyRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
678
+ getIamPolicy(request: protos.google.iam.v1.IGetIamPolicyRequest, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.IGetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
679
+ /**
680
+ * Updates an IAM policy for the specified bucket.
681
+ * The `resource` field in the request should be
682
+ * `projects/_/buckets/{bucket}` for a bucket, or
683
+ * `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
684
+ * for a managed folder.
685
+ *
686
+ * @param {Object} request
687
+ * The request object that will be sent.
688
+ * @param {string} request.resource
689
+ * REQUIRED: The resource for which the policy is being specified.
690
+ * See the operation documentation for the appropriate value for this field.
691
+ * @param {google.iam.v1.Policy} request.policy
692
+ * REQUIRED: The complete policy to be applied to the `resource`. The size of
693
+ * the policy is limited to a few 10s of KB. An empty policy is a
694
+ * valid policy but certain Cloud Platform services (such as Projects)
695
+ * might reject them.
696
+ * @param {google.protobuf.FieldMask} request.updateMask
697
+ * OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only
698
+ * the fields in the mask will be modified. If no mask is provided, the
699
+ * following default mask is used:
700
+ *
701
+ * `paths: "bindings, etag"`
702
+ * @param {object} [options]
703
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
704
+ * @returns {Promise} - The promise which resolves to an array.
705
+ * The first element of the array is an object representing {@link protos.google.iam.v1.Policy|Policy}.
706
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
707
+ * for more details and examples.
708
+ * @example <caption>include:samples/generated/v2/storage_control.set_iam_policy.js</caption>
709
+ * region_tag:storage_v2_generated_StorageControl_SetIamPolicy_async
710
+ */
711
+ setIamPolicy(request?: protos.google.iam.v1.ISetIamPolicyRequest, options?: CallOptions): Promise<[
712
+ protos.google.iam.v1.IPolicy,
713
+ protos.google.iam.v1.ISetIamPolicyRequest | undefined,
714
+ {} | undefined
715
+ ]>;
716
+ setIamPolicy(request: protos.google.iam.v1.ISetIamPolicyRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
717
+ setIamPolicy(request: protos.google.iam.v1.ISetIamPolicyRequest, callback: Callback<protos.google.iam.v1.IPolicy, protos.google.iam.v1.ISetIamPolicyRequest | null | undefined, {} | null | undefined>): void;
718
+ /**
719
+ * Tests a set of permissions on the given bucket, object, or managed folder
720
+ * to see which, if any, are held by the caller.
721
+ * The `resource` field in the request should be
722
+ * `projects/_/buckets/{bucket}` for a bucket,
723
+ * `projects/_/buckets/{bucket}/objects/{object}` for an object, or
724
+ * `projects/_/buckets/{bucket}/managedFolders/{managedFolder}`
725
+ * for a managed folder.
726
+ *
727
+ * @param {Object} request
728
+ * The request object that will be sent.
729
+ * @param {string} request.resource
730
+ * REQUIRED: The resource for which the policy detail is being requested.
731
+ * See the operation documentation for the appropriate value for this field.
732
+ * @param {string[]} request.permissions
733
+ * The set of permissions to check for the `resource`. Permissions with
734
+ * wildcards (such as '*' or 'storage.*') are not allowed. For more
735
+ * information see
736
+ * [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
737
+ * @param {object} [options]
738
+ * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
739
+ * @returns {Promise} - The promise which resolves to an array.
740
+ * The first element of the array is an object representing {@link protos.google.iam.v1.TestIamPermissionsResponse|TestIamPermissionsResponse}.
741
+ * Please see the {@link https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods | documentation }
742
+ * for more details and examples.
743
+ * @example <caption>include:samples/generated/v2/storage_control.test_iam_permissions.js</caption>
744
+ * region_tag:storage_v2_generated_StorageControl_TestIamPermissions_async
745
+ */
746
+ testIamPermissions(request?: protos.google.iam.v1.ITestIamPermissionsRequest, options?: CallOptions): Promise<[
747
+ protos.google.iam.v1.ITestIamPermissionsResponse,
748
+ protos.google.iam.v1.ITestIamPermissionsRequest | undefined,
749
+ {} | undefined
750
+ ]>;
751
+ testIamPermissions(request: protos.google.iam.v1.ITestIamPermissionsRequest, options: CallOptions, callback: Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
752
+ testIamPermissions(request: protos.google.iam.v1.ITestIamPermissionsRequest, callback: Callback<protos.google.iam.v1.ITestIamPermissionsResponse, protos.google.iam.v1.ITestIamPermissionsRequest | null | undefined, {} | null | undefined>): void;
648
753
  /**
649
754
  * Renames a source folder to a destination folder. This operation is only
650
755
  * applicable to a hierarchical namespace enabled bucket. During a rename, the
@@ -238,7 +238,7 @@ class StorageControlClient {
238
238
  this._protos.google.storage.control.v2.StorageControl, this._opts, this._providedCustomServicePath);
239
239
  // Iterate over each of the methods that the service provides
240
240
  // and create an API call method for each.
241
- const storageControlStubMethods = ['createFolder', 'deleteFolder', 'getFolder', 'listFolders', 'renameFolder', 'getStorageLayout', 'createManagedFolder', 'deleteManagedFolder', 'getManagedFolder', 'listManagedFolders', 'createAnywhereCache', 'updateAnywhereCache', 'disableAnywhereCache', 'pauseAnywhereCache', 'resumeAnywhereCache', 'getAnywhereCache', 'listAnywhereCaches', 'getProjectIntelligenceConfig', 'updateProjectIntelligenceConfig', 'getFolderIntelligenceConfig', 'updateFolderIntelligenceConfig', 'getOrganizationIntelligenceConfig', 'updateOrganizationIntelligenceConfig'];
241
+ const storageControlStubMethods = ['createFolder', 'deleteFolder', 'getFolder', 'listFolders', 'renameFolder', 'getStorageLayout', 'createManagedFolder', 'deleteManagedFolder', 'getManagedFolder', 'listManagedFolders', 'createAnywhereCache', 'updateAnywhereCache', 'disableAnywhereCache', 'pauseAnywhereCache', 'resumeAnywhereCache', 'getAnywhereCache', 'listAnywhereCaches', 'getProjectIntelligenceConfig', 'updateProjectIntelligenceConfig', 'getFolderIntelligenceConfig', 'updateFolderIntelligenceConfig', 'getOrganizationIntelligenceConfig', 'updateOrganizationIntelligenceConfig', 'getIamPolicy', 'setIamPolicy', 'testIamPermissions'];
242
242
  for (const methodName of storageControlStubMethods) {
243
243
  const callPromise = this.storageControlStub.then(stub => (...args) => {
244
244
  if (this._terminated) {
@@ -1065,6 +1065,181 @@ class StorageControlClient {
1065
1065
  throw error;
1066
1066
  });
1067
1067
  }
1068
+ getIamPolicy(request, optionsOrCallback, callback) {
1069
+ request = request || {};
1070
+ let options;
1071
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1072
+ callback = optionsOrCallback;
1073
+ options = {};
1074
+ }
1075
+ else {
1076
+ options = optionsOrCallback;
1077
+ }
1078
+ options = options || {};
1079
+ options.otherArgs = options.otherArgs || {};
1080
+ options.otherArgs.headers = options.otherArgs.headers || {};
1081
+ let routingParameter = {};
1082
+ {
1083
+ const fieldValue = request.resource;
1084
+ if (fieldValue !== undefined && fieldValue !== null) {
1085
+ const match = fieldValue.toString().match(RegExp('(?<bucket>(?:.*)?)'));
1086
+ if (match) {
1087
+ const parameterValue = match.groups?.['bucket'] ?? fieldValue;
1088
+ Object.assign(routingParameter, { bucket: parameterValue });
1089
+ }
1090
+ }
1091
+ }
1092
+ {
1093
+ const fieldValue = request.resource;
1094
+ if (fieldValue !== undefined && fieldValue !== null) {
1095
+ const match = fieldValue.toString().match(RegExp('(?<bucket>projects/[^/]+/buckets/[^/]+)(?:/.*)?'));
1096
+ if (match) {
1097
+ const parameterValue = match.groups?.['bucket'] ?? fieldValue;
1098
+ Object.assign(routingParameter, { bucket: parameterValue });
1099
+ }
1100
+ }
1101
+ }
1102
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
1103
+ this.initialize().catch(err => { throw err; });
1104
+ this._log.info('getIamPolicy request %j', request);
1105
+ const wrappedCallback = callback
1106
+ ? (error, response, options, rawResponse) => {
1107
+ this._log.info('getIamPolicy response %j', response);
1108
+ callback(error, response, options, rawResponse); // We verified callback above.
1109
+ }
1110
+ : undefined;
1111
+ return this.innerApiCalls.getIamPolicy(request, options, wrappedCallback)
1112
+ ?.then(([response, options, rawResponse]) => {
1113
+ this._log.info('getIamPolicy response %j', response);
1114
+ return [response, options, rawResponse];
1115
+ }).catch((error) => {
1116
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
1117
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1118
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1119
+ }
1120
+ throw error;
1121
+ });
1122
+ }
1123
+ setIamPolicy(request, optionsOrCallback, callback) {
1124
+ request = request || {};
1125
+ let options;
1126
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1127
+ callback = optionsOrCallback;
1128
+ options = {};
1129
+ }
1130
+ else {
1131
+ options = optionsOrCallback;
1132
+ }
1133
+ options = options || {};
1134
+ options.otherArgs = options.otherArgs || {};
1135
+ options.otherArgs.headers = options.otherArgs.headers || {};
1136
+ let routingParameter = {};
1137
+ {
1138
+ const fieldValue = request.resource;
1139
+ if (fieldValue !== undefined && fieldValue !== null) {
1140
+ const match = fieldValue.toString().match(RegExp('(?<bucket>(?:.*)?)'));
1141
+ if (match) {
1142
+ const parameterValue = match.groups?.['bucket'] ?? fieldValue;
1143
+ Object.assign(routingParameter, { bucket: parameterValue });
1144
+ }
1145
+ }
1146
+ }
1147
+ {
1148
+ const fieldValue = request.resource;
1149
+ if (fieldValue !== undefined && fieldValue !== null) {
1150
+ const match = fieldValue.toString().match(RegExp('(?<bucket>projects/[^/]+/buckets/[^/]+)(?:/.*)?'));
1151
+ if (match) {
1152
+ const parameterValue = match.groups?.['bucket'] ?? fieldValue;
1153
+ Object.assign(routingParameter, { bucket: parameterValue });
1154
+ }
1155
+ }
1156
+ }
1157
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
1158
+ this.initialize().catch(err => { throw err; });
1159
+ this._log.info('setIamPolicy request %j', request);
1160
+ const wrappedCallback = callback
1161
+ ? (error, response, options, rawResponse) => {
1162
+ this._log.info('setIamPolicy response %j', response);
1163
+ callback(error, response, options, rawResponse); // We verified callback above.
1164
+ }
1165
+ : undefined;
1166
+ return this.innerApiCalls.setIamPolicy(request, options, wrappedCallback)
1167
+ ?.then(([response, options, rawResponse]) => {
1168
+ this._log.info('setIamPolicy response %j', response);
1169
+ return [response, options, rawResponse];
1170
+ }).catch((error) => {
1171
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
1172
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1173
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1174
+ }
1175
+ throw error;
1176
+ });
1177
+ }
1178
+ testIamPermissions(request, optionsOrCallback, callback) {
1179
+ request = request || {};
1180
+ let options;
1181
+ if (typeof optionsOrCallback === 'function' && callback === undefined) {
1182
+ callback = optionsOrCallback;
1183
+ options = {};
1184
+ }
1185
+ else {
1186
+ options = optionsOrCallback;
1187
+ }
1188
+ options = options || {};
1189
+ options.otherArgs = options.otherArgs || {};
1190
+ options.otherArgs.headers = options.otherArgs.headers || {};
1191
+ let routingParameter = {};
1192
+ {
1193
+ const fieldValue = request.resource;
1194
+ if (fieldValue !== undefined && fieldValue !== null) {
1195
+ const match = fieldValue.toString().match(RegExp('(?<bucket>(?:.*)?)'));
1196
+ if (match) {
1197
+ const parameterValue = match.groups?.['bucket'] ?? fieldValue;
1198
+ Object.assign(routingParameter, { bucket: parameterValue });
1199
+ }
1200
+ }
1201
+ }
1202
+ {
1203
+ const fieldValue = request.resource;
1204
+ if (fieldValue !== undefined && fieldValue !== null) {
1205
+ const match = fieldValue.toString().match(RegExp('(?<bucket>projects/[^/]+/buckets/[^/]+)/objects(?:/.*)?'));
1206
+ if (match) {
1207
+ const parameterValue = match.groups?.['bucket'] ?? fieldValue;
1208
+ Object.assign(routingParameter, { bucket: parameterValue });
1209
+ }
1210
+ }
1211
+ }
1212
+ {
1213
+ const fieldValue = request.resource;
1214
+ if (fieldValue !== undefined && fieldValue !== null) {
1215
+ const match = fieldValue.toString().match(RegExp('(?<bucket>projects/[^/]+/buckets/[^/]+)/managedFolders(?:/.*)?'));
1216
+ if (match) {
1217
+ const parameterValue = match.groups?.['bucket'] ?? fieldValue;
1218
+ Object.assign(routingParameter, { bucket: parameterValue });
1219
+ }
1220
+ }
1221
+ }
1222
+ options.otherArgs.headers['x-goog-request-params'] = this._gaxModule.routingHeader.fromParams(routingParameter);
1223
+ this.initialize().catch(err => { throw err; });
1224
+ this._log.info('testIamPermissions request %j', request);
1225
+ const wrappedCallback = callback
1226
+ ? (error, response, options, rawResponse) => {
1227
+ this._log.info('testIamPermissions response %j', response);
1228
+ callback(error, response, options, rawResponse); // We verified callback above.
1229
+ }
1230
+ : undefined;
1231
+ return this.innerApiCalls.testIamPermissions(request, options, wrappedCallback)
1232
+ ?.then(([response, options, rawResponse]) => {
1233
+ this._log.info('testIamPermissions response %j', response);
1234
+ return [response, options, rawResponse];
1235
+ }).catch((error) => {
1236
+ if (error && 'statusDetails' in error && error.statusDetails instanceof Array) {
1237
+ const protos = this._gaxModule.protobuf.Root.fromJSON(jsonProtos);
1238
+ error.statusDetails = (0, google_gax_1.decodeAnyProtosInArray)(error.statusDetails, protos);
1239
+ }
1240
+ throw error;
1241
+ });
1242
+ }
1068
1243
  renameFolder(request, optionsOrCallback, callback) {
1069
1244
  request = request || {};
1070
1245
  if (!request.requestId) {