-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproducts_create_usage_based_price.py
More file actions
50 lines (40 loc) · 1.28 KB
/
products_create_usage_based_price.py
File metadata and controls
50 lines (40 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# coding=utf-8
import os
from corehttp.credentials import ServiceKeyCredential
from credytapi import CredytApiClient
"""
# PREREQUISITES
pip install credyt-api
# USAGE
python products_create_usage_based_price.py
Before run the sample, please set environment variables AZURE_KEY with real value
which can access your service
"""
def main():
client = CredytApiClient(
credential=ServiceKeyCredential(key=os.getenv("CREDYT_API_KEY")),
)
response = client.products.create(
body={
"code": "glitch_video_std",
"name": "Glitch Video",
"prices": [
{
"billing_model": {"type": "real_time"},
"name": "Video Promotion",
"pricing": [{"asset": "USD", "values": [{"unit_price": 0.5}]}],
"type": "usage_based",
"usage_calculation": {
"event_type": "video_promoted",
"source_reference_field": "video_id",
"usage_type": "unit",
},
}
],
"publish": True,
},
)
print(response)
# x-ms-original-file: next/Products_create_Usage_Based_Price.json
if __name__ == "__main__":
main()