# Storage

Kubemq gcp-storage target connector allows services using kubemq server to access google storage server.

## Prerequisites

The following required to run the gcp-storage target connector:

* kubemq cluster
* gcp-storage set up
* kubemq-source deployment

## Configuration

storage target connector configuration properties:

| Properties Key | Required | Description           | Example                     |
| -------------- | -------- | --------------------- | --------------------------- |
| credentials    | yes      | gcp credentials files | "\<google json credentials" |

Example:

```yaml
bindings:
  - name: kubemq-query-gcp-storage
    source:
      kind: kubemq.query
      name: kubemq-query
      properties:
        address: "kubemq-cluster:50000"
        client_id: "kubemq-query-gcp-storage-connector"
        auth_token: ""
        channel: "query.gcp.storage"
        group:   ""
        auto_reconnect: "true"
        reconnect_interval_seconds: "1"
        max_reconnects: "0"
    target:
      kind: gcp.storage
      name: gcp-storage
      properties:
        credentials: 'json'
```

## Usage

### Create bucket

create a new bucket under storage

Create bucket metadata settings:

| Metadata Key   | Required | Description                | Possible values           |
| -------------- | -------- | -------------------------- | ------------------------- |
| method         | yes      | type of method             | "create\_bucket"          |
| bucket         | yes      | bucket name                | "bucket name"             |
| storage\_class | yes      | gcp-storage\_class         | "storage\_class"          |
| project\_id    | yes      | gcp storage project\_id    | "/myproject"              |
| location       | yes      | gcp storage valid location | "gcp-supported locations" |

Example:

```javascript
{
  "metadata": {
    "method": "create_bucket",
    "bucket": "myBucketName",
    "storage_class": "COLDLINE",
    "project_id": "MyID",
    "location": "us"
  },
  "data": null
}
```

### Upload file

upload a file to selected bucket

Upload file metadata settings:

| Metadata Key | Required | Description                        | Possible values                                      |
| ------------ | -------- | ---------------------------------- | ---------------------------------------------------- |
| method       | yes      | type of method                     | "upload"                                             |
| bucket       | yes      | bucket name                        | "bucket name"                                        |
| object       | yes      | object name to save the file under | "anyString"                                          |
| path         | yes      | path to the file to upload         | "\<absolute or relative path to file/filename.type>" |

Example:

```javascript
{
  "metadata": {
    "method": "upload",
    "bucket": "myBucketName",
    "object": "MyFile",
    "path": "./myFile.yaml"
  },
  "data": null
}
```

### Delete file

delete file from a bucket

Delete file metadata settings:

| Metadata Key | Required | Description    | Possible values |
| ------------ | -------- | -------------- | --------------- |
| method       | yes      | type of method | "delete"        |
| bucket       | yes      | bucket name    | "bucket name"   |
| object       | yes      | object name    | "anyString"     |

Example:

```javascript
{
  "metadata": {
    "method": "delete",
    "bucket": "myBucketName",
    "object": "MyFile"
  },
  "data": null
}
```

### Download file

download file from bucket by object name

Download file metadata settings:

| Metadata Key | Required | Description    | Possible values |
| ------------ | -------- | -------------- | --------------- |
| method       | yes      | type of method | "download"      |
| bucket       | yes      | bucket name    | "bucket name"   |
| object       | yes      | object name    | "anyString"     |

Example:

```javascript
{
  "metadata": {
    "method": "download",
    "bucket": "myBucketName",
    "object": "MyFile"
  },
  "data": null
}
```

### Rename file

rename an object under the same bucket

Rename file metadata settings:

| Metadata Key   | Required | Description     | Possible values |
| -------------- | -------- | --------------- | --------------- |
| method         | yes      | type of method  | "rename"        |
| bucket         | yes      | bucket name     | "bucket name"   |
| object         | yes      | old object name | "anyString"     |
| rename\_object | yes      | new object name | "anyString"     |

Example:

```javascript
{
  "metadata": {
    "method": "rename",
    "bucket": "myBucketName",
    "object": "MyOldFile",
    "rename_object": "MyNewFile"
  },
  "data": null
}
```

### Copy file

copy file from one bucket to another

Copy file metadata settings:

| Metadata Key   | Required | Description                      | Possible values |
| -------------- | -------- | -------------------------------- | --------------- |
| method         | yes      | type of method                   | "copy"          |
| bucket         | yes      | old bucket name                  | "bucket name"   |
| dst\_bucket    | yes      | new bucket name(can be the same) | "bucket name"   |
| object         | yes      | old object name                  | "anyString"     |
| rename\_object | yes      | new object name(can be the same) | "anyString"     |

Example:

```javascript
{
  "metadata": {
    "method": "copy",
    "bucket": "myOldBucketName",
    "dst_bucket": "myNewBucketName",
    "object": "MyOldFile",
    "rename_object": "MyNewFile"
  },
  "data": null
}
```

### Move file

move a file from one bucket to another

Move file metadata settings:

| Metadata Key   | Required | Description                      | Possible values |
| -------------- | -------- | -------------------------------- | --------------- |
| method         | yes      | type of method                   | "move"          |
| bucket         | yes      | old bucket name                  | "bucket name"   |
| dst\_bucket    | yes      | new bucket name(can be the same) | "bucket name"   |
| object         | yes      | old object name                  | "anyString"     |
| rename\_object | yes      | new object name(can be the same) | "anyString"     |

Example:

```javascript
{
  "metadata": {
    "method": "move",
    "bucket": "myOldBucketName",
    "dst_bucket": "myNewBucketName",
    "object": "MyOldFile",
    "rename_object": "MyNewFile"
  },
  "data": null
}
```

### List files

list all files from a bucket

List files metadata settings:

| Metadata Key | Required | Description     | Possible values |
| ------------ | -------- | --------------- | --------------- |
| method       | yes      | type of method  | "list"          |
| bucket       | yes      | old bucket name | "bucket name"   |

Example:

```javascript
{
  "metadata": {
    "method": "list",
    "bucket": "myBucketName"
  },
  "data": null
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.kubemq.io/configuration/connectors/kubemq-targets/gcp/storage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
