graviti.openapi.draft#

Interfaces about the draft.

Module Contents#

Functions#

create_draft(access_key, url, workspace, dataset, *, title, branch = None, description = None)

Execute the OpenAPI POST /v2/datasets/{workspace}/{dataset}/drafts.

list_drafts(access_key, url, workspace, dataset, *, state = None, branch = None, offset = None, limit = None)

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

get_draft(access_key, url, workspace, dataset, *, draft_number)

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/drafts/{draft_number}.

update_draft(access_key, url, workspace, dataset, *, draft_number, state = None, title = None, description = None)

Execute the OpenAPI PATCH /v2/datasets/{workspace}/{dataset}/drafts/{draft_number}.

graviti.openapi.draft.create_draft(access_key, url, workspace, dataset, *, title, branch=None, description=None)[source]#

Execute the OpenAPI POST /v2/datasets/{workspace}/{dataset}/drafts.

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.

  • title (str) – The draft title.

  • branch (Optional[str]) – The specified branch name. None means the default branch of the dataset.

  • description (Optional[str]) – The draft description.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> create_draft(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
...     title="draft-2",
...     branch="main",
... )
{
   "number": 2,
   "title": "draft-2",
   "description": "",
   "branch": "main",
   "state": "OPEN",
   "parent_commit_id": "85c57a7f03804ccc906632248dc8c359",
   "creator": "graviti-example",
   "created_at": "2021-03-03T18:58:10Z",
   "updated_at": "2021-03-03T18:58:10Z"
}
graviti.openapi.draft.list_drafts(access_key, url, workspace, dataset, *, state=None, branch=None, offset=None, limit=None)[source]#

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

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.

  • state (Optional[str]) – The draft state which includes “OPEN”, “CLOSED”, “COMMITTED”, “ALL” and None. None means listing open drafts.

  • branch (Optional[str]) – The branch name. None means listing drafts from all branches.

  • offset (Optional[int]) – The offset of the page. The default value of this param in OpenAPIv2 is 0.

  • limit (Optional[int]) – The limit of the page. The default value of this param in OpenAPIv2 is 128.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> list_drafts(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "graviti-example",
...     "MNIST",
... )
{
   "drafts": [
       {
           "number": 2,
           "title": "draft-2",
           "description": "",
           "branch": "main",
           "state": "OPEN",
           "parent_commit_id": "85c57a7f03804ccc906632248dc8c359",
           "creator": "graviti-example",
           "created_at": "2021-03-03T18:58:10Z",
           "updated_at": "2021-03-03T18:58:10Z"
       }
   ],
   "offset": 0,
   "record_size": 1,
   "total_count": 1
}
graviti.openapi.draft.get_draft(access_key, url, workspace, dataset, *, draft_number)[source]#

Execute the OpenAPI GET /v2/datasets/{workspace}/{dataset}/drafts/{draft_number}.

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.

  • draft_number (int) – Number of the draft.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

>>> get_draft(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "MNIST",
...     "graviti-example",
...     draft_number=2,
... )
{
   "number": 2,
   "title": "draft-2",
   "description": "",
   "branch": "main",
   "state": "OPEN",
   "parent_commit_id": "85c57a7f03804ccc906632248dc8c359",
   "creator": "graviti-example",
   "created_at": "2021-03-03T18:58:10Z",
   "updated_at": "2021-03-03T18:58:10Z"
}
graviti.openapi.draft.update_draft(access_key, url, workspace, dataset, *, draft_number, state=None, title=None, description=None)[source]#

Execute the OpenAPI PATCH /v2/datasets/{workspace}/{dataset}/drafts/{draft_number}.

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.

  • draft_number (int) – The updated draft number.

  • state (Optional[str]) – The updated draft state which could be “CLOSED” or None. Where None means no change in state.

  • title (Optional[str]) – The draft title.

  • description (Optional[str]) – The draft description.

Returns

The response of OpenAPI.

Return type

Dict[str, Any]

Examples

Update the title or description of the draft:

>>> update_draft(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "MNIST",
...     draft_number=2,
...     title="draft-3"
... )
{
   "number": 2,
   "title": "draft-3",
   "description": "",
   "branch": "main",
   "state": "OPEN",
   "parent_commit_id": "85c57a7f03804ccc906632248dc8c359",
   "creator": "graviti-example",
   "created_at": "2021-03-03T18:58:10Z",
   "updated_at": "2021-03-04T18:58:10Z"
}

Close the draft:

>>> update_draft(
...     "ACCESSKEY-********",
...     "https://api.graviti.com",
...     "MNIST",
...     draft_number=2,
...     state="CLOSED"
... )
{
   "number": 2,
   "title": "draft-3",
   "description": "",
   "branch": "main",
   "state": "CLOSED",
   "parent_commit_id": "85c57a7f03804ccc906632248dc8c359",
   "creator": "graviti-example",
   "created_at": "2021-03-03T18:58:10Z",
   "updated_at": "2021-03-05T18:58:10Z"
}