> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> ClickHouse Cloud OpenAPI を使用して ClickPipes をプログラムで管理するためのリファレンスです。

# ClickPipes OpenAPI リファレンス

すべての ClickPipes タイプは、[ClickHouse Cloud OpenAPI](/ja/api-reference/organization/get-list-of-available-organizations#tag/ClickPipes) を使用してプログラムから作成、更新、削除できます。このページでは、認証と利用可能な ClickPipes エンドポイントについて説明し、各 ClickPipe タイプごとに `curl` リクエストの例を示します。

<div id="authentication">
  ## 認証
</div>

ClickHouse Cloud API は HTTP Basic 認証を使用します。対象のサービスに対する権限を持つ API キー (key ID + key secret) が必要です。作成手順については、[API キーの管理](/ja/products/cloud/features/admin-features/api/openapi)を参照してください。

以下の例を実行する前に、次の環境変数を設定してください。

```bash theme={null}
export KEY_ID=<your_key_id>
export KEY_SECRET=<your_key_secret>
export ORG_ID=<your_organization_id>
export SERVICE_ID=<your_service_id>
```

<div id="base-url">
  ## ベースURL
</div>

```bash theme={null}
https://api.clickhouse.cloud/v1
```

<div id="endpoints">
  ## エンドポイント
</div>

すべての ClickPipes エンドポイントは、ClickHouse Cloud サービスのスコープに属します。

| Method   | Path                                                                                     | Description              |
| -------- | ---------------------------------------------------------------------------------------- | ------------------------ |
| `GET`    | `/organizations/{organizationId}/services/{serviceId}/clickpipes`                        | すべての ClickPipes を一覧表示    |
| `POST`   | `/organizations/{organizationId}/services/{serviceId}/clickpipes`                        | ClickPipe を作成            |
| `GET`    | `/organizations/{organizationId}/services/{serviceId}/clickpipes/{clickPipeId}`          | ClickPipe を取得            |
| `PATCH`  | `/organizations/{organizationId}/services/{serviceId}/clickpipes/{clickPipeId}`          | ClickPipe を更新            |
| `DELETE` | `/organizations/{organizationId}/services/{serviceId}/clickpipes/{clickPipeId}`          | ClickPipe を削除            |
| `GET`    | `/organizations/{organizationId}/services/{serviceId}/clickpipes/{clickPipeId}/settings` | ClickPipe の設定を取得         |
| `PUT`    | `/organizations/{organizationId}/services/{serviceId}/clickpipes/{clickPipeId}/settings` | ClickPipe の設定を更新         |
| `PATCH`  | `/organizations/{organizationId}/services/{serviceId}/clickpipes/{clickPipeId}/scaling`  | ClickPipe のスケーリングを更新     |
| `PATCH`  | `/organizations/{organizationId}/services/{serviceId}/clickpipes/{clickPipeId}/state`    | ClickPipe の状態を更新 (開始/停止) |

CDC (変更データキャプチャ)  ClickPipes (Postgres、MySQL、MongoDB) では、共有 CDC (変更データキャプチャ)  インフラストラクチャのスケーリング用に、組織レベルの追加エンドポイントが用意されています。

| Method  | Path                                                    | Description                             |
| ------- | ------------------------------------------------------- | --------------------------------------- |
| `GET`   | `/organizations/{organizationId}/clickpipes/cdcScaling` | CDC (変更データキャプチャ)  ClickPipes のスケーリングを取得 |
| `PATCH` | `/organizations/{organizationId}/clickpipes/cdcScaling` | CDC (変更データキャプチャ)  ClickPipes のスケーリングを更新 |

各エンドポイントの完全なリクエスト/レスポンス スキーマについては、[Swagger UI](/ja/api-reference/organization/get-list-of-available-organizations#tag/ClickPipes) を参照してください。

<div id="examples">
  ## 例
</div>

<div id="list-clickpipes">
  ### ClickPipes を一覧表示する
</div>

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```

<div id="get-clickpipe">
  ### ClickPipeを取得する
</div>

```bash theme={null}
CLICKPIPE_ID=<your_clickpipe_id>

curl -u "$KEY_ID:$KEY_SECRET" \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes/$CLICKPIPE_ID"
```

<div id="stop-start-clickpipe">
  ### ClickPipe の停止または開始
</div>

```bash theme={null}
# 停止
curl -u "$KEY_ID:$KEY_SECRET" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{"action": "stop"}' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes/$CLICKPIPE_ID/state"

# 開始
curl -u "$KEY_ID:$KEY_SECRET" \
  -X PATCH \
  -H "Content-Type: application/json" \
  -d '{"action": "start"}' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes/$CLICKPIPE_ID/state"
```

<div id="delete-clickpipe">
  ### ClickPipe を削除する
</div>

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X DELETE \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes/$CLICKPIPE_ID"
```

<div id="creating-clickpipes">
  ## ClickPipes の作成
</div>

`POST /clickpipes` のリクエストボディは、ソースタイプによって異なります。以下の例では、サポートされている各 ClickPipe タイプの構造を示します。正式な JSON スキーマについては、[Swagger UI](/ja/api-reference/organization/get-list-of-available-organizations#tag/ClickPipes) を参照してください。

<div id="create-kafka">
  ### Kafka
</div>

サポートされている Kafka 互換のソース: `kafka`, `confluent`, `msk`, `azureeventhub`, `redpanda`, `warpstream`.

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Kafka ClickPipe",
    "source": {
      "kafka": {
        "type": "confluent",
        "format": "JSONEachRow",
        "brokers": "broker.example.com:9092",
        "topics": "my_topic",
        "consumerGroup": "clickpipes-consumer-group",
        "authentication": "PLAIN",
        "credentials": {
          "username": "my_user",
          "password": "my_password"
        }
      }
    },
    "destination": {
      "table": "my_table",
      "managedTable": true,
      "tableDefinition": {
        "engine": { "type": "MergeTree" }
      },
      "columns": [
        { "name": "id", "type": "UInt64" },
        { "name": "message", "type": "String" },
        { "name": "timestamp", "type": "DateTime" }
      ]
    }
  }' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```

<div id="create-kinesis">
  ### Amazon Kinesis
</div>

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Kinesis ClickPipe",
    "source": {
      "kinesis": {
        "format": "JSONEachRow",
        "streamName": "my-stream",
        "region": "us-east-1",
        "iteratorType": "TRIM_HORIZON",
        "authentication": "IAM_USER",
        "accessKey": {
          "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
          "secretKey": "<secret_key>"
        }
      }
    },
    "destination": {
      "table": "my_table",
      "managedTable": true,
      "tableDefinition": {
        "engine": { "type": "MergeTree" }
      },
      "columns": [
        { "name": "id", "type": "UInt64" },
        { "name": "message", "type": "String" }
      ]
    }
  }' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```

<div id="create-s3">
  ### Amazon S3
</div>

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My S3 ClickPipe",
    "source": {
      "objectStorage": {
        "type": "s3",
        "url": "https://my-bucket.s3.amazonaws.com/data/*.json",
        "format": "JSONEachRow",
        "authentication": "IAM_USER",
        "accessKey": {
          "accessKeyId": "AKIAIOSFODNN7EXAMPLE",
          "secretKey": "<secret_key>"
        }
      }
    },
    "destination": {
      "table": "my_table",
      "managedTable": true,
      "tableDefinition": {
        "engine": { "type": "MergeTree" }
      },
      "columns": [
        { "name": "id", "type": "UInt64" },
        { "name": "message", "type": "String" }
      ]
    }
  }' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```

