Skip to main content

Write

Writes image product's usage. Authentication is by user's service account.

import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";

const WriteImageProductUsageRequest =
cloudApi.marketplace.metering_image_product_usage_service
.WriteImageProductUsageRequest;

(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.ImageProductUsageServiceClient);

const result = await client.write(
WriteImageProductUsageRequest.fromPartial({
// validateOnly: true,
productId: "productId",
// usageRecords: [{
// uuid: "uuid",
// skuId: "skuId",
// quantity: 0,
// timestamp: {
// seconds: 0,
// nanos: 0
// }
// }]
})
);
console.log(result);
})();

WriteImageProductUsageRequest

validateOnly : bool

Checks whether you have the access required for the emit usage.

productId : string

Marketplace Product's ID.

usageRecords : UsageRecord

List of product usage records (up to 25 per request).

UsageRecord

uuid : string

Unique identifier of the usage record (UUID format).

skuId : string

Consumed Marketplace SKU ID, linked to UsageRecord.product_id.

quantity : int64

Quantity of SKU consumed, measured in sku.usage_unit units (e.g. bytes).

timestamp : google.protobuf.Timestamp

Timestamp in UTC for which the usage is being reported.

WriteImageProductUsageResponse

accepted : AcceptedUsageRecord

List of accepted product usage records.

rejected : RejectedUsageRecord

List of rejected product usage records (with reason).

AcceptedUsageRecord

uuid : string

Unique identifier of the usage record (UUID format).

RejectedUsageRecord

Reason
  • REASON_UNSPECIFIED

  • DUPLICATE

  • EXPIRED

  • INVALID_TIMESTAMP

  • INVALID_SKU_ID

  • INVALID_PRODUCT_ID

  • INVALID_QUANTITY

  • INVALID_ID

uuid : string

Unique identifier of the usage record (UUID format).

reason : Reason

The reason of rejection.