ストレージ設定

更新しました
Cover image for: ストレージ設定

storage configリソースは、ポーリング結果に属するデータをAPIが格納できる場所を記述します。ストレージ設定で指定されたすべての場所は、 Google Cloud StorageまたはAmazon S3(AWS)のいずれかのクラウドストレージバケットである必要があります。

属性

名前タイプ説明
id storage config ID Resource identifier.
resource string, always storage_config Resource type specifier.
organisation organisation ID The organisation the resource belongs to.
type string One of: gs, s3. This is a read-only attribute generated from the url.
url string A URL representing the target to which results will be published.
credentials dictionary A dictionary containing the credential information used by the API to authenticate against the storage service.
signed_urls_enabled optional bool, default false Whether signed URLs should be generated for results published using the storage config.
signed_urls_expiry optional timedelta If signed URLs are enabled, the time, in seconds, they will remain valid.
state string One of: 'new', 'valid', 'invalid', 'deactivated'.
date_created datetime When the resource was created.

タイプ

gs
Google Cloud Storageのストレージ設定タイプ。サービスアカウントの認証情報が必要です。
s3
Amazon S3(AWS)ストレージ設定タイプ。 AWSユーザーの認証情報が必要です。

URL

url属性は次の形式に従います。

<type>://<bucket name>/<path within bucket>

たとえば、Google Cloud Storageに 'my-bucket'という名前のバケットがあり、このバケット内の 'results'という名前のフォルダにAPIを公開すると、 urlは次のようになります。

gs://my-bucket/results

資格情報

Google Cloud Storageの認証情報

APIは、 credentials属性が次の形式の辞書であることを期待しています。

{
    "type": "service_account",
    "auth_uri": "https://accounts.google.com/o/oauth2/auth",
    "client_id": "<Google Cloud Platform client ID>",
    "token_uri": "https://oauth2.googleapis.com/token",
    "project_id": "<Google Cloud Platform project ID>",
    "private_key": "<Service Account private key>",
    "client_email": "<Service Account ID>.iam.gserviceaccount.com",
    "private_key_id": "<Service Account private key ID>",
    "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/<Service Account ID>.iam.gserviceaccount.com",
    "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs"
}

これは、Google Cloud Platformコンソールからサービスアカウントキーを作成するときに出力されるJSONファイルと完全に一致します。

エクスポートされたJSONファイルの認証情報を使用してストレージ設定を簡単に設定するために、 ricloud-pyには簡単なcliコマンドが含まれています。

ricloud storage-config create --url "gs://<bucket name>" --credentials <path to JSON file>

Amazon S3の認証情報

APIは、 credentials属性が次の形式の辞書であることを期待していました。

{
    "user_name": "<aws user name>",
    "access_key_id": "<aws user access key ID>",
    "secret_access_key": "<aws user secret access key>",
}

上記の認証情報ペイロードでは、 user_nameパラメーターは、アクセスキーが属するAWS IAMユーザーのユーザー名に対応しています。これは、管理および監査の目的で含めるのに役立ちます。

これは、AWSコンソールに表示される詳細から手動で作成することも、 ricloud-pyのcliコマンドを使用してエクスポート可能なCSVファイルから作成することもできます。

ricloud storage-config create --url "s3://<bucket name>" --credentials <path to CSV file>

署名付きURL

署名付きURLは、時間制限があり、クラウドストレージバケット内のアイテムにアクセスするための事前承認済みリンクです。それらにより、実装では、クライアントがアクセスするための資格情報を持たない、または資格情報をまったく持たない特定のアイテムへの安全なアクセスが可能になります。

ストレージ構成で署名付きURLが有効になっている場合、その構成を使用して公開された結果には、 signed_url属性が設定されます。詳細については、 結果属性を参照してください。

署名付きURLは、Google Cloud Storage( GCS署名付きURLドキュメントへのリンク )とAWS S3( S3ドキュメントへのリンク )の両方でサポートされています。

署名付きURLのもう1つの要件は、ストレージ構成の認証情報に関連付けられているユーザーが、バケット内のオブジェクトに対する読み取り権限を持っている必要があることです。 GCSでは、これは「ストレージオブジェクト閲覧者」の役割です。 S3には、「s3:GetObject」ポリシーアクションがあります。

new
作成または最近更新されたばかりですが、まだテストされていません。
valid
検証に合格し、使用する準備が整いました。組織が使用可能になるには、この状態で少なくとも1つのストレージ構成が必要です。
invalid
検証テストに失敗しました。更新または再テストする必要があります。
deactivated
所有組織によって無効にされています。

変更ログ

2020-02-27

  • 署名付きURLのサポートを追加します。これにより、ストレージ構成オブジェクトにsigned_urls_enabledおよびsigned_urls_expiry追加され、結果の署名付きURLの生成と、署名付きURLがアクティブである必要のある期間が切り替えられます。

POST /configs/storage作成します。

新しいストレージ設定が作成されると、APIはstorage_config.testタスクを作成してテストを試みます。このタスクは設定を使用して小さなテストペイロードを単純に公開します。これは後で安全に削除できます。操作が成功すると、設定の状態はvalid設定され、ポーリングで使用できるようになります。失敗した場合、設定の状態はinvalidに設定されinvalidが、これはテストアクションを使用して簡単に再テストできます。

組織内の最初の有効なストレージ構成が自動的に組織のデフォルトとして設定されます。

ストレージ構成の作成はurl属性で重複排除されることに注意してください。そのため、同じurlで異なるcredentials使用して2つのストレージ構成を作成することはできません。

パラメーター

name type description
url required The storage configuration URL for your bucket.
credentials required The storage configuration credentials for your bucket.

cURLを使う

ここで、認証情報ディクショナリの内容は、Googleクラウドサービスアカウントの設定中に生成されたJSON認証情報ファイルの内容をコピーしたものです。

curl https://ricloud-api.reincubate.com/configs/storage \
  -X POST \
  -H 'Authorization: Token <your key_token>' \
  -H 'Content-Type: application/json' \
  -d '{
  "url": "gs://my-storage-bucket",
  "credentials": {
      "type": "service_account",
      "auth_uri": "https://accounts.google.com/o/oauth2/auth",
      "client_id": "<Google Cloud Platform client ID>",
      "token_uri": "https://oauth2.googleapis.com/token",
      "project_id": "<Google Cloud Platform project ID>",
      "private_key": "<Service Account private key>",
      "client_email": "<Service Account ID>.iam.gserviceaccount.com",
      "private_key_id": "<Service Account private key ID>",
      "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/<Service Account ID>.iam.gserviceaccount.com",
      "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs"
  }
}'

ricloud-pyを使う

import json
import ricloud

with open("<path to JSON file>", 'r') as credentials_file:
    credentials = json.load(credentials_file)

storage_config = ricloud.StorageConfig.create(
    url='gs://my-storage-bucket',
    credentials=credentials
)

GET /configs/storage/{storage_config ID}取得しGET /configs/storage/{storage_config ID}

cURLを使う

curl https://ricloud-api.reincubate.com/configs/storage/<storage_config ID> \
  -H 'Authorization: Token <your key_token>'

ricloud-pyを使う

import ricloud

storage_config = ricloud.StorageConfig.retrieve(<storage_config ID>)

GET /configs/storage一覧表示しGET /configs/storage

deactivated状態のストレージ構成はデフォルトで非表示になっており、明示的なフィルタリングによってのみ一覧表示できます。

パラメーター

名前タイプ説明
type string Filter by backing bucket's type.
state string Filter by the configuration's state.
date_created datetime filter Filter by resouce creation date.

cURLを使う

curl https://ricloud-api.reincubate.com/configs/storage \
  -H 'Authorization: Token <your key_token>'

ricloud-pyを使う

import ricloud

storage_configs = ricloud.StorageConfig.list()

POST /configs/storage/{storage_config ID}更新しPOST /configs/storage/{storage_config ID}

このアクションは設定に加えられる変更の妥当性をチェックするためにstorage_config.testタスクを作成します。

パラメーター

名前タイプ説明
url string Update the URL to point to a different bucket or location within the bucket. Note that the type of a bucket cannot be changed through this operation.
credentials dictionary Update the credentials.
state string Only to new or deactivated.

cURLを使う

curl https://ricloud-api.reincubate.com/configs/storage/<storage_config ID> \
  -X POST \
  -H 'Authorization: Token <your key_token>' \
  -H 'Content-Type: application/json' \
  -d '{
    "url": "gs://my-storage-bucket/subfolder"
}'

ricloud-pyを使う

import ricloud

storage_config = ricloud.StorageConfig.update_with_id(
  <storage_config ID>, url="gs://my-storage-bucket/subfolder"
)

# OR

storage_config = ricloud.StorageConfig.retrieve(<storage_config ID>)

storage_config.update(url='gs://my-storage-bucket/subfolder')

削除DELETE /configs/storage/{storage_config ID}

APIからストレージ設定を完全に削除します。これにより、APIに格納されているすべての関連資格情報が削除されます。

cURLを使う

curl https://ricloud-api.reincubate.com/configs/storage/<storage_config ID> \
  -X DELETE \
  -H 'Authorization: Token <your key_token>'

ricloud-pyを使う

ricloud-py v3.0.0以降。

import ricloud

ricloud.StorageConfig.delete_with_id(<storage_config ID>)

# OR

storage_config = ricloud.StorageConfig.retrieve(<storage_config ID>)

storage_config.delete()

テストPOST /configs/storage/{storage_config ID}/test

この操作により、ストレージ設定の有効性を再テストできます。テストの結果に応じて、設定の状態がvalidまたはinvalid設定されvalid

このアクションはタスクリソースを返すことに注意してください。

cURLを使う

curl https://ricloud-api.reincubate.com/configs/storage/<storage_config ID>/test \
  -H 'Authorization: Token <your key_token>'

ricloud-pyを使う

import ricloud

test_task = ricloud.StorageConfig.test_with_id(<storage_config ID>)

# OR

storage_config = ricloud.StorageConfig.retrieve(<storage_config ID>)

test_task = storage_config.test()

どのように我々は助けることができます?

サポートチームがお手伝いします!

営業時間は月曜日から金曜日の午前9時から午後5時(GMT)です。 時間は現在 5:04 AM GMTです。

1営業日以内に、お返事を差し上げます。メールアドレスはこちら。

私たちの素晴らしいサポートチーム

この記事を改善できますか?

ユーザーからの連絡をお待ちしています。電子メールを送信したり、コメントを残したり、ツイートしたりしないでください。 @reincubate?

© 2008 - 2024 Reincubate Ltd. 無断複写・転載を禁じます。 イングランドとウェールズに登録 #5189175, VAT GB151788978. Reincubate®およびCamo®は登録商標です。 個人情報保護方針 & 条項.