UNPKG

5.25 kBTypeScriptView Raw
1import { BodyResponseCallback, DecorateRequestOptions, Metadata } from './nodejs-common';
2export interface AclOptions {
3 pathPrefix: string;
4 request: (reqOpts: DecorateRequestOptions, callback: BodyResponseCallback) => void;
5}
6export declare type GetAclResponse = [AccessControlObject | AccessControlObject[], Metadata];
7export interface GetAclCallback {
8 (err: Error | null, acl?: AccessControlObject | AccessControlObject[] | null, apiResponse?: Metadata): void;
9}
10export interface GetAclOptions {
11 entity: string;
12 generation?: number;
13 userProject?: string;
14}
15export interface UpdateAclOptions {
16 entity: string;
17 role: string;
18 generation?: number;
19 userProject?: string;
20}
21export declare type UpdateAclResponse = [AccessControlObject, Metadata];
22export interface UpdateAclCallback {
23 (err: Error | null, acl?: AccessControlObject | null, apiResponse?: Metadata): void;
24}
25export interface AddAclOptions {
26 entity: string;
27 role: string;
28 generation?: number;
29 userProject?: string;
30}
31export declare type AddAclResponse = [AccessControlObject, Metadata];
32export interface AddAclCallback {
33 (err: Error | null, acl?: AccessControlObject | null, apiResponse?: Metadata): void;
34}
35export declare type RemoveAclResponse = [Metadata];
36export interface RemoveAclCallback {
37 (err: Error | null, apiResponse?: Metadata): void;
38}
39export interface RemoveAclOptions {
40 entity: string;
41 generation?: number;
42 userProject?: string;
43}
44export interface AccessControlObject {
45 entity: string;
46 role: string;
47 projectTeam: string;
48}
49/**
50 * Attach functionality to a {@link Storage.acl} instance. This will add an
51 * object for each role group (owners, readers, and writers), with each object
52 * containing methods to add or delete a type of entity.
53 *
54 * As an example, here are a few methods that are created.
55 *
56 * myBucket.acl.readers.deleteGroup('groupId', function(err) {});
57 *
58 * myBucket.acl.owners.addUser('email@example.com', function(err, acl) {});
59 *
60 * myBucket.acl.writers.addDomain('example.com', function(err, acl) {});
61 *
62 * @private
63 */
64declare class AclRoleAccessorMethods {
65 private static accessMethods;
66 private static entities;
67 private static roles;
68 owners: {};
69 readers: {};
70 writers: {};
71 constructor();
72 _assignAccessMethods(role: string): void;
73}
74/**
75 * Cloud Storage uses access control lists (ACLs) to manage object and
76 * bucket access. ACLs are the mechanism you use to share objects with other
77 * users and allow other users to access your buckets and objects.
78 *
79 * An ACL consists of one or more entries, where each entry grants permissions
80 * to an entity. Permissions define the actions that can be performed against an
81 * object or bucket (for example, `READ` or `WRITE`); the entity defines who the
82 * permission applies to (for example, a specific user or group of users).
83 *
84 * Where an `entity` value is accepted, we follow the format the Cloud Storage
85 * API expects.
86 *
87 * Refer to
88 * https://cloud.google.com/storage/docs/json_api/v1/defaultObjectAccessControls
89 * for the most up-to-date values.
90 *
91 * - `user-userId`
92 * - `user-email`
93 * - `group-groupId`
94 * - `group-email`
95 * - `domain-domain`
96 * - `project-team-projectId`
97 * - `allUsers`
98 * - `allAuthenticatedUsers`
99 *
100 * Examples:
101 *
102 * - The user "liz@example.com" would be `user-liz@example.com`.
103 * - The group "example@googlegroups.com" would be
104 * `group-example@googlegroups.com`.
105 * - To refer to all members of the Google Apps for Business domain
106 * "example.com", the entity would be `domain-example.com`.
107 *
108 * For more detailed information, see
109 * {@link http://goo.gl/6qBBPO| About Access Control Lists}.
110 *
111 * @constructor Acl
112 * @mixin
113 * @param {object} options Configuration options.
114 */
115declare class Acl extends AclRoleAccessorMethods {
116 default: Acl;
117 pathPrefix: string;
118 request_: (reqOpts: DecorateRequestOptions, callback: BodyResponseCallback) => void;
119 constructor(options: AclOptions);
120 add(options: AddAclOptions): Promise<AddAclResponse>;
121 add(options: AddAclOptions, callback: AddAclCallback): void;
122 delete(options: RemoveAclOptions): Promise<RemoveAclResponse>;
123 delete(options: RemoveAclOptions, callback: RemoveAclCallback): void;
124 get(options?: GetAclOptions): Promise<GetAclResponse>;
125 get(options: GetAclOptions, callback: GetAclCallback): void;
126 get(callback: GetAclCallback): void;
127 update(options: UpdateAclOptions): Promise<UpdateAclResponse>;
128 update(options: UpdateAclOptions, callback: UpdateAclCallback): void;
129 /**
130 * Transform API responses to a consistent object format.
131 *
132 * @private
133 */
134 makeAclObject_(accessControlObject: AccessControlObject): AccessControlObject;
135 /**
136 * Patch requests up to the bucket's request object.
137 *
138 * @private
139 *
140 * @param {string} method Action.
141 * @param {string} path Request path.
142 * @param {*} query Request query object.
143 * @param {*} body Request body contents.
144 * @param {function} callback Callback function.
145 */
146 request(reqOpts: DecorateRequestOptions, callback: BodyResponseCallback): void;
147}
148export { Acl, AclRoleAccessorMethods };