graviti.openapi.policy#

Interfaces about the dataset policy.

Module Contents#

Functions#

get_object_policy(access_key, url, owner, dataset, *, actions = None, is_internal = None, expired = None)

Execute the OpenAPI GET /v2/datasets/{owner}/{dataset}/policy/object.

graviti.openapi.policy.get_object_policy(access_key, url, owner, dataset, *, actions=None, is_internal=None, expired=None)[source]#

Execute the OpenAPI GET /v2/datasets/{owner}/{dataset}/policy/object.

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

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

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

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

  • actions (Optional[str]) – The specific actions including “GET” and “PUT”. The default value in the OpenAPI is “GET”. 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:

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

Request permission to put dataset data:

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