diff --git a/src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx b/src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx index af65fe7b77..90971fb85e 100644 --- a/src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx +++ b/src/content/docs/en/pages/devtools/azion-lib/usage/storage.mdx @@ -57,7 +57,7 @@ The `createClient` method has the following **parameters** and **return value**: | Parameter | Type | Description | |-----------|------|-------------| -| `config` | `Partial<{ token: string; options?: OptionsParams }>` | Configuration options for the Storage client. | +| `config` | `Partial<{ token: string; options?: AzionClientOptions }>` | Configuration options for the Storage client. | **Returns**: @@ -172,7 +172,7 @@ if (data) { | Parameter | Type | Description | |-----------|------|-------------| | `name` | `string` | The name of the bucket to be deleted. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -203,10 +203,8 @@ if (buckets) { | Parameter | Type | Description | |-----------|------|-------------| -| `options?` | `AzionBucketCollectionOptions` | Optional parameters for filtering and pagination. | -| `page?` | `number` | The page number for pagination. | -| `page_size?` | `number` | The number of items per page. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `params?` | [`AzionBucketCollectionParams`](#azionbucketcollectionparams) | Parameters for filtering and pagination. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -236,7 +234,7 @@ if (bucket) { | Parameter | Type | Description | |-----------|------|-------------| | `name` | `string` | The name of the bucket to be retrieved. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -288,9 +286,9 @@ Example: import { createObject, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: newObject, error }: AzionStorageResponse = await createObject({ - bucketName: 'my-bucket', + bucket: 'my-bucket', key: 'new-file.txt', - file: 'File content', + content: 'File content', }); if (newObject) { console.log(`Object created with key: ${newObject.key}`); @@ -304,10 +302,10 @@ if (newObject) { | Parameter | Type | Description | |-------------|----------|-----------------------------------------------| -| `bucketName` | `string` | The name of the bucket to create the object in. | -| `objectKey` | `string` | Key (name) of the object to be created. | -| `file` | `string` | The content of the file to be uploaded. | -| `debug?` | `boolean`| Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket to create the object in.| +| `key` | `string` | Key (name) of the object to be created.| +| `content` | `string` | The content of the file to be uploaded.| +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -325,7 +323,7 @@ Example: import { getObjectByKey, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: object, error }: AzionStorageResponse = await getObjectByKey({ - bucketName: 'my-bucket', + bucket: 'my-bucket', key: 'file.txt', }); if (object) { @@ -339,9 +337,9 @@ if (object) { | Parameter | Type | Description | |-----------|------|-------------| -| `bucketName` | `string` | The name of the bucket containing the object. | -| `objectKey` | `string` | The key of the object to be retrieved. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket containing the object. | +| `key` | `string` | The key of the object to be retrieved. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -359,7 +357,7 @@ Example: import { getObjects, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: objectResult, error }: AzionStorageResponse = await getObjects({ - bucketName: 'my-bucket', + bucket: 'my-bucket', }); if (objectResult) { console.log(`Retrieved ${objectResult.count} objects from the bucket`); @@ -372,8 +370,9 @@ if (objectResult) { | Parameter | Type | Description | |-----------|------|-------------| -| `bucketName` | `string` | The name of the bucket to retrieve objects from. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket to retrieve objects from. | +| `params?` | [`AzionObjectCollectionParams`](#azionobjectcollectionparams) | Parameters for filtering and pagination. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -391,9 +390,9 @@ Example: import { updateObject, AzionBucketObject } from 'azion/storage'; const { data: updatedObject, error }: AzionStorageResponse = await updateObject({ - bucketName: 'my-bucket', + bucket: 'my-bucket', key: 'file.txt', - file: 'Updated content', + content: 'Updated content', }); if (updatedObject) { console.log(`Object updated: ${updatedObject.key}`); @@ -407,10 +406,10 @@ if (updatedObject) { | Parameter | Type | Description | |-----------|------|-------------| -| `bucketName` | `string` | The name of the bucket containing the object. | -| `objectKey` | `string` | The key of the object to be updated. | -| `file` | `string` | The new content of the file. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket containing the object. | +| `key` | `string` | The key of the object to be updated. | +| `content` | `string` | The new content of the file. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -422,13 +421,13 @@ if (updatedObject) { Deletes an object from a specific bucket. -Example: +Example: ```typescript import { deleteObject, AzionDeletedBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: result, error }: AzionStorageResponse = await deleteObject({ - bucketName: 'my-bucket', + bucket: 'my-bucket', key: 'file.txt', }); if (result) { @@ -442,9 +441,9 @@ if (result) { | Parameter | Type | Description | |-----------|------|-------------| -| `bucketName` | `string` | The name of the bucket containing the object. | -| `objectKey` | `string` | The key of the object to be deleted. | -| `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `bucket` | `string` | The name of the bucket containing the object. | +| `key` | `string` | The key of the object to be deleted. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Optional parameters for the request. | **Returns**: @@ -458,14 +457,47 @@ if (result) { These are the types used by the **Storage** library and its methods: -### `ClientConfig` +### AzionBucketCollectionParams + +Parameters for filtering and pagination when retrieving a collection of buckets. + +| Parameter | Type | Description | +|-----------|------|-------------| +| `page?` | `number` | The page number for pagination. | +| `page_size?` | `number` | The number of items per page. | + +### `AzionObjectCollectionParams` + +| Parameter | Type | Description | +|-----------|------|-------------| +| `max_object_count?` | `number` | The max number of items per request. | + +### `EdgeAccessType` + +The type of access control for the bucket. + +```typescript +'read_only' | 'read_write' | 'restricted' +``` + +### `AzionClientOptions` Configuration options for the Storage client. | Parameter | Type | Description | |-----------|------|-------------| -| `token?` | `string` | Your Azion API token. | | `debug?` | `boolean` | Enables debug mode for detailed logging. | +| `force?` | `boolean` | Force the operation even if it might be destructive. | +| `env?` | [`AzionEnvironment`](#azionenvironment) | Environment to use (dev, stage, prod). | +| `external?` | `boolean` | Force using external REST API instead of built-in runtime API. | + +### AzionEnvironment + +The environment in which the client operates. + +```typescript +'development' | 'staging' | 'production' +``` ### `StorageClient` @@ -474,8 +506,8 @@ An object with methods to interact with Storage. | Method | Parameters | Return Type | |--------|------------|--------------| | `getBuckets` | `options?: BucketCollectionOptions` | `Promise>` | -| `createBucket` | `name: string, edge_access: string` | `Promise>` | -| `updateBucket` | `name: string, edge_access: string` | `Promise>` | +| `createBucket` | `name: string, edge_access: EdgeAccessType` | `Promise>` | +| `updateBucket` | `name: string, edge_access: EdgeAccessType` | `Promise>` | | `deleteBucket` | `name: string` | `Promise>` | | `getBucket` | `name: string` | `Promise>` | diff --git a/src/content/docs/pt-br/pages/devtools/azion-lib/usage/storage.mdx b/src/content/docs/pt-br/pages/devtools/azion-lib/usage/storage.mdx index 02f12ab049..339b13b103 100644 --- a/src/content/docs/pt-br/pages/devtools/azion-lib/usage/storage.mdx +++ b/src/content/docs/pt-br/pages/devtools/azion-lib/usage/storage.mdx @@ -50,13 +50,14 @@ if (data) { console.error('Failed to create bucket', error); } ``` + O método `createClient` tem os seguintes **parâmetros** e **valor de retorno**: **Parâmetros**: | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `config` | `Partial<{ token: string; options?: OptionsParams }>` | Configurações do `client` do Storage. | +| `config` | `Partial<{ token: string; options?: AzionClientOptions }>` | Configurações do `client` do Storage. | **Retorno**: @@ -134,6 +135,7 @@ if (data) { console.error('Failed to create bucket', error); } ``` + **Parâmetros**: | Parâmetro | Tipo | Descrição | @@ -170,7 +172,7 @@ if (data) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| | `name` | `string` | O nome do bucket a ser excluído. | -| `debug?` | `boolean` | Habilita o modo de debug para logs detalhados. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -201,10 +203,8 @@ if (buckets) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `options?` | `AzionBucketCollectionOptions` | Parâmetros opcionais para filtragem e paginação. | -| `page?` | `number` | O número da página para paginação. | -| `page_size?` | `number` | O número de itens por página. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `params?` | [`AzionBucketCollectionParams`](#azionbucketcollectionparams) | Parâmetros para filtragem e paginação. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -234,7 +234,7 @@ if (bucket) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| | `name` | `string` | O nome do bucket a ser atualizado. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -286,9 +286,9 @@ Exemplo: import { createObject, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: newObject, error }: AzionStorageResponse = await createObject({ - bucketName: 'my-bucket', + name: 'my-bucket', key: 'new-file.txt', - file: 'File content', + content: 'File content', }); if (newObject) { console.log(`Object created with key: ${newObject.key}`); @@ -302,10 +302,10 @@ if (newObject) { | Parâmetro | Tipo | Descrição | |-------------|----------|---------------------------------------------| -| `bucketName` | `string` | O nome do bucket onde o objeto será criado. | -| `objectKey` | `string` | A chave (nome) do objeto a ser criado. | -| `file` | `string` | O conteúdo do arquivo a ser enviado. | -| `debug?` | `boolean`| Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket onde o objeto será criado. | +| `key` | `string` | A chave (nome) do objeto a ser criado. | +| `content` | `string` | O conteúdo do arquivo a ser enviado. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -323,7 +323,7 @@ Exemplo: import { getObjectByKey, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: object, error }: AzionStorageResponse = await getObjectByKey({ - bucketName: 'my-bucket', + name: 'my-bucket', key: 'file.txt', }); if (object) { @@ -337,9 +337,9 @@ if (object) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `bucketName` | `string` | O nome do bucket contendo o objeto. | -| `objectKey` | `string` | A chave do objeto a ser recuperado. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket contendo o objeto. | +| `key` | `string` | A chave do objeto a ser recuperado. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -357,7 +357,7 @@ Exemplo: import { getObjects, AzionBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: objectResult, error }: AzionStorageResponse = await getObjects({ - bucketName: 'my-bucket', + name: 'my-bucket', }); if (objectResult) { console.log(`Retrieved ${objectResult.count} objects from the bucket`); @@ -370,8 +370,8 @@ if (objectResult) { | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `bucketName` | `string` | O nome do bucket a partir do qual os objetos devem ser recuperados. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket a partir do qual os objetos devem ser recuperados. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -389,9 +389,9 @@ Exemplo: import { updateObject, AzionBucketObject } from 'azion/storage'; const { data: updatedObject, error }: AzionStorageResponse = await updateObject({ - bucketName: 'my-bucket', + name: 'my-bucket', key: 'file.txt', - file: 'Updated content', + content: 'Updated content', }); if (updatedObject) { console.log(`Object updated: ${updatedObject.key}`); @@ -400,14 +400,15 @@ if (updatedObject) { console.error('Failed to update object', error); } ``` + **Parâmetros**: | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `bucketName` | `string` | O nome do bucket que contém o objeto. | -| `objectKey` | `string` | O nome do objeto a ser atualizado. | -| `arquivo` | `string` | O novo conteúdo do arquivo. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket que contém o objeto. | +| `key` | `string` | O nome do objeto a ser atualizado. | +| `content` | `string` | O novo conteúdo do arquivo. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -425,7 +426,7 @@ Exemplo: import { deleteObject, AzionDeletedBucketObject, AzionStorageResponse } from 'azion/storage'; const { data: result, error }: AzionStorageResponse = await deleteObject({ - bucketName: 'my-bucket', + name: 'my-bucket', key: 'file.txt', }); if (result) { @@ -434,13 +435,14 @@ if (result) { console.error('Failed to delete object', error); } ``` + **Parâmetros**: | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `bucketName` | `string` | O nome do bucket que contém o objeto. | -| `objectKey` | `string` | O nome do objeto a ser excluído. | -| `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `name` | `string` | O nome do bucket que contém o objeto. | +| `key` | `string` | O nome do objeto a ser excluído. | +| `options?` | [`AzionClientOptions`](#azionclientoptions) | Parâmetros opcionais para a requisição. | **Retorno**: @@ -454,14 +456,47 @@ if (result) { Estes são os tipos usados pela biblioteca **Storage** e seus métodos: -### `ClientConfig` +### AzionBucketCollectionParams + +Parâmetros para filtragem e paginação ao solicitar uma coleção de buckets. + +| Parâmetro | Tipo | Descrição | +|-----------|------|-------------| +| `page?` | `number` | O número da página para paginação. | +| `page_size?` | `number` | O número de itens por página. | + +### `AzionObjectCollectionParams` + +| Parâmetro | Tipo | Descrição | +|-----------|------|-------------| +| `max_object_count?` | `number` | O número máximo de objetos a serem retornados. | + +### `EdgeAccessType` + +O tipo de controle de acesso para o bucket. + +```typescript +'read_only' | 'read_write' | 'restricted' +``` + +### `AzionClientOptions` Opções de configuração para o `client` de Storage. | Parâmetro | Tipo | Descrição | |-----------|------|-------------| -| `token?` | `string` | Seu token de API da Azion. | | `debug?` | `boolean` | Ativa o modo de debug para logs detalhados. | +| `force?` | `boolean` | Força a operação mesmo que possa ser destrutiva. | +| `env?` | [`AzionEnvironment`](#azionenvironment) | Ambiente a ser utilizado (desenvolvimento, homologação, produção). | +| `external?` | `boolean` | Força o uso da API REST externa em vez da API interna do runtime. | + +### AzionEnvironment + +O ambiente em que o cliente opera. + +```typescript +'development' | 'staging' | 'production' +``` ### `StorageClient`