<div id="create-gcs">
  ### Google Cloud Storage
</div>

`serviceAccountKey` には、GCP のサービス アカウント JSON キーファイルの内容を base64 エンコードした値を指定する必要があります。

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My GCS ClickPipe",
    "source": {
      "objectStorage": {
        "type": "gcs",
        "url": "gs://my-bucket/data/*.json",
        "format": "JSONEachRow",
        "authentication": "SERVICE_ACCOUNT",
        "serviceAccountKey": "<base64_encoded_service_account_json>"
      }
    },
    "destination": {
      "table": "my_table",
      "managedTable": true,
      "tableDefinition": {
        "engine": { "type": "MergeTree" }
      },
      "columns": [
        { "name": "id", "type": "UInt64" },
        { "name": "message", "type": "String" }
      ]
    }
  }' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```

<div id="create-abs">
  ### Azure Blob Storage
</div>

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Azure Blob ClickPipe",
    "source": {
      "objectStorage": {
        "type": "azureblobstorage",
        "azureContainerName": "my-container",
        "path": "data/*.json",
        "format": "JSONEachRow",
        "authentication": "CONNECTION_STRING",
        "connectionString": "DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;EndpointSuffix=core.windows.net"
      }
    },
    "destination": {
      "table": "my_table",
      "managedTable": true,
      "tableDefinition": {
        "engine": { "type": "MergeTree" }
      },
      "columns": [
        { "name": "id", "type": "UInt64" },
        { "name": "message", "type": "String" }
      ]
    }
  }' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```

