-
Notifications
You must be signed in to change notification settings - Fork 17
[NO ISSUE] docs: update Storage azion lib usage #1727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
egermano
wants to merge
3
commits into
aziontech:main
Choose a base branch
from
egermano:docs/update-lib-storage
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+134
−67
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -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<AzionBucketObject> = 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<AzionBucketObject> = 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<AzionBucketObjects> = 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<AzionBucketObject> = 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. | | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
| | `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<AzionDeletedBucketObject> = 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<AzionStorageResponse<AzionBucketCollection>>` | | ||||||||
| | `createBucket` | `name: string, edge_access: string` | `Promise<AzionStorageResponse<AzionBucket>>` | | ||||||||
| | `updateBucket` | `name: string, edge_access: string` | `Promise<AzionStorageResponse<AzionBucket>>` | | ||||||||
| | `createBucket` | `name: string, edge_access: EdgeAccessType` | `Promise<AzionStorageResponse<AzionBucket>>` | | ||||||||
| | `updateBucket` | `name: string, edge_access: EdgeAccessType` | `Promise<AzionStorageResponse<AzionBucket>>` | | ||||||||
| | `deleteBucket` | `name: string` | `Promise<AzionStorageResponse<AzionDeletedBucket>>` | | ||||||||
| | `getBucket` | `name: string` | `Promise<AzionStorageResponse<AzionBucket>>` | | ||||||||
|
|
||||||||
|
|
||||||||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.