# Create or Update Storage instance

put ` https://app.mk.io/api/v1/projects/:project_name/media/storage/:storage_name`

Create or update a Storage instance. Only the description, credentials and privateLinkServiceConnection details are updatable.

RBAC Capability Required: `infra.storage.create` or `infra.storage.update`

## Authentication

Authorization Bearer

Bearer authentication of the form `Bearer <token>`, where token is your auth token.

## Path parameters

| Parameter            | Type   | Required | Description                                                    |
|----------------------|--------|----------|----------------------------------------------------------------|
| project_name         | string | Yes      | Name of the project.                                          |
| storage_name         | string | Yes      | Name of the storage instance.                                  |

## Request

This endpoint expects an object.

spec | object | Required | The specification of the storage instance.

### Variants:

1. **Microsoft.Storage** 
   * Documentation: [AzureStorageSpecCreate](https://docs.mediakind.com/api-reference/media-api/schemas/azurestoragespeccreate)

* credential | object | [AzureCredentialCreate](https://docs.mediakind.com/api-reference/media-api/schemas/azurecredentialcreate) Optional 
       * sasToken | string | Required | SAS Token for Azure Storage Account, including leading ?
       * description | string or null | Optional | Description of the storage.
       * privateLinkServiceConnection | object or null | [PrivateLinkServiceConnectionNullable](https://docs.mediakind.com/api-reference/media-api/schemas/privatelinkserviceconnectionnullable) Optional 
       * requestMessage | string | Required | A message passed to the owner of the remote resource with this connection request.
       * resourceGroupName | string | Required | The name of the resource group containing the storage account.
       * storageAccountName | string | Required | The name of the storage account.
       * subscriptionId | string | Required | The ID of the Azure subscription containing the storage account.
       * type | enum | Required | The type of storage. Allowed values: Microsoft.Storage, AWS.S3, Google.Storage.
       * url | string | Required | HTTP(S) URL required for access to the storage.

2. **AWS.S3** 
   * Documentation: [AWSStorageSpecCreate](https://docs.mediakind.com/api-reference/media-api/schemas/awsstoragespeccreate)

* bucketName | string | Required | The name of the AWS S3 bucket.
   * credential | object | [AWSCredential](https://docs.mediakind.com/api-reference/media-api/schemas/awscredential) Optional 
       * accessKeyId | string | Required | The access key ID for the bucket.
       * secretAccessKey | string | Required | The secret access key for the bucket.
       * description | string or null | Optional | Description of the storage.
       * type | enum | Required | The type of storage.
       * url | string | Required | The URL of the S3 bucket.

3. **Google.Storage** 
   * Documentation: [GoogleStorageSpecCreate](https://docs.mediakind.com/api-reference/media-api/schemas/googlestoragespeccreate)

* bucketName | string | Required | The name of the Google Storage bucket.
   * credential | object | [GoogleCredential](https://docs.mediakind.com/api-reference/media-api/schemas/googlecredential) Optional 
       * gac | map from strings to string | Required | Google Application Credentials in JSON format.
       * description | string or null | Optional | Description of the storage.
       * type | enum | Required | The type of storage.

## Response

- `200`: Storage instance successfully updated
   - metadata | object | Required | Metadata about the storage instance.
       - id | string | Required | The ID of the resource.
       - created | string | Optional | The time when the resource was created.
       - updated | string | Optional | The time when the resource was last updated.

- `201`: Storage instance successfully created

## Errors

- `400`: Bad Request
   - error | object | Required | Pertinent information about the error.
       - code | string | Required | The error code.
       - detail | string | Required | The error message.

- `401`: Unauthorized
- `403`: Forbidden
- `404`: Not Found
- `429`: Too Many Requests
- `500`: Internal Server Error