<div id="create-postgres">
  ### Postgres CDC (変更データキャプチャ)
</div>

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My Postgres CDC ClickPipe",
    "source": {
      "postgres": {
        "host": "postgres.example.com",
        "port": 5432,
        "database": "mydb",
        "credentials": {
          "username": "postgres_user",
          "password": "<password>"
        },
        "settings": {
          "replicationMode": "cdc"
        },
        "tableMappings": [
          {
            "sourceSchemaName": "public",
            "sourceTable": "users",
            "targetTable": "public_users"
          }
        ]
      }
    },
    "destination": {
      "database": "default"
    }
  }' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```

<div id="create-mysql">
  ### MySQL CDC (変更データキャプチャ)
</div>

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My MySQL CDC ClickPipe",
    "source": {
      "mysql": {
        "host": "mysql.example.com",
        "port": 3306,
        "credentials": {
          "username": "mysql_user",
          "password": "<password>"
        },
        "settings": {
          "replicationMode": "cdc"
        },
        "tableMappings": [
          {
            "sourceSchemaName": "mydb",
            "sourceTable": "orders",
            "targetTable": "mydb_orders"
          }
        ]
      }
    },
    "destination": {
      "database": "default"
    }
  }' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```

<div id="create-mongodb">
  ### MongoDB CDC (変更データキャプチャ)
</div>

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My MongoDB CDC ClickPipe",
    "source": {
      "mongodb": {
        "uri": "mongodb+srv://cluster0.example.mongodb.net",
        "readPreference": "secondaryPreferred",
        "credentials": {
          "username": "mongo_user",
          "password": "<password>"
        },
        "settings": {
          "replicationMode": "cdc"
        },
        "tableMappings": [
          {
            "sourceDatabaseName": "mydb",
            "sourceCollection": "users",
            "targetTable": "mydb_users"
          }
        ]
      }
    },
    "destination": {
      "database": "default"
    }
  }' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```

<div id="create-bigquery">
  ### BigQuery
</div>

`serviceAccountFile` には、GCP のサービスアカウント JSON キーファイルの内容を base64 エンコードしたものを指定する必要があります。

```bash theme={null}
curl -u "$KEY_ID:$KEY_SECRET" \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{
    "name": "My BigQuery ClickPipe",
    "source": {
      "bigquery": {
        "snapshotStagingPath": "gs://my-staging-bucket/staging/",
        "credentials": {
          "serviceAccountFile": "<base64_encoded_service_account_json>"
        },
        "settings": {
          "replicationMode": "snapshot"
        },
        "tableMappings": [
          {
            "sourceDatasetName": "my_dataset",
            "sourceTable": "my_table",
            "targetTable": "my_bigquery_table"
          }
        ]
      }
    },
    "destination": {
      "database": "default"
    }
  }' \
  "https://api.clickhouse.cloud/v1/organizations/$ORG_ID/services/$SERVICE_ID/clickpipes"
```
