Integration with the License Manager API
If you created a subscription within one of these service plans:
Subscription
: Set up integration with the License Manager API or License Manager SaaS API for your subscription to work properly.PAYG
: User will automatically switch to this service plan as soon as they unlink the subscription from a resource or as soon as the subscription expires. You can set up integration with the License Manager API if required.
-
Get the subscription template ID (
license_template_id
).You can find the subscription template ID in the Cloud Marketplace partner dashboard. Use the ID in the product code to manage the subscription.
-
Implement the following steps in your product code:
-
Regularly checking if your subscription is active.
You can get the up-to-date subscription information using the list REST API method for the Instance resource or the InstanceService/List gRPC API call.
Note
Please note that the user can unlink a resource from the subscription and link another one to it. Make sure your code can handle cases like this correctly.
-
Configuring business logic for subscription processing: consumption records, limitations related to time, number of users, etc.
-
-
Get the subscription template ID (
license_template_id
).You can find the subscription template ID in the Cloud Marketplace partner dashboard. Use the ID in the product code to manage the subscription.
-
Implement the following steps in your product code:
-
Getting the ID of application installation to the Kubernetes cluster and linking it to the subscription. Sample code
. -
Regularly checking if your subscription is active.
You can get the up-to-date subscription information using the list REST API method for the Instance resource or the InstanceService/List gRPC API call.
Note
Please note that the user can unlink a resource from the subscription and link another one to it. Make sure your code can handle cases like this correctly.
-
Configuring business logic for subscription processing: consumption records, limitations related to time, number of users, etc.
-
-
Get the subscription template ID (
license_template_id
).You can find the subscription template ID in the Cloud Marketplace partner dashboard. Use the ID in the product code to manage the subscription.
-
Implement the following steps in your product code:
-
Regularly checking if your subscription is active.
You can get the up-to-date subscription information using the list REST API method for the Instance resource or the InstanceService/List gRPC API call.
Note
Please note that the user can unlink a resource from the subscription and link another one to it. Make sure your code can handle cases like this correctly.
-
Configuring business logic for subscription processing: consumption records, limitations related to time, number of users, etc.
-
-
Create a service account you will use to verify subscriptions purchased by users and link such subscriptions to the service:
- Log in to the Marketplace partner dashboard
. - Open the Access management section.
- Click Add federated user.
- In the window that opens, specify the service account ID and click Add.
- Find the service account in the list and click → Change.
- In the window that opens, click + Add role, select the
license-manager.saasSubscriptionSupervisor
role, and click Save.
- Log in to the Marketplace partner dashboard
-
Authenticate with the License Manager API as a service account. For authentication, use an IAM token.
-
Create a page to redirect the user to when linking their purchased subscription to the service.
When redirecting the user to such a page, the
token
parameter in the request string will contain the JWT token (instanceToken
) generated by Yandex Cloud. The JWT token is valid for 15 minutes. It contains:- ID of the subscription the user purchased (
license_instance_id
). - ID of the subscription template you created in the partner dashboard (
license_template_id
).
- ID of the subscription the user purchased (
-
While the JWT token is valid, use the created page to authenticate the user and assign them a unique ID (
resourceId
). You must generate the unique user ID (resourceId
) manually in the product code. -
Link the unique user ID (
resourceId
) to the subscription the user purchased (license_instance_id
).You can link an ID to a subscription using the ensure REST API method for the Lock resource or the LockService/Ensure gRPC API call.
Provide the JWT token (
instanceToken
) and the unique user ID (resourceId
) in the request. In response, you will get the link ID (lock_id
) in themetadata
parameter. If the response returns an error, the subscription failed to link to the service and you need to ask the user to complete all the steps again. -
Make sure to regularly check your subscription link is active. To do this, use the link ID (
lock_id
) you got in the previous step.To get up-to-date information about a linked subscription, use the get REST API method for the Lock resource or the LockService/Get gRPC API call.
The response must return an active Lock resource with
state = LOCKED
and the subscription expiry time (end_time
) set to a value in future.Note
Note that the user can unlink a subscription from the service and link a different one. Make sure your code can handle cases like this correctly.
-
Implement business logic to process subscriptions: consumption records, limitations related to time, number of users, etc.
Integration testing
For code examples and a test server you can use to check the License Manager API integration, see this GitHub repository