API Client represents a low level interface for Datalake API. All API operation can performed using this.
A low-level client for Datalake API
from abeja.datalake import APIClient
api_client = APIClient()
archive a bucket
API reference: POST /organizations/<organization_id>/buckets/<bucket_id>/archive
organization_id = "1234567890123"
bucket_id = "1230000000000"
response = api_client.archive_bucket(
organization_id, bucket_id)
organization_id (str): ORGANIZATION_ID
bucket_id (str): BUCKET_ID
dict
Response Syntax:
{
"organization_id": "1234567890123",
"bucket": {
"updated_at": "2018-06-06T09:43:34Z",
"security_method": "organization",
"name": "example-bucket",
"display_name": "example-bucket",
"description": "this is sample bucket",
"created_at": "2018-05-30T10:44:28Z",
"bucket_id": "1234567890123",
"archived": true
},
"organization_name": "abeja-inc",
"created_at": "2017-09-12T10:11:46Z",
"updated_at": "2017-09-12T10:11:46Z"
}
Unauthorized: Authentication failed
NotFound: bucket not found
Forbidden
InternalServerError
archive a channel
API reference: POST /organizations/<organization_id>/channels/<channel_id>/archive
organization_id = "1234567890123"
channel_id = "1230000000000"
response = api_client.archive_channel(
organization_id, channel_id)
organization_id (str): ORGANIZATION_ID
channel_id (str): CHANNEL_ID
dict
Response Syntax:
{
"organization_id": "1234567890123",
"channel": {
"updated_at": "2018-06-06T09:43:34Z",
"storage_type": "datalake",
"security_method": "organization",
"name": "example-channel",
"display_name": "example-channel",
"description": "this is sample channel",
"created_at": "2018-05-30T10:44:28Z",
"channel_id": "1234567890123",
"archived": true
},
"organization_name": "abeja-inc",
"created_at": "2017-09-12T10:11:46Z",
"updated_at": "2017-09-12T10:11:46Z"
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
create a bucket
API reference: POST /organizations/<organization_id>/buckets
organization_id = "1234567890123"
name = "sample bucket"
description = "sample bucket description"
response = api_client.create_bucket(organization_id, name, description)
organization_id (str): ORGANIZATION_ID
name (str): bucket name
description (str): bucket description
dict
Response Syntax:
{
"organization_id": "1234567890123",
"updated_at": "2017-09-12T10:11:46Z",
"organization_name": "abeja-inc",
"bucket": {
"updated_at": "2018-05-15T17:14:03Z",
"created_at": "2018-05-15T17:14:02Z",
"name": "test",
"description": "test",
"display_name": "test",
"bucket_id": "1230000000000"
},
"created_at": "2017-09-12T10:11:46Z"
}
BadRequest
Unauthorized
Forbidden
InternalServerError
create a channel
API reference: POST /organizations/<organization_id>/channels/
organization_id = "1234567890123"
name = "sample channel"
description = "sample channel description"
storage_type = "datalake"
response = api_client.create_channel(
organization_id, name, description, storage_type)
organization_id (str): ORGANIZATION_ID
name (str): channel name
description (str): channel description
storage_type (str): datalake or file
dict
Response Syntax:
{
"organization_id": "1234567890123",
"updated_at": "2017-09-12T10:11:46Z",
"organization_name": "abeja-inc",
"channel": {
"updated_at": "2018-05-15T17:14:03Z",
"created_at": "2018-05-15T17:14:02Z",
"storage_type": "datalake",
"name": "test",
"description": "test",
"display_name": "test",
"channel_id": "1230000000000"
},
"created_at": "2017-09-12T10:11:46Z"
}
BadRequest
Unauthorized
Forbidden
InternalServerError
delete datasource of a channel
API reference: DELETE /organizations/<organization_id>/channels/<channel_id>/datasources/<datasource_id>
organization_id = "1234567890123"
channel_id = "1230000000000"
datasource_id = "1442132811920"
response = api_client.delete_channel_datasource(
organization_id, channel_id, datasource_id)
organization_id (str): ORGANIZATION_ID
channel_id (str): CHANNEL_ID
datasource_id (str): DATASOURCE_ID
dict
Response Syntax:
{
"organization_id": "1234567890123",
"datasource": {
"secret": "c78cc952d6aa021b1701c3a7e68205cc84c4eddd",
"created_at": "2018-05-15T10:33:00Z",
"display_name": "test",
"updated_at": "2018-05-15T10:33:00Z",
"datasource_id": "1442132811920"
},
"organization_name": "abeja-inc",
"created_at": "2017-09-12T10:11:46Z",
"updated_at": "2017-09-12T10:11:46Z"
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
delete a file in a channel.
API reference: DELETE /channels/<channel_id>/<file_id>
channel_id = "1230000000000"
file_id = "20180510T110208-193d0d17-f0b1-4549-96df-651c02ccb8c9"
response = api_client.delete_channel_file(channel_id, file_id)
channel_id (str): CHANNEL_ID
file_id (str): FILE_ID
dict
Response Syntax:
{
"message": "deleted file (20180510T110208-193d0d17-f0b1-4549-96df-651c02ccb8c9)"
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
get a bucket
API reference: GET /organizations/<organization_id>/buckets/<bucket_id>
organization_id = "1234567890123"
bucket_id = "1230000000000"
response = api_client.get_bucket(organization_id, bucket_id)
organization_id (str): ORGANIZATION_ID
bucket_id (str): BUCKET_ID
dict
Response Syntax:
{
"updated_at": "2017-09-12T10:11:46Z",
"created_at": "2017-09-12T10:11:46Z",
"bucket": {
"created_at": "2018-05-15T17:14:02Z",
"name": "test",
"updated_at": "2018-05-15T17:14:03Z",
"bucket_id": "1230000000000",
"display_name": "test",
"description": "test"
},
"organization_id": "1234567890123",
"organization_name": "abeja-inc"
}
Unauthorized: Authentication failed
NotFound: bucket not found
Forbidden
InternalServerError
get a file in a bucket.
API reference: GET /organizations/<organization_id>/buckets/<bucket_id>/files/<file_id>
organization_id = "1234567890123"
bucket_id = "1230000000000"
file_id = "aaa/bbb"
response = api_client.get_bucket_file(organization_id, bucket_id, file_id)
organization_id (str): ORGANIZATION_ID
bucket_id (str): BUCKET_ID
file_id (str): FILE_ID in a bucket
dict
Response Syntax:
{
"size": 4,
"etag": "xxx",
"is_file": true,
"metadata": {
"x-abeja-meta-filename": "000000006197.jpg"
},
"last_modified": "2018-05-10T11:02:08+00:00",
"uploaded_at": "2018-05-10T11:02:08+00:00",
"url_expires_on": "2018-05-15T18:54:37+00:00",
"download_uri": "...",
"file_id": "/aaa/bbb/ddd"
}
Unauthorized: Authentication failed
NotFound: bucket not found
Forbidden
InternalServerError
get a channel
API reference: GET /organizations/<organization_id>/channels/<channel_id>
organization_id = "1234567890123"
channel_id = "1230000000000"
response = api_client.get_channel(organization_id, channel_id)
organization_id (str): ORGANIZATION_ID
channel_id (str): CHANNEL_ID
dict
Response Syntax:
{
"updated_at": "2017-09-12T10:11:46Z",
"created_at": "2017-09-12T10:11:46Z",
"channel": {
"created_at": "2018-05-15T17:14:02Z",
"name": "test",
"updated_at": "2018-05-15T17:14:03Z",
"channel_id": "1230000000000",
"storage_type": "datalake",
"display_name": "test",
"description": "test",
"archived": false
},
"organization_id": "1234567890123",
"organization_name": "abeja-inc"
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
get a file info in a channel.
API reference: GET /channels/<channel_id>/<file_id>
channel_id = "1230000000000"
file_id = "20180510T110208-193d0d17-f0b1-4549-96df-651c02ccb8c9"
response = api_client.get_channel_file_download(channel_id, file_id)
channel_id (str): CHANNEL_ID
file_id (str): FILE_ID
dict
Response Syntax:
{
"download_uri": "...",
"url_expires_on": "2018-05-15T18:57:03+00:00",
"metadata": {
"x-abeja-meta-filename": "000000009851.jpg"
},
"file_id": "20180510T110210-a2d3a218-5357-4919-8218-9090acaa147e",
"content_type": "image/jpeg",
"uploaded_at": "2018-05-10T11:02:10+00:00"
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
get upload info for a channel.
API reference: POST /channels/<channel_id>/
channel_id = "1230000000000"
content_type = "image/jpeg"
metadata = {
"x-abeja-meta-filename": "sample.jpg"
}
response = api_client.get_channel_file_upload(
channel_id, content_type, metadata)
channel_id (str): CHANNEL_ID
content_type (str): content type of a file to be uploaded
metadata (dict): key-value pair of metadata for the file
dict
Response Syntax:
{
"url_expires_on": "2018-05-15T19:06:05+00:00",
"upload_url": "...",
"uploaded_at": null,
"metadata": {},
"content_type": "image/jpeg",
"file_id": "20180515T180605-f4acc798-9afa-40a1-b500-ebce42a4fa3f"
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
get files in a bucket.
API reference: GET /organizations/<organization_id>/buckets/<bucket_id>/files
organization_id = "1234567890123"
bucket_id = "1230000000000"
response = api_client.list_bucket_files(bucket_id)
organization_id (str): ORGANIZATION_ID
bucket_id (str): BUCKET_ID
target_dir (str): Bucket target directory name
items_per_page (int): max number of files to be returned
API response includes file list after last_file_id.
query to search. JMESPATH format is available. Please refer to https://boto3.amazonaws.com/v1/documentation/api/latest/guide/paginators.html#filtering-results-with-jmespath
dict
Response Syntax:
{
"last_file_id": "/aaa/bbb/ccc",
"files": [
{
"size": 4,
"etag": "xxx",
"is_file": true,
"metadata": {
"x-abeja-meta-filename": "000000006197.jpg"
},
"last_modified": "2018-05-10T11:02:08+00:00",
"uploaded_at": "2018-05-10T11:02:08+00:00",
"url_expires_on": "2018-05-15T18:54:37+00:00",
"download_uri": "...",
"file_id": "/aaa/bbb/ddd"
},
]
}
Unauthorized: Authentication failed
NotFound: bucket not found
Forbidden
InternalServerError
get buckets
API reference: GET /organizations/<organization_id>/buckets/
organization_id = "1234567890123"
response = api_client.list_buckets(organization_id)
organization_id (str): ORGANIZATION_ID
limit (int): max number of buckets to be returned
offset (int): offset of buckets ( which starts from 0 )
dict
Response Syntax:
{
"updated_at": "2017-09-12T10:11:46Z",
"buckets": [
{
"updated_at": "2018-05-15T17:14:03Z",
"display_name": "test",
"description": "test",
"name": "test",
"bucket_id": "1230000000000",
"created_at": "2018-05-15T17:14:02Z",
},
],
"limit": 50,
"has_next": true,
"organization_name": "abeja-inc",
"offset": 0,
"created_at": "2017-09-12T10:11:46Z",
"organization_id": "1234567890123"
}
Unauthorized: Authentication failed
NotFound: bucket not found
Forbidden
InternalServerError
get datasources of a channel
API reference: GET /organizations/<organization_id>/channels/<channel_id>/datasources
organization_id = "1234567890123"
channel_id = "1230000000000"
response = api_client.list_channel_datasources(organization_id, channel_id)
organization_id (str): ORGANIZATION_ID
channel_id (str): CHANNEL_ID
dict
Response Syntax:
{
"limit": 50,
"has_next": false,
"updated_at": "2017-09-12T10:11:46Z",
"datasources": [
{
"created_at": "2018-05-15T17:37:12Z",
"datasource_id": "1442132811920",
"secret": "c123aa2751dc123235156040ed160103877b9aaa",
"updated_at": "2018-05-15T17:37:12Z",
"display_name": "test_datasource"
}
],
"organization_name": "abeja-inc",
"created_at": "2017-09-12T10:11:46Z",
"offset": 0,
"organization_id": "1234567890123"
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
get files in a channel.
API reference: GET /channels/<channel_id>/
channel_id = "1230000000000"
response = api_client.list_channel_files(channel_id)
channel_id (str): CHANNEL_ID
start (str): start date of target uploaded files
end (str): end date of target uploaded files
timezone (str): timezone of specified start and end date
items_per_page (int): max number of files to be returned
the order of the file list. multiple items can be specified by separating with commas (,). It is possible to sort in descending order by specifying a hyphen (-) in front of the item. By default, the list is sorted by uploaded_at in ascending order.
token for offset of files. other params should not be used with next_page_token.
query to search. It is possible to filter what contain specific value by describing like “x-abeja-meta-filename:filename”.
dict
Response Syntax:
{
"next_page_token": null,
"files": [
{
"content_type": "image/jpeg",
"metadata": {
"x-abeja-meta-filename": "000000006197.jpg"
},
"uploaded_at": "2018-05-10T11:02:08+00:00",
"url_expires_on": "2018-05-15T18:54:37+00:00",
"download_uri": "...",
"file_id": "20180510T110208-193d0d17-f0b1-4549-96df-651c02ccb8c9"
},
]
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
get channels
API reference: GET /organizations/<organization_id>/channels/
organization_id = "1234567890123"
response = api_client.list_channels(organization_id)
organization_id (str): ORGANIZATION_ID
limit (int): [optional] max number of channels to be returned
offset (int): [optional] offset of channels ( which starts from 0 )
filter_archived (bool): [optional] If true
, include archived jobs, otherwise exclude archived jobs. (default: false
)
dict
Response Syntax:
{
"updated_at": "2017-09-12T10:11:46Z",
"channels": [
{
"updated_at": "2018-05-15T17:14:03Z",
"display_name": "test",
"description": "test",
"name": "test",
"channel_id": "1230000000000",
"created_at": "2018-05-15T17:14:02Z",
"storage_type": "datalake",
"archived": false
},
],
"limit": 50,
"has_next": true,
"organization_name": "abeja-inc",
"offset": 0,
"created_at": "2017-09-12T10:11:46Z",
"organization_id": "1234567890123"
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
edit a bucket
API reference: PATCH /organizations/<organization_id>/buckets/<bucket_id>
organization_id = "1234567890123"
bucket_id = "1230000000000"
name = 'updated_name'
description = 'updated_description'
response = api_client.patch_bucket(organization_id, bucket_id, name, description)
organization_id (str): ORGANIZATION_ID
bucket_id (str): BUCKET_ID
name (str): bucket name
description (str): bucket description
dict
Response Syntax:
{
"bucket": {
"description": "updated_description",
"updated_at": "2018-05-15T17:30:21Z",
"created_at": "2018-05-15T17:14:02Z",
"display_name": "updated_description",
"bucket_id": "1230000000000",
"name": "updated_name"
},
"organization_name": "abeja-inc",
"updated_at": "2017-09-12T10:11:46Z",
"created_at": "2017-09-12T10:11:46Z",
"organization_id": "1234567890123"
}
BadRequest
Unauthorized: Authentication failed
Forbidden
NotFound: bucket not found
InternalServerError
edit a channel
API reference: PATCH /organizations/<organization_id>/channels/<channel_id>
organization_id = "1234567890123"
channel_id = "1230000000000"
name = 'updated_name'
description = 'updated_description'
response = api_client.patch_channel(organization_id, channel_id, name, description)
organization_id (str): ORGANIZATION_ID
channel_id (str): CHANNEL_ID
name (str): channel name
description (str): channel description
dict
Response Syntax:
{
"channel": {
"storage_type": "datalake",
"description": "updated_description",
"updated_at": "2018-05-15T17:30:21Z",
"created_at": "2018-05-15T17:14:02Z",
"display_name": "updated_description",
"channel_id": "1230000000000",
"name": "updated_name"
},
"organization_name": "abeja-inc",
"updated_at": "2017-09-12T10:11:46Z",
"created_at": "2017-09-12T10:11:46Z",
"organization_id": "1234567890123"
}
BadRequest
Unauthorized: Authentication failed
Forbidden
NotFound: channel not found
InternalServerError
upload a file to a channel.
API reference: POST /channels/<channel_id>/upload
channel_id = "1230000000000"
content_type = "image/jpeg"
metadata = {
"x-abeja-meta-filename": "sample.jpg"
}
with open('sample.jpg', 'rb') as f:
response = api_client.post_channel_file_upload(
channel_id, f, content_type, metadata=metadata)
channel_id (str): CHANNEL_ID
file_obj (a file-like object) : a file-like object to upload. It must implement the read method, and must return bytes.
content_type (str): content type of a file to be uploaded
metadata (dict): [optional] key-value pair of metadata for the file
the file will be deleted after the specified time.
conflict_target (str): [optional] return 409 Conflict when the same value of specified key already exists in channel.
dict
Response Syntax:
{
"uploaded_at": null,
"metadata": {
"x-abeja-meta-filename": "sample.jpg"
},
"lifetime": "1day",
"content_type": "image/jpeg",
"file_id": "20180515T180605-f4acc798-9afa-40a1-b500-ebce42a4fa3f"
}
BadRequest: given parameters are invalid
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
connect a datasource with a channel
API reference: PUT /organizations/<organization_id>/channels/<channel_id>/datasources/<datasource_id>
organization_id = "1234567890123"
channel_id = "1230000000000"
datasource_id = "1442132811920"
response = api_client.put_channel_datasource(organization_id,
channel_id, datasource_id)
organization_id (str): ORGANIZATION_ID
channel_id (str): CHANNEL_ID
datasource_id (str): DATASOURCE_ID
dict
Response Syntax:
{
"organization_id": "1234567890123",
"datasource": {
"datasource_id": "1442132811920",
"created_at": "2018-05-15T10:33:00Z",
"display_name": "test",
"secret": "c78cc952d6aa021b1701c3a7e68205cc84c4eddd",
"updated_at": "2018-05-15T10:33:00Z"
},
"organization_name": "abeja-inc",
"created_at": "2017-09-12T10:11:46Z",
"updated_at": "2017-09-12T10:11:46Z"
}
Unauthorized: Authentication failed
Forbidden
NotFound: channel not found
Conflict
InternalServerError
update a file lifetime in a channel.
API reference: PUT /channels/<channel_id>/<file_id>/lifetime
channel_id = "1230000000000"
file_id = "20180510T110208-193d0d17-f0b1-4549-96df-651c02ccb8c9"
lifetime = "1week"
response = api_client.put_channel_file_life(channel_id, file_id, life)
channel_id (str): CHANNEL_ID
file_id (str): FILE_ID
lifetime (str): string value of file lifetime
dict
Response Syntax:
{
"channel_id": "1230000000000",
"file_id": "20180510T110208-193d0d17-f0b1-4549-96df-651c02ccb8c9",
"lifetime": "1week"
}
BadRequest
Unauthorized: Authentication failed
NotFound: file not found
Forbidden
InternalServerError
update a file metadata in a channel.
API reference: PUT /channels/<channel_id>/<file_id>/metadata
channel_id = "1230000000000"
file_id = "20180510T110208-193d0d17-f0b1-4549-96df-651c02ccb8c9"
metadata = {
"x-abeja-meta-filename": "test.csv"
}
response = api_client.put_channel_file_metadata(channel_id, file_id, metadata)
channel_id (str): CHANNEL_ID
file_id (str): FILE_ID
metadata (dict): key-value pair of metadata for the file
dict
Response Syntax:
{
"uploaded_at": "2018-05-10T11:02:10+00:00"
"download_uri": "...",
"url_expires_on": "2018-05-15T18:57:03+00:00",
"metadata": {
"x-abeja-sys-meta-organizationid": "1200123565071",
"x-abeja-meta-filename": "test.csv"
},
"file_id": "20180510T110208-193d0d17-f0b1-4549-96df-651c02ccb8c9",
"content_type": "text/csv",
}
BadRequest
Unauthorized: Authentication failed
NotFound: file not found
Forbidden
InternalServerError
unarchive a bucket
API reference: POST /organizations/<organization_id>/buckets/<bucket_id>/unarchive
organization_id = "1234567890123"
bucket_id = "1230000000000"
response = api_client.unarchive_bucket(
organization_id, bucket_id)
organization_id (str): ORGANIZATION_ID
bucket_id (str): BUCKET_ID
dict
Response Syntax:
{
"organization_id": "1234567890123",
"bucket": {
"updated_at": "2018-06-06T09:43:34Z",
"security_method": "organization",
"name": "example-bucket",
"display_name": "example-bucket",
"description": "this is sample bucket",
"created_at": "2018-05-30T10:44:28Z",
"bucket_id": "1234567890123",
"archived": false
},
"organization_name": "abeja-inc",
"created_at": "2017-09-12T10:11:46Z",
"updated_at": "2017-09-12T10:11:46Z"
}
Unauthorized: Authentication failed
NotFound: bucket not found
Forbidden
InternalServerError
unarchive a channel
API reference: POST /organizations/<organization_id>/channels/<channel_id>/unarchive
organization_id = "1234567890123"
channel_id = "1230000000000"
response = api_client.unarchive_channel(
organization_id, channel_id)
organization_id (str): ORGANIZATION_ID
channel_id (str): CHANNEL_ID
dict
Response Syntax:
{
"organization_id": "1234567890123",
"channel": {
"updated_at": "2018-06-06T09:43:34Z",
"storage_type": "datalake",
"security_method": "organization",
"name": "example-channel",
"display_name": "example-channel",
"description": "this is sample channel",
"created_at": "2018-05-30T10:44:28Z",
"channel_id": "1234567890123",
"archived": false
},
"organization_name": "abeja-inc",
"created_at": "2017-09-12T10:11:46Z",
"updated_at": "2017-09-12T10:11:46Z"
}
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
upload a file to a bucket.
API reference: POST /organizations/<organization_id>/buckets/<bucket_id>/files
organization_id = "1234567890123"
bucket_id = "1230000000000"
file_location = "target/sample.jpg"
content_type = "image/jpeg"
metadata = {
"x-abeja-meta-filename": "target/sample.jpg"
}
with open('sample.jpg', 'rb') as f:
response = api_client.upload_bucket_file(
bucket_id, f, content_type, metadata=metadata)
organization_id (str): ORGANIZATION_ID
bucket_id (str): BUCKET_ID
file_obj (a file-like object) : a file-like object to upload. It must implement the read method, and must return bytes.
file_location (str): file location to store
content_type (str): content type of a file to be uploaded
metadata (dict): [optional] key-value pair of metadata for the file
the file will be deleted after the specified time.
dict
Response Syntax:
{
"uploaded_at": null,
"metadata": {
"x-abeja-meta-filename": "sample.jpg"
},
"lifetime": "1day",
"content_type": "image/jpeg",
"file_id": "20180515T180605-f4acc798-9afa-40a1-b500-ebce42a4fa3f"
}
BadRequest: given parameters are invalid
Unauthorized: Authentication failed
NotFound: channel not found
Forbidden
InternalServerError
upload files on your specified directory to a bucket.
API reference: POST /organizations/<organization_id>/buckets/<bucket_id>/files
organization_id = "1234567890123"
bucket_id = "1230000000000"
target_dir = "./data"
response = api_client.upload_bucket_files(organization_id, bucket_id, target_dir)
organization_id (str): ORGANIZATION_ID
bucket_id (str): BUCKET_ID
target_dir (str) : a directory to upload. Directory structure will be kept on a bucket.
the file will be deleted after the specified time.
dict
Response Syntax:
{
"messages": [
{ "message": "Upload failed. file (20180510T110208-193d0d17-f0b1-4549-96df-651c02ccb8c9)" },
]
}
BadRequest: given parameters are invalid
Unauthorized: Authentication failed
NotFound: bucket not found
Forbidden
InternalServerError