Skip to content

Commit 6690563

Browse files
egermanogabriel-alves-azionVitorAEltz
authored
[NO ISSUE] docs: update Storage azion lib usage (#1727)
* docs: update Storage azion lib usage * fix: update `edge_access` types * Update src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx Co-authored-by: GabrielAzion <116839080+GabrielAzion@users.noreply.github.com> * Update src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx Co-authored-by: GabrielAzion <116839080+GabrielAzion@users.noreply.github.com> --------- Co-authored-by: GabrielAzion <116839080+GabrielAzion@users.noreply.github.com> Co-authored-by: Vitor Eltz <107409234+VitorAEltz@users.noreply.github.com>
1 parent 5b0f585 commit 6690563

2 files changed

Lines changed: 136 additions & 67 deletions

File tree

src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx

Lines changed: 69 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ The `createClient` method has the following **parameters** and **return value**:
5757

5858
| Parameter | Type | Description |
5959
|-----------|------|-------------|
60-
| `config` | `Partial<{ token: string; options?: OptionsParams }>` | Configuration options for the Storage client. |
60+
| `config` | `Partial<{ token: string; options?: AzionClientOptions }>` | Configuration options for the Storage client. |
6161

6262
**Returns**:
6363

@@ -172,7 +172,7 @@ if (data) {
172172
| Parameter | Type | Description |
173173
|-----------|------|-------------|
174174
| `name` | `string` | The name of the bucket to be deleted. |
175-
| `debug?` | `boolean` | Enables debug mode for detailed logging. |
175+
| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. |
176176

177177
**Returns**:
178178

@@ -203,10 +203,8 @@ if (buckets) {
203203

204204
| Parameter | Type | Description |
205205
|-----------|------|-------------|
206-
| `options?` | `AzionBucketCollectionOptions` | Optional parameters for filtering and pagination. |
207-
| `page?` | `number` | The page number for pagination. |
208-
| `page_size?` | `number` | The number of items per page. |
209-
| `debug?` | `boolean` | Enables debug mode for detailed logging. |
206+
| `params?` | [`AzionBucketCollectionParams`](#azionbucketcollectionparams) | Parameters for filtering and pagination. |
207+
| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. |
210208

211209
**Returns**:
212210

@@ -236,7 +234,7 @@ if (bucket) {
236234
| Parameter | Type | Description |
237235
|-----------|------|-------------|
238236
| `name` | `string` | The name of the bucket to be retrieved. |
239-
| `debug?` | `boolean` | Enables debug mode for detailed logging. |
237+
| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. |
240238

241239
**Returns**:
242240

@@ -288,9 +286,9 @@ Example:
288286
import { createObject, AzionBucketObject, AzionStorageResponse } from 'azion/storage';
289287

290288
const { data: newObject, error }: AzionStorageResponse<AzionBucketObject> = await createObject({
291-
bucketName: 'my-bucket',
289+
bucket: 'my-bucket',
292290
key: 'new-file.txt',
293-
file: 'File content',
291+
content: 'File content',
294292
});
295293
if (newObject) {
296294
console.log(`Object created with key: ${newObject.key}`);
@@ -304,10 +302,11 @@ if (newObject) {
304302

305303
| Parameter | Type | Description |
306304
|-------------|----------|-----------------------------------------------|
307-
| `bucketName` | `string` | The name of the bucket to create the object in. |
308-
| `objectKey` | `string` | Key (name) of the object to be created. |
309-
| `file` | `string` | The content of the file to be uploaded. |
310-
| `debug?` | `boolean`| Enables debug mode for detailed logging. |
305+
| `bucket` | `string` | The name of the bucket to create the object in.|
306+
| `key` | `string` | Key (name) of the object to be created.|
307+
| `content` | [`ContentObjectStorage`](#contentobjectstorage) | The content of the file to be uploaded. Accepts `string`, `ArrayBuffer`, `ReadableStream`, or `Uint8Array`.|
308+
| `params?` | `{ content_type?: string }` | Optional object parameters, including the content type of the file. |
309+
| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. |
311310

312311
**Returns**:
313312

@@ -325,7 +324,7 @@ Example:
325324
import { getObjectByKey, AzionBucketObject, AzionStorageResponse } from 'azion/storage';
326325

327326
const { data: object, error }: AzionStorageResponse<AzionBucketObject> = await getObjectByKey({
328-
bucketName: 'my-bucket',
327+
bucket: 'my-bucket',
329328
key: 'file.txt',
330329
});
331330
if (object) {
@@ -339,9 +338,9 @@ if (object) {
339338

340339
| Parameter | Type | Description |
341340
|-----------|------|-------------|
342-
| `bucketName` | `string` | The name of the bucket containing the object. |
343-
| `objectKey` | `string` | The key of the object to be retrieved. |
344-
| `debug?` | `boolean` | Enables debug mode for detailed logging. |
341+
| `bucket` | `string` | The name of the bucket containing the object. |
342+
| `key` | `string` | The key of the object to be retrieved. |
343+
| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. |
345344

346345
**Returns**:
347346

@@ -359,7 +358,7 @@ Example:
359358
import { getObjects, AzionBucketObject, AzionStorageResponse } from 'azion/storage';
360359

361360
const { data: objectResult, error }: AzionStorageResponse<AzionBucketObjects> = await getObjects({
362-
bucketName: 'my-bucket',
361+
bucket: 'my-bucket',
363362
});
364363
if (objectResult) {
365364
console.log(`Retrieved ${objectResult.count} objects from the bucket`);
@@ -372,8 +371,9 @@ if (objectResult) {
372371

373372
| Parameter | Type | Description |
374373
|-----------|------|-------------|
375-
| `bucketName` | `string` | The name of the bucket to retrieve objects from. |
376-
| `debug?` | `boolean` | Enables debug mode for detailed logging. |
374+
| `bucket` | `string` | The name of the bucket to retrieve objects from. |
375+
| `params?` | [`AzionObjectCollectionParams`](#azionobjectcollectionparams) | Parameters for filtering and pagination. |
376+
| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. |
377377

378378
**Returns**:
379379

@@ -391,9 +391,9 @@ Example:
391391
import { updateObject, AzionBucketObject } from 'azion/storage';
392392

393393
const { data: updatedObject, error }: AzionStorageResponse<AzionBucketObject> = await updateObject({
394-
bucketName: 'my-bucket',
394+
bucket: 'my-bucket',
395395
key: 'file.txt',
396-
file: 'Updated content',
396+
content: 'Updated content',
397397
});
398398
if (updatedObject) {
399399
console.log(`Object updated: ${updatedObject.key}`);
@@ -407,10 +407,11 @@ if (updatedObject) {
407407

408408
| Parameter | Type | Description |
409409
|-----------|------|-------------|
410-
| `bucketName` | `string` | The name of the bucket containing the object. |
411-
| `objectKey` | `string` | The key of the object to be updated. |
412-
| `file` | `string` | The new content of the file. |
413-
| `debug?` | `boolean` | Enables debug mode for detailed logging. |
410+
| `bucket` | `string` | The name of the bucket containing the object. |
411+
| `key` | `string` | The key of the object to be updated. |
412+
| `content` | [`ContentObjectStorage`](#contentobjectstorage) | The new content of the file. Accepts `string`, `ArrayBuffer`, `ReadableStream`, or `Uint8Array`. |
413+
| `params?` | `{ content_type?: string }` | Optional object parameters, including the content type of the file. |
414+
| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. |
414415

415416
**Returns**:
416417

@@ -422,13 +423,13 @@ if (updatedObject) {
422423

423424
Deletes an object from a specific bucket.
424425

425-
Example:
426+
Example:
426427

427428
```typescript
428429
import { deleteObject, AzionDeletedBucketObject, AzionStorageResponse } from 'azion/storage';
429430

430431
const { data: result, error }: AzionStorageResponse<AzionDeletedBucketObject> = await deleteObject({
431-
bucketName: 'my-bucket',
432+
bucket: 'my-bucket',
432433
key: 'file.txt',
433434
});
434435
if (result) {
@@ -442,9 +443,9 @@ if (result) {
442443

443444
| Parameter | Type | Description |
444445
|-----------|------|-------------|
445-
| `bucketName` | `string` | The name of the bucket containing the object. |
446-
| `objectKey` | `string` | The key of the object to be deleted. |
447-
| `debug?` | `boolean` | Enables debug mode for detailed logging. |
446+
| `bucket` | `string` | The name of the bucket containing the object. |
447+
| `key` | `string` | The key of the object to be deleted. |
448+
| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. |
448449

449450
**Returns**:
450451

@@ -458,14 +459,47 @@ if (result) {
458459

459460
These are the types used by the **Storage** library and its methods:
460461

461-
### `ClientConfig`
462+
### AzionBucketCollectionParams
463+
464+
Parameters for filtering and pagination when retrieving a collection of buckets.
465+
466+
| Parameter | Type | Description |
467+
|-----------|------|-------------|
468+
| `page?` | `number` | The page number for pagination. |
469+
| `page_size?` | `number` | The number of items per page. |
470+
471+
### `AzionObjectCollectionParams`
472+
473+
| Parameter | Type | Description |
474+
|-----------|------|-------------|
475+
| `max_object_count?` | `number` | The max number of items per request. |
476+
477+
### `EdgeAccessType`
478+
479+
The type of access control for the bucket.
480+
481+
```typescript
482+
'read_only' | 'read_write' | 'restricted'
483+
```
484+
485+
### `AzionClientOptions`
462486

463487
Configuration options for the Storage client.
464488

465489
| Parameter | Type | Description |
466490
|-----------|------|-------------|
467-
| `token?` | `string` | Your Azion API token. |
468491
| `debug?` | `boolean` | Enables debug mode for detailed logging. |
492+
| `force?` | `boolean` | Force the operation even if it might be destructive. |
493+
| `env?` | [`AzionEnvironment`](#azionenvironment) | Environment to use (dev, stage, prod). |
494+
| `external?` | `boolean` | Force using external REST API instead of built-in runtime API. |
495+
496+
### AzionEnvironment
497+
498+
The environment in which the client operates.
499+
500+
```typescript
501+
'development' | 'staging' | 'production'
502+
```
469503

470504
### `StorageClient`
471505

@@ -474,8 +508,8 @@ An object with methods to interact with Storage.
474508
| Method | Parameters | Return Type |
475509
|--------|------------|--------------|
476510
| `getBuckets` | `options?: BucketCollectionOptions` | `Promise<AzionStorageResponse<AzionBucketCollection>>` |
477-
| `createBucket` | `name: string, edge_access: string` | `Promise<AzionStorageResponse<AzionBucket>>` |
478-
| `updateBucket` | `name: string, edge_access: string` | `Promise<AzionStorageResponse<AzionBucket>>` |
511+
| `createBucket` | `name: string, edge_access: EdgeAccessType` | `Promise<AzionStorageResponse<AzionBucket>>` |
512+
| `updateBucket` | `name: string, edge_access: EdgeAccessType` | `Promise<AzionStorageResponse<AzionBucket>>` |
479513
| `deleteBucket` | `name: string` | `Promise<AzionStorageResponse<AzionDeletedBucket>>` |
480514
| `getBucket` | `name: string` | `Promise<AzionStorageResponse<AzionBucket>>` |
481515

0 commit comments

Comments
 (0)