Getting Started
Scenarios
This section describes the basic procedure of calling OMS APIs by creating an object data migration task.
For details, see Calling APIs.
Involved APIs
- Obtaining a User Token Through Password Authentication: used to obtain the user token for authentication
- Creating a Migration Task: used to create a migration task using the source and destination AK/SK pairs
- Querying Migration Tasks by Task IDs: used to query the task details based on the migration task ID to check whether the migration task has been created successfully
Prerequisites
- You have obtained the AK/SK pair of the source platform account.
- You have obtained AK/SK of the destination platform account. For details about how to obtain AKs and SKs, see Creating Access Keys (AK and SK).
- You have obtained the endpoints of IAM and OMS. For details, see Regions and Endpoints.
- You have obtained the region where the source bucket locates.
- The destination bucket has been created. For details, see Creating a Bucket.
- You have obtained the region where the destination bucket locates. For details, see Viewing Basic Information of a Bucket.
- You have obtained the project ID. For details, see Obtaining a Project ID.
Creating an Application
Assume that you have obtained the required information shown as follows, which are examples. You need to replace them based on the actual situation.
- IAM endpoint: iam_endpoint
- OMS endpoint: oms.cn-north-1.myhuaweicloud.com
- Project ID: 0215ef11e49d4743be23dd97a156xxxx
- Region where the source bucket locates: cn-beijing
- Region where the destination bucket locates: cn-north-1
- Source AK: source_ak
- Source SK: source_sk
- Destination AK: destination_ak
- Destination SK: destination_sk
- Source bucket name: source_bucket
- Destination bucket name: destination_bucket
- Source type: cloud_type
Procedure
- Obtain the token of the IAM user.
- API
URI format: POST /v3/auth/tokens
For details, see Obtaining a User Token Through Password Authentication.
- Example request
POST: https://{iam_endpoint}/v3/auth/tokens
Obtain {endpoint} from Regions and Endpoints.
Body:{ "auth": { "identity": { "methods": [ "password" ], "password": { "user": { "name": "testname", "domain": { "name": "testname" }, "password": "Password" } } }, "scope": { "project": { "id": "0215ef11e49d4743be23dd97a156xxxx" } } } }
In the response header, the value of X-Subject-Token is the token.
X-Subject-Token:MIIDkgYJKoZIhvcNAQcCoIIDgzCCA38CAQExDTALBglghkgBZQMEAgEwgXXXXX...
- API
- Make a call to the API for creating a migration task to create a migration task.
- API
URI format: POST /v1/{project_id}/objectstorage/task
For details, see Creating a Migration Task.
- Example request
POST: https://oms.cn-north-1.myhuaweicloud.com/v1/0215ef11e49d4743be23dd97a1561e91/objectstorage/task
Obtain {endpoint} from Regions and Endpoints.
Header:
Content-Type: application/json X-Auth-Token: "Token"
Body:
{ "src_node": { "region": "cn-beijing", "ak": "source_ak", "sk": "source_sk", "object_key": { "path": "", "keys": [] }, "bucket": "source_bucket", "cloud_type": "{cloud_type}" }, "thread_num": 50, "enableKMS": false, "description": "A migration task.", "dst_node": { "region": "cn-north-1", "ak": "destination_ak", "sk": "destination_sk", "object_key": "/", "bucket": "destination_bucket", "cloud_type": "OBS" }, "task_type": "object", "enable_failed_object_recording": false }
- Example response
{ "id" : 180890111968184, "task_name" : "task_name" }
- API
- Make a call to the task viewing API to view the task status.
- API
GET /v1/{project_id}/objectstorage/task/{task_id}
For details, see Querying Migration Tasks by Task IDs.
- Example request
GET: https://oms.cn-north-1.myhuaweicloud.com/v1/0215ef11e49d4743be23dd97a1561e91/objectstorage/task/{task_id}
Obtain {endpoint} from Regions and Endpoints.
Header:
Content-Type: application/json X-Auth-Token: "Token"
- Example response
{ "id": 180894011968184, "name": "task_name", "src_node": { "region": "cn-beijing", "bucket": "source_bucket", "object_key": ["/"], "list_file": "", "cloud_type": "{cloud_type}" }, "dst_node": { "region": "cn-north-1", "bucket": "destination_bucket", "object_key": "/", "cloud_type": "OBS" }, "thread_num": 50, "is_query_over": true, "status": 5, "progress": 1, "total_num": 1001, "success_num": 1001, "fail_num": 0, "skip_num": 0, "description": "A migration task.", "enableKMS": false, "error_reason": "", "total_size": 10240000, "real_size": 10240000, "complete_size": 10240000, "migrate_speed": 577552, "start_time": 1534762935868, "left_time": 0, "total_time": 17730, "migrate_since": 0, "task_type": "object", "failed_object_record": { "result": false, "list_file_key": "", "reson": "S3M.0301" } }
status indicates the task execution status. The value 5 indicates that the task is successfully executed.
- API
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot