UNPKG

owltech

Version:
136 lines (135 loc) 4.89 kB
/*! * Copyright 2017 Google Inc. All Rights Reserved. * * 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. */ import * as r from 'request'; import { Bucket } from './bucket'; /** * @typedef {object} GetPolicyOptions * @property {string} [userProject] The ID of the project which will be billed for * the request. */ export interface GetPolicyOptions { userProject?: string; } /** * @typedef {array} GetPolicyResponse * @property {object} 0 The policy. * @property {object} 1 The full API response. */ export declare type GetPolicyResponse = [Policy, r.Response]; /** * @callback GetPolicyCallback * @param {?Error} err Request error, if any. * @param {object} acl The policy. * @param {object} apiResponse The full API response. */ export interface GetPolicyCallback { (err?: Error | null, acl?: Policy, apiResponse?: r.Response): void; } /** * @typedef {object} SetPolicyOptions * @param {string} [userProject] The ID of the project which will be * billed for the request. */ export interface SetPolicyOptions { userProject?: string; } /** * @typedef {array} SetPolicyResponse * @property {object} 0 The policy. * @property {object} 1 The full API response. */ export declare type SetPolicyResponse = [Policy, r.Response]; /** * @callback SetPolicyCallback * @param {?Error} err Request error, if any. * @param {object} acl The policy. * @param {object} apiResponse The full API response. */ export interface SetPolicyCallback { (err?: Error | null, acl?: Policy, apiResponse?: object): void; } /** * @typedef {object} Policy * @property {array} policy.bindings Bindings associate members with roles. * @property {string} [policy.etag] Etags are used to perform a read-modify-write. */ export interface Policy { bindings: PolicyBinding[]; etag?: string; } export interface PolicyBinding { role: string; members: string[]; } /** * @typedef {array} TestIamPermissionsResponse * @property {object} 0 A subset of permissions that the caller is allowed. * @property {object} 1 The full API response. */ export declare type TestIamPermissionsResponse = [{ [key: string]: boolean; }, r.Response]; /** * @callback TestIamPermissionsCallback * @param {?Error} err Request error, if any. * @param {object} acl A subset of permissions that the caller is allowed. * @param {object} apiResponse The full API response. */ export interface TestIamPermissionsCallback { (err?: Error | null, acl?: { [key: string]: boolean; } | null, apiResponse?: r.Response): void; } /** * @typedef {object} TestIamPermissionsOptions Configuration options for Iam#testPermissions(). * @param {string} [userProject] The ID of the project which will be * billed for the request. */ export interface TestIamPermissionsOptions { userProject?: string; } /** * Get and set IAM policies for your Cloud Storage bucket. * * @see [Cloud Storage IAM Management](https://cloud.google.com/storage/docs/access-control/iam#short_title_iam_management) * @see [Granting, Changing, and Revoking Access](https://cloud.google.com/iam/docs/granting-changing-revoking-access) * @see [IAM Roles](https://cloud.google.com/iam/docs/understanding-roles) * * @constructor Iam * @mixin * * @param {Bucket} bucket The parent instance. * @example * const {Storage} = require('@google-cloud/storage'); * const storage = new Storage(); * const bucket = storage.bucket('my-bucket'); * // bucket.iam */ declare class Iam { private request_; private resourceId_; constructor(bucket: Bucket); getPolicy(options?: GetPolicyOptions): Promise<GetPolicyResponse>; getPolicy(options: GetPolicyOptions, callback: GetPolicyCallback): void; getPolicy(callback: GetPolicyCallback): void; setPolicy(policy: Policy, options?: SetPolicyOptions): Promise<SetPolicyResponse>; setPolicy(policy: Policy, callback: SetPolicyCallback): void; setPolicy(policy: Policy, options: SetPolicyOptions, callback: SetPolicyCallback): void; testPermissions(permissions: string | string[], options?: TestIamPermissionsOptions): Promise<TestIamPermissionsResponse>; testPermissions(permissions: string | string[], callback: TestIamPermissionsCallback): void; testPermissions(permissions: string | string[], options: TestIamPermissionsOptions, callback: TestIamPermissionsCallback): void; } export { Iam };