-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcloud_export_example.py
165 lines (138 loc) · 4.82 KB
/
cloud_export_example.py
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
"""
Examples of using the CloudExport API
"""
from examples.utils import client, pretty_print
from kentik_api.cloudexport.cloud_export import (
AwsProperties,
AzureProperties,
CloudExport,
CloudExportType,
CloudProviderType,
GceProperties,
)
from kentik_api.public.types import ID
PLAN_ID = ID("11467")
def cloud_exports_list() -> None:
print("### CLOUD EXPORTS LIST")
response = client().cloud_export.get_all()
pretty_print(response)
print()
def cloud_export_azure_crud() -> None:
azure = AzureProperties(
location="Singapore",
resource_group="exampleresourcegroup",
storage_account="examplestorageaccount",
subscription_id=ID("bda574ce-5d2e-5d2c-83da-0f7b0762e10c"),
security_principal_enabled=True,
)
export = CloudExport(
name="community_sdk_python azure cloud export",
type=CloudExportType.KENTIK_MANAGED,
enabled=True,
description="example azure cloud export",
plan_id=PLAN_ID,
cloud_provider=CloudProviderType.AZURE,
azure=azure,
)
print("### AZURE CLOUD EXPORT CREATE")
created_export = client().cloud_export.create(export)
pretty_print(created_export)
print()
print("### AZURE CLOUD EXPORT GET")
received_export = client().cloud_export.get(created_export.id)
pretty_print(received_export)
print()
print("### AZURE CLOUD EXPORT PATCH")
received_export.description = "PATCHED example azure cloud export"
patched_export = client().cloud_export.patch(received_export, "export.description")
pretty_print(patched_export)
print()
print("### AZURE CLOUD EXPORT UPDATE")
received_export.name = "UPDATED community_sdk_python azure cloud export"
updated_export = client().cloud_export.update(received_export)
pretty_print(updated_export)
print()
print("### AZURE CLOUD EXPORT DELETE")
client().cloud_export.delete(created_export.id)
print("OK")
print()
def cloud_export_aws_crud() -> None:
aws = AwsProperties(
bucket="cloudexport-src-s3-bucket",
iam_role_arn="arn:aws:iam::177634097045:role/test-cloudexport-IngestRole",
region="eu-central-1",
delete_after_read=True,
multiple_buckets=True,
)
export = CloudExport(
name="community_sdk_python aws cloud export",
type=CloudExportType.KENTIK_MANAGED,
enabled=True,
description="example aws cloud export",
plan_id=PLAN_ID,
cloud_provider=CloudProviderType.AWS,
aws=aws,
)
print("### AWS CLOUD EXPORT CREATE")
created_export = client().cloud_export.create(export)
pretty_print(created_export)
print()
print("### AWS CLOUD EXPORT GET")
received_export = client().cloud_export.get(created_export.id)
pretty_print(received_export)
print()
print("### AWS CLOUD EXPORT PATCH")
received_export.description = "PATCHED example aws cloud export"
patched_export = client().cloud_export.patch(received_export, "export.description")
pretty_print(patched_export)
print()
print("### AWS CLOUD EXPORT UPDATE")
received_export.name = "UPDATED community_sdk_python aws cloud export"
updated_export = client().cloud_export.update(received_export)
pretty_print(updated_export)
print()
print("### AWS CLOUD EXPORT DELETE")
client().cloud_export.delete(created_export.id)
print("OK")
print()
def cloud_export_gce_crud() -> None:
gce = GceProperties(
project="testproject",
subscription="testsubscription",
)
export = CloudExport(
name="community_sdk_python gce cloud export",
type=CloudExportType.KENTIK_MANAGED,
enabled=True,
description="example gce cloud export",
plan_id=PLAN_ID,
cloud_provider=CloudProviderType.GCE,
gce=gce,
)
print("### GCE CLOUD EXPORT CREATE")
created_export = client().cloud_export.create(export)
pretty_print(created_export)
print()
print("### GCE CLOUD EXPORT GET")
received_export = client().cloud_export.get(created_export.id)
pretty_print(received_export)
print()
print("### GCE CLOUD EXPORT PATCH")
received_export.description = "PATCHED example gce cloud export"
patched_export = client().cloud_export.patch(received_export, "export.description")
pretty_print(patched_export)
print()
print("### GCE CLOUD EXPORT UPDATE")
received_export.name = "UPDATED community_sdk_python gce cloud export"
updated_export = client().cloud_export.update(received_export)
pretty_print(updated_export)
print()
print("### GCE CLOUD EXPORT DELETE")
client().cloud_export.delete(created_export.id)
print("OK")
print()
if __name__ == "__main__":
cloud_exports_list()
cloud_export_azure_crud()
cloud_export_aws_crud()
cloud_export_gce_crud()