graviti.openapi.object#

Interfaces about the dataset object.

Module Contents#

Functions#

get_object_permission(access_key, url, workspace, dataset, *, actions, is_internal = None, expired = None)

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/objects/permissions.

copy_objects(access_key, url, workspace, target_dataset, *, source_dataset, keys)

Execute the OpenAPI POST /v2/datasets/{workspace}/{target_dataset}/objects/copy.

graviti.openapi.object.get_object_permission(access_key, url, workspace, dataset, *, actions, is_internal=None, expired=None)[source]#

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/objects/permissions.

Parameters
  • access_key (str) – User’s access key.

  • url (str) – The URL of the graviti website.

  • workspace (str) – The workspace of the dataset.

  • dataset (str) – Name of the dataset, unique for a user.

  • actions (str) – The specific actions including “GET” and “PUT”. Supports multiple actions, which need to be separated by |, like “GET|PUT”.

  • is_internal (Optional[bool]) – Whether to return the intranet upload address, the default value in the OpenAPI is False.

  • expired (Optional[int]) – Token expiry time in seconds. It cannot be negative.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

Request permission to get dataset data from OSS:

>>> get_object_permission(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     actions="GET",
... )
{
    "backend_type":"OSS",
    "expire_at":"2022-07-12T06:07:52Z",
    "permission": {
        "AccessKeyId":"LTAI4FjgXD3yFJUaasdasd",
        "AccessKeySecret":"LTAI4FjgXD3yFJJKasdad",
        "SecurityToken":"CAISrgJ1q6Ft5B2yfSjIr5bkKILdaseqw",
        "bucket":"content-store-dev",
        "endpoint":"content-store-dev.oss-cn-qingdao.aliyuncs.com"
    }
}

Request permission to put dataset data to OSS:

>>> get_object_permission(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     actions="PUT",
... )
{
    "backend_type":"OSS",
    "expire_at":"2022-07-12T06:07:52Z",
    "permission": {
        "AccessKeyId":"LTAI4FjgXD3yFJUaasdasd",
        "AccessKeySecret":"LTAI4FjgXD3yFJJKasdad",
        "SecurityToken":"CAISrgJ1q6Ft5B2yfSjIr5bkKILdaseqw",
        "bucket":"content-store-dev",
        "endpoint":"content-store-dev.oss-cn-qingdao.aliyuncs.com",
        "prefix":"051dd0676cc74f548a7e9b7ace45c26b/"
    }
}

Request permission to get dataset data from AZURE:

>>> get_object_permission(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     actions="GET",
... )
{
    "backend_type":"AZURE",
    "expire_at":"2022-07-12T06:07:52Z",
    "permission": {
        "container_name":"graviti210304",
        "account_name":"gra220303",
        "sas_param":"se=2022-07-21T10%3A07Z&sig=*******",
        "endpoint_prefix":"https://gra220303.blob.core.window.net/graviti210304/"
    }
}

Request permission to put dataset data to AZURE:

>>> get_object_permission(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     actions="PUT",
... )
{
    "backend_type":"AZURE",
    "expire_at":"2022-07-12T06:07:52Z",
    "permission": {
        "container_name":"graviti210304",
        "account_name":"gra220303",
        "prefix":"examplePrefix/",
        "sas_param":"se=2022-07-21T10%3A07Z&sig=*******",
        "endpoint_prefix":"https://gra220303.blob.core.window.net/graviti210304/"
    }
}

Request permission to get dataset data from S3:

>>> get_object_permission(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     actions="GET",
... )
{
    "backend_type":"S3",
    "expire_at":"2022-07-12T06:07:52Z",
    "permission": {
        "AccessKeyId":"ASIAQHT******",
        "AccessKeySecret":"Y6x2a2cHIlJdx******",
        "SecurityToken":"FwoGZXIvYXdzEH0aDGYBu******",
        "bucket":"fat-dataplatform",
        "endpoint":"s3.amazonaws.com",
        "region":"us-west-1"
    }
}

Request permission to put dataset data to S3:

>>> get_object_permission(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     actions="PUT",
... )
{
    "backend_type":"S3",
    "expire_at":"2022-07-12T06:07:52Z",
    "permission": {
        "AccessKeyId":"ASIAQHT******",
        "AccessKeySecret":"Y6x2a2cHIlJdx******",
        "SecurityToken":"FwoGZXIvYXdzEH0aDGYBu******",
        "bucket":"fat-dataplatform",
        "endpoint":"s3.amazonaws.com",
        "prefix":"051dd0676cc74f548a7e9b7ace45c26b/",
        "region":"us-west-1"
    }
}
graviti.openapi.object.copy_objects(access_key, url, workspace, target_dataset, *, source_dataset, keys)[source]#

Execute the OpenAPI POST /v2/datasets/{workspace}/{target_dataset}/objects/copy.

Parameters
  • access_key (str) – User’s access key.

  • url (str) – The URL of the graviti website.

  • workspace (str) – The workspace of the dataset.

  • target_dataset (str) – The name of the target dataset.

  • source_dataset (str) – The name of the source dataset.

  • keys (List[str]) – The keys of the objects which need to be copied.

Returns

The response of OpenAPI.

Return type

Dict[str, List[str]]

Examples

>>> copy_objects(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     source_dataset="EMINST",
...     keys=["xxxxx/xxxxx, xxxxx/xxxxx"]
... )
{
    keys: [
        "yyyyyyy/yyyyyy",
        "yyyyyyy/yyyyyy"
    ]
}