Getting started with the Marketplace Cloud Apps Workload API
This section provides examples of using the Marketplace Cloud Apps Workload REST API and gRPC API to get information about an application in Cloud Apps and how to link such an app and the VM it runs on to Yandex Cloud Apps.
You can also send all the requests given below using the Node.js
Getting started
To get started with the Marketplace Cloud Apps Workload API:
- Get an IAM token for the service account created automatically while installing the application and linked to the VM running this application.
- Get the ID of the VM running the application.
To use the examples, install these utilities:
Get information about a Yandex Cloud Apps application
To get information about an application in Cloud Apps, use the service account created automatically while installing the application and linked to the VM running this application. Run this command:
curl \
--request GET \
--header "Authorization: Bearer <IAM_token>" \
https://cloudapps.api.cloud.yandex.net/cloudapps/workload/v1/cloud-applications
Where <IAM_token>
is the service account IAM token you got earlier.
Result:
{
"id": "d7fsg12ho5h6********",
"status": "DEPLOYED",
"billing": {
"type": "PAY_AS_YOU_GO"
}
}
The request uses the get REST API method for the CloudApplication resource.
grpcurl \
-H "Authorization: Bearer <IAM_token>" \
cloudapps.api.cloud.yandex.net:443 yandex.cloud.cloudapps.workload.v1.CloudApplicationService/Get
Where <IAM_token>
is the service account IAM token you got earlier.
Result:
{
"id": "d7fsg12ho5h6********",
"status": "DEPLOYED",
"billing": {
"type": "PAY_AS_YOU_GO"
}
}
The request uses the CloudApplicationService/Get gRPC API call.
This response indicates that the service account was automatically created while installing a Cloud Apps application whose ID is d7fsg12ho5h6********
. The current application status is DEPLOYED
, and the current service plan type is PAY_AS_YOU_GO
.
Make sure the application is running in Cloud Apps
To make sure your application is running in Cloud Apps, check that the VM is linked to the application. To do this, use the service account created automatically while installing the application and linked to the VM running this application. Run this command:
curl \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer <IAM_token>" \
--data '{"workload_type": "COMPUTE_INSTANCE", "workload_id": "<VM_ID>"}' \
https://cloudapps.api.cloud.yandex.net/cloudapps/workload/v1/cloud-applications:resolve-by-workload
Where:
Result:
The VM is linked to the Cloud Apps application
{
"cloudApplication": {
"id": "d7fsg12ho5h6********",
"status": "DEPLOYED",
"billing": {
"type": "PAY_AS_YOU_GO"
}
}
}
This response indicates that the VM and its linked service account were created automatically while installing a Cloud Apps application whose ID is d7fsg12ho5h6********
. The current application status is DEPLOYED
, and the current service plan type is PAY_AS_YOU_GO
.
The VM is not linked to the Cloud Apps application
{
"code": 5,
"message": "Workload not found",
"details": [
{
"@type": "type.googleapis.com/google.rpc.RequestInfo",
"requestId": "5899fc83-b123-47b8-94c3-1ad1********"
}
]
}
If the request returns the above error, this means the user created the VM manually. As a result, the cost of the software product as per the service plan is not credited to the user’s account, and the application running on that VM may not be fully functional.
The request uses the resolveByWorkload REST API method for the CloudApplication resource.
grpcurl \
-H "Authorization: Bearer <IAM_token>" \
-d '{"workload_type": "COMPUTE_INSTANCE", "workload_id": "<VM_ID>"}' \
cloudapps.api.cloud.yandex.net:443 yandex.cloud.cloudapps.workload.v1.CloudApplicationService/ResolveByWorkload
Where:
Result:
The VM is linked to the Cloud Apps application
{
"cloudApplication": {
"id": "d7fsg12ho5h6********",
"status": "DEPLOYED",
"billing": {
"type": "PAY_AS_YOU_GO"
}
}
}
This response indicates that the VM and its linked service account were created automatically while installing a Cloud Apps application whose ID is d7fsg12ho5h6********
. The current application status is DEPLOYED
, and the current service plan type is PAY_AS_YOU_GO
.
The VM is not linked to the Cloud Apps application
ERROR:
Code: NotFound
Message: Workload not found
Details:
1) {
"@type": "type.googleapis.com/google.rpc.RequestInfo",
"requestId": "5899fc83-b123-47b8-94c3-1ad1********"
}
If the request returns the above error, this means the user created the VM manually. As a result, the cost of the software product as per the service plan is not credited to the user’s account, and the application running on that VM may not be fully functional.
The request uses the CloudApplicationService/ResolveByWorkload gRPC API call.