• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-node-sdk / 28487081640

30 Jun 2026 12:28PM UTC coverage: 40.775% (-0.06%) from 40.831%
28487081640

push

github

web-flow
chore: Update `.codegen.json` with commit hash of `codegen` and `openapi` spec [skip ci] (#1530)

Co-authored-by: box-sdk-build <box-sdk-build@box.com>

4956 of 21079 branches covered (23.51%)

Branch coverage included in aggregate %.

18062 of 35372 relevant lines covered (51.06%)

171.36 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

48.63
/src/managers/folderMetadata.ts
1
import { serializeMetadatas } from '../schemas/metadatas';
2
import { deserializeMetadatas } from '../schemas/metadatas';
246✔
3
import { serializeClientError } from '../schemas/clientError';
4
import { deserializeClientError } from '../schemas/clientError';
5
import { serializeMetadataFull } from '../schemas/metadataFull';
6
import { deserializeMetadataFull } from '../schemas/metadataFull';
246✔
7
import { serializeMetadataError } from '../schemas/metadataError';
8
import { deserializeMetadataError } from '../schemas/metadataError';
9
import { serializeMetadataInstanceValue } from '../schemas/metadataInstanceValue';
246✔
10
import { deserializeMetadataInstanceValue } from '../schemas/metadataInstanceValue';
246✔
11
import { ResponseFormat } from '../networking/fetchOptions';
12
import { Metadatas } from '../schemas/metadatas';
13
import { ClientError } from '../schemas/clientError';
14
import { MetadataFull } from '../schemas/metadataFull';
15
import { MetadataError } from '../schemas/metadataError';
16
import { MetadataInstanceValue } from '../schemas/metadataInstanceValue';
17
import { BoxSdkError } from '../box/errors';
246✔
18
import { Authentication } from '../networking/auth';
19
import { NetworkSession } from '../networking/network';
246✔
20
import { FetchOptions } from '../networking/fetchOptions';
246✔
21
import { FetchResponse } from '../networking/fetchResponse';
22
import { prepareParams } from '../internal/utils';
246✔
23
import { toString } from '../internal/utils';
246✔
24
import { ByteStream } from '../internal/utils';
25
import { CancellationToken } from '../internal/utils';
26
import { sdToJson } from '../serialization/json';
27
import { SerializedData } from '../serialization/json';
28
import { sdIsEmpty } from '../serialization/json';
29
import { sdIsBoolean } from '../serialization/json';
30
import { sdIsNumber } from '../serialization/json';
31
import { sdIsString } from '../serialization/json';
246✔
32
import { sdIsList } from '../serialization/json';
33
import { sdIsMap } from '../serialization/json';
246✔
34
export class GetFolderMetadataOptionals {
246✔
35
  readonly queryParams: GetFolderMetadataQueryParams =
3✔
36
    {} satisfies GetFolderMetadataQueryParams;
37
  readonly headers: GetFolderMetadataHeaders = new GetFolderMetadataHeaders({});
3✔
38
  readonly cancellationToken?: CancellationToken = void 0;
3✔
39
  constructor(
40
    fields: Omit<
41
      GetFolderMetadataOptionals,
42
      'queryParams' | 'headers' | 'cancellationToken'
43
    > &
44
      Partial<
45
        Pick<
46
          GetFolderMetadataOptionals,
47
          'queryParams' | 'headers' | 'cancellationToken'
48
        >
49
      >,
50
  ) {
51
    if (fields.queryParams !== undefined) {
3!
52
      this.queryParams = fields.queryParams;
×
53
    }
54
    if (fields.headers !== undefined) {
3!
55
      this.headers = fields.headers;
×
56
    }
57
    if (fields.cancellationToken !== undefined) {
3!
58
      this.cancellationToken = fields.cancellationToken;
×
59
    }
60
  }
61
}
62
export interface GetFolderMetadataOptionalsInput {
63
  readonly queryParams?: GetFolderMetadataQueryParams;
64
  readonly headers?: GetFolderMetadataHeaders;
65
  readonly cancellationToken?: CancellationToken;
66
}
67
export class GetFolderMetadataByIdOptionals {
246✔
68
  readonly headers: GetFolderMetadataByIdHeaders =
9✔
69
    new GetFolderMetadataByIdHeaders({});
70
  readonly cancellationToken?: CancellationToken = void 0;
9✔
71
  constructor(
72
    fields: Omit<
73
      GetFolderMetadataByIdOptionals,
74
      'headers' | 'cancellationToken'
75
    > &
76
      Partial<
77
        Pick<GetFolderMetadataByIdOptionals, 'headers' | 'cancellationToken'>
78
      >,
79
  ) {
80
    if (fields.headers !== undefined) {
9!
81
      this.headers = fields.headers;
×
82
    }
83
    if (fields.cancellationToken !== undefined) {
9!
84
      this.cancellationToken = fields.cancellationToken;
×
85
    }
86
  }
87
}
88
export interface GetFolderMetadataByIdOptionalsInput {
89
  readonly headers?: GetFolderMetadataByIdHeaders;
90
  readonly cancellationToken?: CancellationToken;
91
}
92
export class CreateFolderMetadataByIdOptionals {
246✔
93
  readonly headers: CreateFolderMetadataByIdHeaders =
12✔
94
    new CreateFolderMetadataByIdHeaders({});
95
  readonly cancellationToken?: CancellationToken = void 0;
12✔
96
  constructor(
97
    fields: Omit<
98
      CreateFolderMetadataByIdOptionals,
99
      'headers' | 'cancellationToken'
100
    > &
101
      Partial<
102
        Pick<CreateFolderMetadataByIdOptionals, 'headers' | 'cancellationToken'>
103
      >,
104
  ) {
105
    if (fields.headers !== undefined) {
12!
106
      this.headers = fields.headers;
×
107
    }
108
    if (fields.cancellationToken !== undefined) {
12!
109
      this.cancellationToken = fields.cancellationToken;
×
110
    }
111
  }
112
}
113
export interface CreateFolderMetadataByIdOptionalsInput {
114
  readonly headers?: CreateFolderMetadataByIdHeaders;
115
  readonly cancellationToken?: CancellationToken;
116
}
117
export class UpdateFolderMetadataByIdOptionals {
246✔
118
  readonly headers: UpdateFolderMetadataByIdHeaders =
6✔
119
    new UpdateFolderMetadataByIdHeaders({});
120
  readonly cancellationToken?: CancellationToken = void 0;
6✔
121
  constructor(
122
    fields: Omit<
123
      UpdateFolderMetadataByIdOptionals,
124
      'headers' | 'cancellationToken'
125
    > &
126
      Partial<
127
        Pick<UpdateFolderMetadataByIdOptionals, 'headers' | 'cancellationToken'>
128
      >,
129
  ) {
130
    if (fields.headers !== undefined) {
6!
131
      this.headers = fields.headers;
×
132
    }
133
    if (fields.cancellationToken !== undefined) {
6!
134
      this.cancellationToken = fields.cancellationToken;
×
135
    }
136
  }
137
}
138
export interface UpdateFolderMetadataByIdOptionalsInput {
139
  readonly headers?: UpdateFolderMetadataByIdHeaders;
140
  readonly cancellationToken?: CancellationToken;
141
}
142
export class DeleteFolderMetadataByIdOptionals {
246✔
143
  readonly headers: DeleteFolderMetadataByIdHeaders =
9✔
144
    new DeleteFolderMetadataByIdHeaders({});
145
  readonly cancellationToken?: CancellationToken = void 0;
9✔
146
  constructor(
147
    fields: Omit<
148
      DeleteFolderMetadataByIdOptionals,
149
      'headers' | 'cancellationToken'
150
    > &
151
      Partial<
152
        Pick<DeleteFolderMetadataByIdOptionals, 'headers' | 'cancellationToken'>
153
      >,
154
  ) {
155
    if (fields.headers !== undefined) {
9!
156
      this.headers = fields.headers;
×
157
    }
158
    if (fields.cancellationToken !== undefined) {
9!
159
      this.cancellationToken = fields.cancellationToken;
×
160
    }
161
  }
162
}
163
export interface DeleteFolderMetadataByIdOptionalsInput {
164
  readonly headers?: DeleteFolderMetadataByIdHeaders;
165
  readonly cancellationToken?: CancellationToken;
166
}
167
export interface GetFolderMetadataQueryParams {
168
  /**
169
   * Taxonomy field values are returned in `API view` by default, meaning
170
   * the value is represented with a taxonomy node identifier.
171
   * To retrieve the `Hydrated view`, where taxonomy values are represented
172
   * with the full taxonomy node information, set this parameter to `hydrated`.
173
   * This is the only supported value for this parameter. */
174
  readonly view?: string;
175
}
176
export class GetFolderMetadataHeaders {
246✔
177
  /**
178
   * Extra headers that will be included in the HTTP request. */
179
  readonly extraHeaders?: {
3✔
180
    readonly [key: string]: undefined | string;
181
  } = {};
182
  constructor(
183
    fields: Omit<GetFolderMetadataHeaders, 'extraHeaders'> &
184
      Partial<Pick<GetFolderMetadataHeaders, 'extraHeaders'>>,
185
  ) {
186
    if (fields.extraHeaders !== undefined) {
3!
187
      this.extraHeaders = fields.extraHeaders;
×
188
    }
189
  }
190
}
191
export interface GetFolderMetadataHeadersInput {
192
  /**
193
   * Extra headers that will be included in the HTTP request. */
194
  readonly extraHeaders?: {
195
    readonly [key: string]: undefined | string;
196
  };
197
}
198
export type GetFolderMetadataByIdScope = 'global' | 'enterprise' | string;
199
export class GetFolderMetadataByIdHeaders {
246✔
200
  /**
201
   * Extra headers that will be included in the HTTP request. */
202
  readonly extraHeaders?: {
9✔
203
    readonly [key: string]: undefined | string;
204
  } = {};
205
  constructor(
206
    fields: Omit<GetFolderMetadataByIdHeaders, 'extraHeaders'> &
207
      Partial<Pick<GetFolderMetadataByIdHeaders, 'extraHeaders'>>,
208
  ) {
209
    if (fields.extraHeaders !== undefined) {
9!
210
      this.extraHeaders = fields.extraHeaders;
×
211
    }
212
  }
213
}
214
export interface GetFolderMetadataByIdHeadersInput {
215
  /**
216
   * Extra headers that will be included in the HTTP request. */
217
  readonly extraHeaders?: {
218
    readonly [key: string]: undefined | string;
219
  };
220
}
221
export type CreateFolderMetadataByIdScope = 'global' | 'enterprise' | string;
222
export type CreateFolderMetadataByIdRequestBody = {
223
  readonly [key: string]: any;
224
};
225
export class CreateFolderMetadataByIdHeaders {
246✔
226
  /**
227
   * Extra headers that will be included in the HTTP request. */
228
  readonly extraHeaders?: {
12✔
229
    readonly [key: string]: undefined | string;
230
  } = {};
231
  constructor(
232
    fields: Omit<CreateFolderMetadataByIdHeaders, 'extraHeaders'> &
233
      Partial<Pick<CreateFolderMetadataByIdHeaders, 'extraHeaders'>>,
234
  ) {
235
    if (fields.extraHeaders !== undefined) {
12!
236
      this.extraHeaders = fields.extraHeaders;
×
237
    }
238
  }
239
}
240
export interface CreateFolderMetadataByIdHeadersInput {
241
  /**
242
   * Extra headers that will be included in the HTTP request. */
243
  readonly extraHeaders?: {
244
    readonly [key: string]: undefined | string;
245
  };
246
}
247
export type UpdateFolderMetadataByIdScope = 'global' | 'enterprise' | string;
248
export type UpdateFolderMetadataByIdRequestBodyOpField =
249
  'add' | 'replace' | 'remove' | 'test' | 'move' | 'copy' | string;
250
export interface UpdateFolderMetadataByIdRequestBody {
251
  /**
252
   * The type of change to perform on the template. Some
253
   * of these are hazardous as they will change existing templates. */
254
  readonly op?: UpdateFolderMetadataByIdRequestBodyOpField;
255
  /**
256
   * The location in the metadata JSON object
257
   * to apply the changes to, in the format of a
258
   * [JSON-Pointer](https://tools.ietf.org/html/rfc6901).
259
   *
260
   * The path must always be prefixed with a `/` to represent the root
261
   * of the template. The characters `~` and `/` are reserved
262
   * characters and must be escaped in the key. */
263
  readonly path?: string;
264
  readonly value?: MetadataInstanceValue;
265
  /**
266
   * The location in the metadata JSON object to move or copy a value
267
   * from. Required for `move` or `copy` operations and must be in the
268
   * format of a [JSON-Pointer](https://tools.ietf.org/html/rfc6901). */
269
  readonly from?: string;
270
  readonly rawData?: SerializedData;
271
}
272
export class UpdateFolderMetadataByIdHeaders {
246✔
273
  /**
274
   * Extra headers that will be included in the HTTP request. */
275
  readonly extraHeaders?: {
6✔
276
    readonly [key: string]: undefined | string;
277
  } = {};
278
  constructor(
279
    fields: Omit<UpdateFolderMetadataByIdHeaders, 'extraHeaders'> &
280
      Partial<Pick<UpdateFolderMetadataByIdHeaders, 'extraHeaders'>>,
281
  ) {
282
    if (fields.extraHeaders !== undefined) {
6!
283
      this.extraHeaders = fields.extraHeaders;
×
284
    }
285
  }
286
}
287
export interface UpdateFolderMetadataByIdHeadersInput {
288
  /**
289
   * Extra headers that will be included in the HTTP request. */
290
  readonly extraHeaders?: {
291
    readonly [key: string]: undefined | string;
292
  };
293
}
294
export type DeleteFolderMetadataByIdScope = 'global' | 'enterprise' | string;
295
export class DeleteFolderMetadataByIdHeaders {
246✔
296
  /**
297
   * Extra headers that will be included in the HTTP request. */
298
  readonly extraHeaders?: {
9✔
299
    readonly [key: string]: undefined | string;
300
  } = {};
301
  constructor(
302
    fields: Omit<DeleteFolderMetadataByIdHeaders, 'extraHeaders'> &
303
      Partial<Pick<DeleteFolderMetadataByIdHeaders, 'extraHeaders'>>,
304
  ) {
305
    if (fields.extraHeaders !== undefined) {
9!
306
      this.extraHeaders = fields.extraHeaders;
×
307
    }
308
  }
309
}
310
export interface DeleteFolderMetadataByIdHeadersInput {
311
  /**
312
   * Extra headers that will be included in the HTTP request. */
313
  readonly extraHeaders?: {
314
    readonly [key: string]: undefined | string;
315
  };
316
}
317
export class FolderMetadataManager {
246✔
318
  readonly auth?: Authentication;
319
  readonly networkSession: NetworkSession = new NetworkSession({});
522✔
320
  constructor(
321
    fields: Omit<
322
      FolderMetadataManager,
323
      | 'networkSession'
324
      | 'getFolderMetadata'
325
      | 'getFolderMetadataById'
326
      | 'createFolderMetadataById'
327
      | 'updateFolderMetadataById'
328
      | 'deleteFolderMetadataById'
329
    > &
330
      Partial<Pick<FolderMetadataManager, 'networkSession'>>,
331
  ) {
332
    if (fields.auth !== undefined) {
522✔
333
      this.auth = fields.auth;
522✔
334
    }
335
    if (fields.networkSession !== undefined) {
522✔
336
      this.networkSession = fields.networkSession;
522✔
337
    }
338
  }
339
  /**
340
     * Retrieves all metadata for a given folder. This can not be used on the root
341
     * folder with ID `0`.
342
     * @param {string} folderId The unique identifier that represent a folder.
343
    
344
    The ID for any folder can be determined
345
    by visiting this folder in the web application
346
    and copying the ID from the URL. For example,
347
    for the URL `https://*.app.box.com/folder/123`
348
    the `folder_id` is `123`.
349
    
350
    The root folder of a Box account is
351
    always represented by the ID `0`.
352
    Example: "12345"
353
     * @param {GetFolderMetadataOptionalsInput} optionalsInput
354
     * @returns {Promise<Metadatas>}
355
     */
356
  async getFolderMetadata(
357
    folderId: string,
3✔
358
    optionalsInput: GetFolderMetadataOptionalsInput = {},
3✔
359
  ): Promise<Metadatas> {
360
    const optionals: GetFolderMetadataOptionals =
361
      new GetFolderMetadataOptionals({
3✔
362
        queryParams: optionalsInput.queryParams,
363
        headers: optionalsInput.headers,
364
        cancellationToken: optionalsInput.cancellationToken,
365
      });
366
    const queryParams: any = optionals.queryParams;
3✔
367
    const headers: any = optionals.headers;
3✔
368
    const cancellationToken: any = optionals.cancellationToken;
3✔
369
    const queryParamsMap: {
370
      readonly [key: string]: string;
371
    } = prepareParams({ ['view']: toString(queryParams.view) as string });
3✔
372
    const headersMap: {
373
      readonly [key: string]: string;
374
    } = prepareParams({ ...{}, ...headers.extraHeaders });
3✔
375
    const response: FetchResponse =
376
      await this.networkSession.networkClient.fetch(
3✔
377
        new FetchOptions({
378
          url: ''.concat(
379
            this.networkSession.baseUrls.baseUrl,
380
            '/2.0/folders/',
381
            (toString(folderId) as string)!,
382
            '/metadata',
383
          ) as string,
384
          method: 'GET',
385
          params: queryParamsMap,
386
          headers: headersMap,
387
          responseFormat: 'json' as ResponseFormat,
388
          auth: this.auth,
389
          networkSession: this.networkSession,
390
          cancellationToken: cancellationToken,
391
        }),
392
      );
393
    return {
3✔
394
      ...deserializeMetadatas(response.data!),
395
      rawData: response.data!,
396
    };
397
  }
398
  /**
399
     * Retrieves the instance of a metadata template that has been applied to a
400
     * folder. This can not be used on the root folder with ID `0`.
401
     * @param {string} folderId The unique identifier that represent a folder.
402
    
403
    The ID for any folder can be determined
404
    by visiting this folder in the web application
405
    and copying the ID from the URL. For example,
406
    for the URL `https://*.app.box.com/folder/123`
407
    the `folder_id` is `123`.
408
    
409
    The root folder of a Box account is
410
    always represented by the ID `0`.
411
    Example: "12345"
412
     * @param {GetFolderMetadataByIdScope} scope The scope of the metadata template.
413
    Example: "global"
414
     * @param {string} templateKey The name of the metadata template.
415
    Example: "properties"
416
     * @param {GetFolderMetadataByIdOptionalsInput} optionalsInput
417
     * @returns {Promise<MetadataFull>}
418
     */
419
  async getFolderMetadataById(
420
    folderId: string,
9✔
421
    scope: GetFolderMetadataByIdScope,
422
    templateKey: string,
423
    optionalsInput: GetFolderMetadataByIdOptionalsInput = {},
9✔
424
  ): Promise<MetadataFull> {
425
    const optionals: GetFolderMetadataByIdOptionals =
426
      new GetFolderMetadataByIdOptionals({
9✔
427
        headers: optionalsInput.headers,
428
        cancellationToken: optionalsInput.cancellationToken,
429
      });
430
    const headers: any = optionals.headers;
9✔
431
    const cancellationToken: any = optionals.cancellationToken;
9✔
432
    const headersMap: {
433
      readonly [key: string]: string;
434
    } = prepareParams({ ...{}, ...headers.extraHeaders });
9✔
435
    const response: FetchResponse =
436
      await this.networkSession.networkClient.fetch(
9✔
437
        new FetchOptions({
438
          url: ''.concat(
439
            this.networkSession.baseUrls.baseUrl,
440
            '/2.0/folders/',
441
            (toString(folderId) as string)!,
442
            '/metadata/',
443
            (toString(scope) as string)!,
444
            '/',
445
            (toString(templateKey) as string)!,
446
          ) as string,
447
          method: 'GET',
448
          headers: headersMap,
449
          responseFormat: 'json' as ResponseFormat,
450
          auth: this.auth,
451
          networkSession: this.networkSession,
452
          cancellationToken: cancellationToken,
453
        }),
454
      );
455
    return {
6✔
456
      ...deserializeMetadataFull(response.data!),
457
      rawData: response.data!,
458
    };
459
  }
460
  /**
461
     * Applies an instance of a metadata template to a folder.
462
     *
463
     * In most cases only values that are present in the metadata template
464
     * will be accepted, except for the `global.properties` template which accepts
465
     * any key-value pair.
466
     *
467
     * To display the metadata template in the Box web app the enterprise needs to be
468
     * configured to enable **Cascading Folder Level Metadata** for the user in the
469
     * admin console.
470
     * @param {string} folderId The unique identifier that represent a folder.
471
    
472
    The ID for any folder can be determined
473
    by visiting this folder in the web application
474
    and copying the ID from the URL. For example,
475
    for the URL `https://*.app.box.com/folder/123`
476
    the `folder_id` is `123`.
477
    
478
    The root folder of a Box account is
479
    always represented by the ID `0`.
480
    Example: "12345"
481
     * @param {CreateFolderMetadataByIdScope} scope The scope of the metadata template.
482
    Example: "global"
483
     * @param {string} templateKey The name of the metadata template.
484
    Example: "properties"
485
     * @param {CreateFolderMetadataByIdRequestBody} requestBody Request body of createFolderMetadataById method
486
     * @param {CreateFolderMetadataByIdOptionalsInput} optionalsInput
487
     * @returns {Promise<MetadataFull>}
488
     */
489
  async createFolderMetadataById(
490
    folderId: string,
12✔
491
    scope: CreateFolderMetadataByIdScope,
492
    templateKey: string,
493
    requestBody: CreateFolderMetadataByIdRequestBody,
494
    optionalsInput: CreateFolderMetadataByIdOptionalsInput = {},
12✔
495
  ): Promise<MetadataFull> {
496
    const optionals: CreateFolderMetadataByIdOptionals =
497
      new CreateFolderMetadataByIdOptionals({
12✔
498
        headers: optionalsInput.headers,
499
        cancellationToken: optionalsInput.cancellationToken,
500
      });
501
    const headers: any = optionals.headers;
12✔
502
    const cancellationToken: any = optionals.cancellationToken;
12✔
503
    const headersMap: {
504
      readonly [key: string]: string;
505
    } = prepareParams({ ...{}, ...headers.extraHeaders });
12✔
506
    const response: FetchResponse =
507
      await this.networkSession.networkClient.fetch(
12✔
508
        new FetchOptions({
509
          url: ''.concat(
510
            this.networkSession.baseUrls.baseUrl,
511
            '/2.0/folders/',
512
            (toString(folderId) as string)!,
513
            '/metadata/',
514
            (toString(scope) as string)!,
515
            '/',
516
            (toString(templateKey) as string)!,
517
          ) as string,
518
          method: 'POST',
519
          headers: headersMap,
520
          data: serializeCreateFolderMetadataByIdRequestBody(requestBody),
521
          contentType: 'application/json',
522
          responseFormat: 'json' as ResponseFormat,
523
          auth: this.auth,
524
          networkSession: this.networkSession,
525
          cancellationToken: cancellationToken,
526
        }),
527
      );
528
    return {
12✔
529
      ...deserializeMetadataFull(response.data!),
530
      rawData: response.data!,
531
    };
532
  }
533
  /**
534
     * Updates a piece of metadata on a folder.
535
     *
536
     * The metadata instance can only be updated if the template has already been
537
     * applied to the folder before. When editing metadata, only values that match
538
     * the metadata template schema will be accepted.
539
     *
540
     * The update is applied atomically. If any errors occur during the
541
     * application of the operations, the metadata instance will not be changed.
542
     * @param {string} folderId The unique identifier that represent a folder.
543
    
544
    The ID for any folder can be determined
545
    by visiting this folder in the web application
546
    and copying the ID from the URL. For example,
547
    for the URL `https://*.app.box.com/folder/123`
548
    the `folder_id` is `123`.
549
    
550
    The root folder of a Box account is
551
    always represented by the ID `0`.
552
    Example: "12345"
553
     * @param {UpdateFolderMetadataByIdScope} scope The scope of the metadata template.
554
    Example: "global"
555
     * @param {string} templateKey The name of the metadata template.
556
    Example: "properties"
557
     * @param {readonly UpdateFolderMetadataByIdRequestBody[]} requestBody Request body of updateFolderMetadataById method
558
     * @param {UpdateFolderMetadataByIdOptionalsInput} optionalsInput
559
     * @returns {Promise<MetadataFull>}
560
     */
561
  async updateFolderMetadataById(
562
    folderId: string,
6✔
563
    scope: UpdateFolderMetadataByIdScope,
564
    templateKey: string,
565
    requestBody: readonly UpdateFolderMetadataByIdRequestBody[],
566
    optionalsInput: UpdateFolderMetadataByIdOptionalsInput = {},
6✔
567
  ): Promise<MetadataFull> {
568
    const optionals: UpdateFolderMetadataByIdOptionals =
569
      new UpdateFolderMetadataByIdOptionals({
6✔
570
        headers: optionalsInput.headers,
571
        cancellationToken: optionalsInput.cancellationToken,
572
      });
573
    const headers: any = optionals.headers;
6✔
574
    const cancellationToken: any = optionals.cancellationToken;
6✔
575
    const headersMap: {
576
      readonly [key: string]: string;
577
    } = prepareParams({ ...{}, ...headers.extraHeaders });
6✔
578
    const response: FetchResponse =
579
      await this.networkSession.networkClient.fetch(
6✔
580
        new FetchOptions({
581
          url: ''.concat(
582
            this.networkSession.baseUrls.baseUrl,
583
            '/2.0/folders/',
584
            (toString(folderId) as string)!,
585
            '/metadata/',
586
            (toString(scope) as string)!,
587
            '/',
588
            (toString(templateKey) as string)!,
589
          ) as string,
590
          method: 'PUT',
591
          headers: headersMap,
592
          data: requestBody.map(
593
            serializeUpdateFolderMetadataByIdRequestBody,
594
          ) as readonly any[],
595
          contentType: 'application/json-patch+json',
596
          responseFormat: 'json' as ResponseFormat,
597
          auth: this.auth,
598
          networkSession: this.networkSession,
599
          cancellationToken: cancellationToken,
600
        }),
601
      );
602
    return {
6✔
603
      ...deserializeMetadataFull(response.data!),
604
      rawData: response.data!,
605
    };
606
  }
607
  /**
608
     * Deletes a piece of folder metadata.
609
     * @param {string} folderId The unique identifier that represent a folder.
610
    
611
    The ID for any folder can be determined
612
    by visiting this folder in the web application
613
    and copying the ID from the URL. For example,
614
    for the URL `https://*.app.box.com/folder/123`
615
    the `folder_id` is `123`.
616
    
617
    The root folder of a Box account is
618
    always represented by the ID `0`.
619
    Example: "12345"
620
     * @param {DeleteFolderMetadataByIdScope} scope The scope of the metadata template.
621
    Example: "global"
622
     * @param {string} templateKey The name of the metadata template.
623
    Example: "properties"
624
     * @param {DeleteFolderMetadataByIdOptionalsInput} optionalsInput
625
     * @returns {Promise<undefined>}
626
     */
627
  async deleteFolderMetadataById(
628
    folderId: string,
9✔
629
    scope: DeleteFolderMetadataByIdScope,
630
    templateKey: string,
631
    optionalsInput: DeleteFolderMetadataByIdOptionalsInput = {},
9✔
632
  ): Promise<undefined> {
633
    const optionals: DeleteFolderMetadataByIdOptionals =
634
      new DeleteFolderMetadataByIdOptionals({
9✔
635
        headers: optionalsInput.headers,
636
        cancellationToken: optionalsInput.cancellationToken,
637
      });
638
    const headers: any = optionals.headers;
9✔
639
    const cancellationToken: any = optionals.cancellationToken;
9✔
640
    const headersMap: {
641
      readonly [key: string]: string;
642
    } = prepareParams({ ...{}, ...headers.extraHeaders });
9✔
643
    const response: FetchResponse =
644
      await this.networkSession.networkClient.fetch(
9✔
645
        new FetchOptions({
646
          url: ''.concat(
647
            this.networkSession.baseUrls.baseUrl,
648
            '/2.0/folders/',
649
            (toString(folderId) as string)!,
650
            '/metadata/',
651
            (toString(scope) as string)!,
652
            '/',
653
            (toString(templateKey) as string)!,
654
          ) as string,
655
          method: 'DELETE',
656
          headers: headersMap,
657
          responseFormat: 'no_content' as ResponseFormat,
658
          auth: this.auth,
659
          networkSession: this.networkSession,
660
          cancellationToken: cancellationToken,
661
        }),
662
      );
663
    return void 0;
9✔
664
  }
665
}
666
export interface FolderMetadataManagerInput {
667
  readonly auth?: Authentication;
668
  readonly networkSession?: NetworkSession;
669
}
670
export function serializeGetFolderMetadataByIdScope(
246✔
671
  val: GetFolderMetadataByIdScope,
672
): SerializedData {
673
  return val;
×
674
}
675
export function deserializeGetFolderMetadataByIdScope(
246✔
676
  val: SerializedData,
677
): GetFolderMetadataByIdScope {
678
  if (val == 'global') {
×
679
    return val;
×
680
  }
681
  if (val == 'enterprise') {
×
682
    return val;
×
683
  }
684
  if (sdIsString(val)) {
×
685
    return val;
×
686
  }
687
  throw new BoxSdkError({
×
688
    message: "Can't deserialize GetFolderMetadataByIdScope",
689
  });
690
}
691
export function serializeCreateFolderMetadataByIdScope(
246✔
692
  val: CreateFolderMetadataByIdScope,
693
): SerializedData {
694
  return val;
×
695
}
696
export function deserializeCreateFolderMetadataByIdScope(
246✔
697
  val: SerializedData,
698
): CreateFolderMetadataByIdScope {
699
  if (val == 'global') {
×
700
    return val;
×
701
  }
702
  if (val == 'enterprise') {
×
703
    return val;
×
704
  }
705
  if (sdIsString(val)) {
×
706
    return val;
×
707
  }
708
  throw new BoxSdkError({
×
709
    message: "Can't deserialize CreateFolderMetadataByIdScope",
710
  });
711
}
712
export function serializeCreateFolderMetadataByIdRequestBody(
246✔
713
  val: CreateFolderMetadataByIdRequestBody,
714
): SerializedData {
715
  return Object.fromEntries(
12✔
716
    Object.entries(val).map(([k, v]: [string, any]) => [
36✔
717
      k,
718
      (function (v: any): any {
719
        return v;
36✔
720
      })(v),
721
    ]),
722
  ) as {
723
    readonly [key: string]: any;
724
  };
725
}
726
export function deserializeCreateFolderMetadataByIdRequestBody(
246✔
727
  val: SerializedData,
728
): CreateFolderMetadataByIdRequestBody {
729
  return sdIsMap(val)
×
730
    ? (Object.fromEntries(
731
        Object.entries(val).map(([k, v]: [string, any]) => [
×
732
          k,
733
          (function (v: any): any {
734
            return v;
×
735
          })(v),
736
        ]),
737
      ) as {
738
        readonly [key: string]: any;
739
      })
740
    : {};
741
}
742
export function serializeUpdateFolderMetadataByIdScope(
246✔
743
  val: UpdateFolderMetadataByIdScope,
744
): SerializedData {
745
  return val;
×
746
}
747
export function deserializeUpdateFolderMetadataByIdScope(
246✔
748
  val: SerializedData,
749
): UpdateFolderMetadataByIdScope {
750
  if (val == 'global') {
×
751
    return val;
×
752
  }
753
  if (val == 'enterprise') {
×
754
    return val;
×
755
  }
756
  if (sdIsString(val)) {
×
757
    return val;
×
758
  }
759
  throw new BoxSdkError({
×
760
    message: "Can't deserialize UpdateFolderMetadataByIdScope",
761
  });
762
}
763
export function serializeUpdateFolderMetadataByIdRequestBodyOpField(
246✔
764
  val: UpdateFolderMetadataByIdRequestBodyOpField,
765
): SerializedData {
766
  return val;
18✔
767
}
768
export function deserializeUpdateFolderMetadataByIdRequestBodyOpField(
246✔
769
  val: SerializedData,
770
): UpdateFolderMetadataByIdRequestBodyOpField {
771
  if (val == 'add') {
×
772
    return val;
×
773
  }
774
  if (val == 'replace') {
×
775
    return val;
×
776
  }
777
  if (val == 'remove') {
×
778
    return val;
×
779
  }
780
  if (val == 'test') {
×
781
    return val;
×
782
  }
783
  if (val == 'move') {
×
784
    return val;
×
785
  }
786
  if (val == 'copy') {
×
787
    return val;
×
788
  }
789
  if (sdIsString(val)) {
×
790
    return val;
×
791
  }
792
  throw new BoxSdkError({
×
793
    message: "Can't deserialize UpdateFolderMetadataByIdRequestBodyOpField",
794
  });
795
}
796
export function serializeUpdateFolderMetadataByIdRequestBody(
246✔
797
  val: UpdateFolderMetadataByIdRequestBody,
798
): SerializedData {
799
  return {
18✔
800
    ['op']:
801
      val.op == void 0
18!
802
        ? val.op
803
        : serializeUpdateFolderMetadataByIdRequestBodyOpField(val.op),
804
    ['path']: val.path,
805
    ['value']:
806
      val.value == void 0
18!
807
        ? val.value
808
        : serializeMetadataInstanceValue(val.value),
809
    ['from']: val.from,
810
  };
811
}
812
export function deserializeUpdateFolderMetadataByIdRequestBody(
246✔
813
  val: SerializedData,
814
): UpdateFolderMetadataByIdRequestBody {
815
  if (!sdIsMap(val)) {
×
816
    throw new BoxSdkError({
×
817
      message: 'Expecting a map for "UpdateFolderMetadataByIdRequestBody"',
818
    });
819
  }
820
  const op: undefined | UpdateFolderMetadataByIdRequestBodyOpField =
821
    val.op == void 0
×
822
      ? void 0
823
      : deserializeUpdateFolderMetadataByIdRequestBodyOpField(val.op);
824
  if (!(val.path == void 0) && !sdIsString(val.path)) {
×
825
    throw new BoxSdkError({
×
826
      message:
827
        'Expecting string for "path" of type "UpdateFolderMetadataByIdRequestBody"',
828
    });
829
  }
830
  const path: undefined | string = val.path == void 0 ? void 0 : val.path;
×
831
  const value: undefined | MetadataInstanceValue =
832
    val.value == void 0 ? void 0 : deserializeMetadataInstanceValue(val.value);
×
833
  if (!(val.from == void 0) && !sdIsString(val.from)) {
×
834
    throw new BoxSdkError({
×
835
      message:
836
        'Expecting string for "from" of type "UpdateFolderMetadataByIdRequestBody"',
837
    });
838
  }
839
  const from: undefined | string = val.from == void 0 ? void 0 : val.from;
×
840
  return {
×
841
    op: op,
842
    path: path,
843
    value: value,
844
    from: from,
845
  } satisfies UpdateFolderMetadataByIdRequestBody;
846
}
847
export function serializeDeleteFolderMetadataByIdScope(
246✔
848
  val: DeleteFolderMetadataByIdScope,
849
): SerializedData {
850
  return val;
×
851
}
852
export function deserializeDeleteFolderMetadataByIdScope(
246✔
853
  val: SerializedData,
854
): DeleteFolderMetadataByIdScope {
855
  if (val == 'global') {
×
856
    return val;
×
857
  }
858
  if (val == 'enterprise') {
×
859
    return val;
×
860
  }
861
  if (sdIsString(val)) {
×
862
    return val;
×
863
  }
864
  throw new BoxSdkError({
×
865
    message: "Can't deserialize DeleteFolderMetadataByIdScope",
866
  });
867
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc