스토리지 구성

업데이트 됨
Cover image for: 스토리지 구성

저장소 구성 리소스는 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>

예를 들어 'my-bucket'이라는 이름의 Google Cloud Storage에 버킷이 있고 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에 대한 추가 요구 사항은 스토리지 구성 자격 증명과 연결된 사용자에게 버킷의 객체에 대한 읽기 권한이 있어야한다는 것입니다. GCS에서 이는 "스토리지 오브젝트 뷰어"역할입니다. S3에는 "s3 : GetObject"정책 작업이 있습니다.

new
방금 생성되었거나 최근에 업데이트되었지만 아직 테스트되지 않았습니다.
valid
유효성 검사를 통과했으며 사용할 준비가되었습니다. 조직은이 상태에서 하나 이상의 스토리지 구성을 가지고 있어야 사용할 수 있습니다.
invalid
유효성 검사에 실패했습니다. 반드시 갱신되거나 재시험되어야합니다.
deactivated
소유하고있는 조직에 의해 꺼졌습니다.

변경 로그

2020-02-27

  • 서명 된 URL에 대한 지원을 추가합니다. 그러면 스토리지 구성 오브젝트에 signed_urls_enabledsigned_urls_expiry 추가되어 결과에 대한 서명 된 URL 생성 및 서명 된 URL의 활성 기간이 토글됩니다.

POST /configs/storage 만들기

새 저장소 구성이 만들어지면 API는 storage_config.test 작업을 만들어이를 테스트하려고 시도합니다. 이 작업은 나중에 안전하게 삭제할 수있는 config를 사용하여 작은 테스트 페이로드를 게시하기 만합니다. 작업이 성공하면 config의 상태가 valid 로 설정되고 polls와 함께 사용할 수있게됩니다. 실패 할 경우 config의 상태는 invalid 로 설정되지만 테스트 액션을 사용하여 쉽게 다시 테스트 할 수 있습니다.

조직 내의 첫 번째 유효한 저장 장치 구성이 자동으로 조직의 기본값으로 설정됩니다.

스토리지 구성의 생성은 url 속성에서 중복 제거됩니다. 따라서 동일한 url 이지만 credentials 다른 두 개의 스토리지 구성을 만들 수 없습니다.

매개 변수

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}

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 목록

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}

이 조치는 구성에 대한 변경의 유효성을 확인하기 위해 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 로 설정됩니다.

이 작업은 작업 리소스를 반환합니다.

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시 (그리니치 표준시)입니다. 시간은 현재 12:29 오후 GMT입니다.

우리는 1 일 이내에 모든 메시지에 답장하고자합니다.

우리의 멋진 지원 팀

이 기사를 개선 할 수 있습니까?

사용자의 의견을 듣고 싶습니다. 전자 메일을 보내지 말고, 의견을 남기거나, 트윗하지 마십시오. @reincubate?

© 2008 - 2024 Reincubate Ltd. 판권 소유. 영국과 웨일즈에 등록 #5189175, VAT GB151788978. Reincubate® 및 Camo®는 등록 상표입니다. 개인 정보 정책 & 자귀.