UNPKG

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