yicloud-sdk-python 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. version.py +9 -0
  2. yicloud/__init__.py +7 -0
  3. yicloud/base/__init__.py +58 -0
  4. yicloud/base/auth/__init__.py +10 -0
  5. yicloud/base/auth/credential.py +64 -0
  6. yicloud/base/auth/sign.py +80 -0
  7. yicloud/base/client.py +313 -0
  8. yicloud/base/config.py +62 -0
  9. yicloud/base/errs/__init__.py +292 -0
  10. yicloud/base/log/__init__.py +43 -0
  11. yicloud/base/log/logger.py +123 -0
  12. yicloud/base/log/std.py +70 -0
  13. yicloud/base/msgs/__init__.py +226 -0
  14. yicloud/base/utils/__init__.py +6 -0
  15. yicloud/base/utils/helps.py +110 -0
  16. yicloud/base/utils/retry/__init__.py +27 -0
  17. yicloud/base/utils/retry/retry.py +162 -0
  18. yicloud/services/__init__.py +24 -0
  19. yicloud/services/bc/__init__.py +9 -0
  20. yicloud/services/bc/actions.py +23 -0
  21. yicloud/services/bc/client.py +19 -0
  22. yicloud/services/bc/models.py +61 -0
  23. yicloud/services/fs/__init__.py +29 -0
  24. yicloud/services/fs/actions.py +109 -0
  25. yicloud/services/fs/client.py +19 -0
  26. yicloud/services/fs/models.py +152 -0
  27. yicloud/services/iam/__init__.py +27 -0
  28. yicloud/services/iam/actions.py +304 -0
  29. yicloud/services/iam/client.py +19 -0
  30. yicloud/services/iam/models.py +276 -0
  31. yicloud/services/job/__init__.py +44 -0
  32. yicloud/services/job/actions.py +167 -0
  33. yicloud/services/job/client.py +19 -0
  34. yicloud/services/job/models.py +268 -0
  35. yicloud/services/mc/__init__.py +59 -0
  36. yicloud/services/mc/actions.py +221 -0
  37. yicloud/services/mc/client.py +21 -0
  38. yicloud/services/mc/models.py +322 -0
  39. yicloud/services/modelrepo/__init__.py +33 -0
  40. yicloud/services/modelrepo/actions.py +163 -0
  41. yicloud/services/modelrepo/client.py +19 -0
  42. yicloud/services/modelrepo/models.py +146 -0
  43. yicloud/services/modelset/__init__.py +45 -0
  44. yicloud/services/modelset/actions.py +130 -0
  45. yicloud/services/modelset/client.py +19 -0
  46. yicloud/services/modelset/models.py +356 -0
  47. yicloud/services/oss/__init__.py +25 -0
  48. yicloud/services/oss/actions.py +83 -0
  49. yicloud/services/oss/client.py +19 -0
  50. yicloud/services/oss/models.py +113 -0
  51. yicloud/services/registry/__init__.py +42 -0
  52. yicloud/services/registry/actions.py +208 -0
  53. yicloud/services/registry/client.py +19 -0
  54. yicloud/services/registry/models.py +183 -0
  55. yicloud_sdk_python-0.1.0.dist-info/METADATA +145 -0
  56. yicloud_sdk_python-0.1.0.dist-info/RECORD +59 -0
  57. yicloud_sdk_python-0.1.0.dist-info/WHEEL +5 -0
  58. yicloud_sdk_python-0.1.0.dist-info/licenses/LICENSE +202 -0
  59. yicloud_sdk_python-0.1.0.dist-info/top_level.txt +2 -0
@@ -0,0 +1,276 @@
1
+ from dataclasses import dataclass, field
2
+ from typing import Optional, List
3
+
4
+
5
+ # Enum: Role
6
+ class Role:
7
+ MANAGER = "manager"
8
+ OPERATOR = "operator"
9
+
10
+
11
+ # Enum: UserType
12
+ class UserType:
13
+ TENANT_OPERATOR = "tenantOperator"
14
+ TENANT_MANAGER = "tenantManager"
15
+ TENANT_OBSERVER = "noPermission"
16
+
17
+
18
+ # Enum: AccessKeyStatus
19
+ class AccessKeyStatus:
20
+ ACTIVE = "Active"
21
+ INACTIVE = "Inactive"
22
+
23
+
24
+ # Enum: StatementType
25
+ class StatementType:
26
+ CLASSIC_WHITE_LIST = "ClassicWhiteList"
27
+
28
+
29
+ # Models
30
+ @dataclass
31
+ class ProjectRole:
32
+ Name: str # json:"Name"
33
+ Role: str # json:"Role"
34
+
35
+
36
+ @dataclass
37
+ class CreateUserReq:
38
+ Email: str # json:"Email"
39
+ FirstName: str # json:"FirstName"
40
+ LastName: str # json:"LastName"
41
+ Password: str # json:"Password"
42
+ UserName: str # json:"UserName"
43
+ UserType: str # json:"UserType"
44
+ ProjectsRoles: Optional[List[ProjectRole]] = None # json:"ProjectsRoles,omitempty"
45
+
46
+
47
+ @dataclass
48
+ class UserData:
49
+ CreationTime: str # json:"CreationTime"
50
+ DisplayName: str # json:"DisplayName"
51
+ Email: str # json:"Email"
52
+ UserName: str # json:"UserName"
53
+ UserType: str # json:"UserType"
54
+ ProjectsRoles: Optional[List[ProjectRole]] = None # json:"ProjectsRoles,omitempty"
55
+
56
+
57
+ @dataclass
58
+ class ListUsersData:
59
+ Items: Optional[List[UserData]] = None # json:"Items,omitempty"
60
+ Limit: int = 10 # json:"Limit,omitempty"
61
+ Offset: int = 0 # json:"Offset,omitempty"
62
+ Total: int = 0 # json:"Total,omitempty"
63
+
64
+
65
+ @dataclass
66
+ class DeleteUserReq:
67
+ UserName: str # json:"UserName"
68
+
69
+
70
+ @dataclass
71
+ class CreateAccessKeyReq:
72
+ UserName: str # json:"UserName"
73
+
74
+
75
+ @dataclass
76
+ class AccessKeyData:
77
+ AccessKey: str # json:"AccessKey"
78
+ CreationTime: str # json:"CreationTime"
79
+ SecretKey: str # json:"SecretKey"
80
+ Status: str # json:"Status"
81
+
82
+
83
+ @dataclass
84
+ class DeleteAccessKeyReq:
85
+ AccessKey: str # json:"AccessKey"
86
+
87
+
88
+ @dataclass
89
+ class UpdateAccessKeyReq:
90
+ AccessKey: str # json:"AccessKey"
91
+ Status: str # json:"Status"
92
+
93
+
94
+ @dataclass
95
+ class ListAccessKeyData:
96
+ Items: Optional[List[AccessKeyData]] = None # json:"Items,omitempty"
97
+ Total: int = 0 # json:"Total,omitempty"
98
+
99
+
100
+ @dataclass
101
+ class Statement:
102
+ Type: str # json:"Type"
103
+ IPList: List[str] # json:"IPList"
104
+
105
+
106
+ @dataclass
107
+ class AccessKeyPolicyData:
108
+ Type: str # json:"Type"
109
+ IPList: List[str] # json:"IPList"
110
+ Status: str # json:"Status"
111
+
112
+
113
+ @dataclass
114
+ class SetAccessKeyPolicyReq:
115
+ AccessKey: str # json:"AccessKey"
116
+ AccessKeyPolicy: Optional[AccessKeyPolicyData] = None # json:"AccessKeyPolicy"
117
+
118
+
119
+ @dataclass
120
+ class CreateProjectReq:
121
+ ProjectName: str # json:"ProjectName"
122
+
123
+
124
+ @dataclass
125
+ class DeleteProjectReq:
126
+ ProjectName: str # json:"ProjectName"
127
+
128
+
129
+ @dataclass
130
+ class ProjectData:
131
+ CreationTime: str # json:"CreationTime,omitempty"
132
+ ProjectName: str # json:"ProjectName,omitempty"
133
+
134
+
135
+ @dataclass
136
+ class ListProjectsData:
137
+ Items: Optional[List[ProjectData]] = None # json:"Items,omitempty"
138
+ Limit: int = 10 # json:"Limit,omitempty"
139
+ Offset: int = 0 # json:"Offset,omitempty"
140
+ Total: int = 0 # json:"Total,omitempty"
141
+
142
+
143
+ @dataclass
144
+ class BindProjectUserReq:
145
+ ProjectName: str # json:"ProjectName"
146
+ Role: str # json:"Role"
147
+ UserName: str # json:"UserName"
148
+
149
+
150
+ @dataclass
151
+ class RemoveProjectUserReq:
152
+ ProjectName: str # json:"ProjectName"
153
+ Role: str # json:"Role"
154
+ UserName: str # json:"UserName"
155
+
156
+
157
+ @dataclass
158
+ class ListProjectUsersReq:
159
+ ProjectName: str # query:"ProjectName"
160
+ Role: str # query:"Role"
161
+ Limit: int = 10 # query:"Limit,omitempty"
162
+ Offset: int = 0 # query:"Offset,omitempty"
163
+
164
+
165
+ @dataclass
166
+ class ProjectUser:
167
+ CreationTime: str # json:"CreationTime,omitempty"
168
+ Role: str # json:"Role,omitempty"
169
+ UserName: str # json:"UserName,omitempty"
170
+
171
+
172
+ @dataclass
173
+ class ListProjectUsersData:
174
+ Items: Optional[List[ProjectUser]] = None # json:"Items,omitempty"
175
+ Limit: int = 10 # json:"Limit,omitempty"
176
+ Offset: int = 0 # json:"Offset,omitempty"
177
+ Total: int = 0 # json:"Total,omitempty"
178
+
179
+
180
+ @dataclass
181
+ class QuotaGroupRole:
182
+ Role: str # json:"Role"
183
+ UserName: str # json:"UserName"
184
+
185
+
186
+ @dataclass
187
+ class CreateQuotaGroupReq:
188
+ ProjectName: str # json:"ProjectName"
189
+ QuotaGroupName: str # json:"QuotaGroupName"
190
+ QuotaGroupRoles: Optional[List[QuotaGroupRole]] = None # json:"QuotaGroupRoles,omitempty"
191
+ Quota: Optional[str] = None # json:"Quota"
192
+
193
+
194
+ @dataclass
195
+ class QuotaGroupData:
196
+ CreationTime: str # json:"CreationTime,omitempty"
197
+ ProjectName: str # json:"ProjectName,omitempty"
198
+ QuotaGroupId: str # json:"QuotaGroupId,omitempty"
199
+ QuotaGroupName: str # json:"QuotaGroupName,omitempty"
200
+ QuotaGroupRoles: Optional[List[QuotaGroupRole]] = None # json:"QuotaGroupRoles,omitempty"
201
+
202
+
203
+ @dataclass
204
+ class QuotaGroupBasicData:
205
+ CreationTime: str # json:"CreationTime,omitempty"
206
+ ProjectName: str # json:"ProjectName,omitempty"
207
+ QuotaGroupId: str # json:"QuotaGroupId,omitempty"
208
+ QuotaGroupName: str # json:"QuotaGroupName,omitempty"
209
+
210
+
211
+ @dataclass
212
+ class ListQuotaGroupData:
213
+ Items: Optional[List[QuotaGroupBasicData]] = None # json:"Items,omitempty"
214
+ Limit: int = 10 # json:"Limit,omitempty"
215
+ Offset: int = 0 # json:"Offset,omitempty"
216
+ Total: int = 0 # json:"Total,omitempty"
217
+
218
+
219
+ # GET request models
220
+ @dataclass
221
+ class GetUserReq:
222
+ UserName: str # query:"UserName"
223
+
224
+
225
+ @dataclass
226
+ class ListUsersReq:
227
+ Limit: int = 10 # query:"Limit,omitempty"
228
+ Offset: int = 0 # query:"Offset,omitempty"
229
+ UserName: str = "" # query:"UserName,omitempty"
230
+
231
+
232
+ @dataclass
233
+ class GetAccessKeyReq:
234
+ AccessKey: str # query:"AccessKey"
235
+
236
+
237
+ @dataclass
238
+ class ListAccessKeysReq:
239
+ UserName: str # query:"UserName"
240
+
241
+
242
+ @dataclass
243
+ class GetAccessKeyPolicyReq:
244
+ AccessKey: str # query:"AccessKey"
245
+
246
+
247
+ @dataclass
248
+ class GetProjectReq:
249
+ ProjectName: str # query:"ProjectName"
250
+
251
+
252
+ @dataclass
253
+ class ListProjectsReq:
254
+ Limit: int = 10 # query:"Limit,omitempty"
255
+ Offset: int = 0 # query:"Offset,omitempty"
256
+ ProjectName: str = "" # query:"ProjectName,omitempty"
257
+
258
+
259
+ @dataclass
260
+ class GetQuotaGroupReq:
261
+ ProjectName: str # query:"ProjectName"
262
+ QuotaGroupName: str # query:"QuotaGroupName"
263
+
264
+
265
+ @dataclass
266
+ class DeleteQuotaGroupReq:
267
+ ProjectName: str # query:"ProjectName"
268
+ QuotaGroupName: str # query:"QuotaGroupName"
269
+
270
+
271
+ @dataclass
272
+ class ListQuotaGroupsReq:
273
+ Limit: int = 10 # query:"Limit,omitempty"
274
+ Offset: int = 0 # query:"Offset,omitempty"
275
+ ProjectName: str = "" # query:"ProjectName,omitempty"
276
+ QuotaGroupName: str = "" # query:"QuotaGroupName,omitempty"
@@ -0,0 +1,44 @@
1
+ from yicloud.services.job.client import JobClient as Client, client, use_client
2
+ from . import actions, models
3
+
4
+ from .actions import (
5
+ list_jobs,
6
+ get_job,
7
+ create_job,
8
+ edit_job,
9
+ batch_delete_jobs,
10
+ batch_stop_jobs,
11
+ get_logs,
12
+ get_logs_volume,
13
+ list_job_replicas,
14
+ get_job_replica,
15
+ get_job_replica_pid,
16
+ )
17
+ from .models import (
18
+ TaskSpec,
19
+ ListJobsReq,
20
+ JobData,
21
+ TaskSpecResponse,
22
+ ListJobsData,
23
+ GetJobReq,
24
+ CreateJobReq,
25
+ CreateJobData,
26
+ EditJobReq,
27
+ BatchDeleteJobsReq,
28
+ BatchStopJobsReq,
29
+ BatchStopJobsData,
30
+ GetLogsReq,
31
+ LogEntry,
32
+ GetLogsResponse,
33
+ GetLogsVolumeReq,
34
+ VolumeDataPoint,
35
+ VolumeResultItem,
36
+ VolumeMetadata,
37
+ GetLogsVolumeResponse,
38
+ ListJobReplicasReq,
39
+ ReplicaData,
40
+ ListJobReplicasData,
41
+ GetJobReplicaReq,
42
+ GetJobReplicaPidReq,
43
+ PidInfoData,
44
+ )
@@ -0,0 +1,167 @@
1
+ from typing import Optional
2
+
3
+ from yicloud.base import msgs
4
+ from yicloud.services.job import models
5
+ from yicloud.services.job.client import client
6
+
7
+ _PRODUCT_CODE = "job"
8
+ _LAST_VERSION = "v1alpha1"
9
+
10
+
11
+ def list_jobs(ctx: Optional[dict], req: models.ListJobsReq) -> models.ListJobsData:
12
+ """
13
+ GET /job/v1alpha1/ListJobs
14
+ Action: ListJobs
15
+
16
+ Returns ListJobsData on success.
17
+
18
+ Raises YiCloudException on error.
19
+ """
20
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/ListJobs"
21
+ rsp = msgs.Rsp[models.ListJobsData]()
22
+ client.base.get(ctx, path, req, rsp)
23
+ return rsp.get_typed_data()
24
+
25
+
26
+ def get_job(ctx: Optional[dict], req: models.GetJobReq) -> models.JobData:
27
+ """
28
+ GET /job/v1alpha1/GetJob
29
+ Action: GetJob
30
+
31
+ Returns JobData on success.
32
+
33
+ Raises YiCloudException on error.
34
+ """
35
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/GetJob"
36
+ rsp = msgs.Rsp[models.JobData]()
37
+ client.base.get(ctx, path, req, rsp)
38
+ return rsp.get_typed_data()
39
+
40
+
41
+ def create_job(ctx: Optional[dict], req: models.CreateJobReq) -> models.CreateJobData:
42
+ """
43
+ POST /job/v1alpha1/CreateJob
44
+ Action: CreateJob
45
+
46
+ Returns CreateJobData on success.
47
+
48
+ Raises YiCloudException on error.
49
+ """
50
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/CreateJob"
51
+ rsp = msgs.Rsp[models.CreateJobData]()
52
+ client.base.post(ctx, path, req.__dict__, rsp)
53
+ return rsp.get_typed_data()
54
+
55
+
56
+ def edit_job(ctx: Optional[dict], req: models.EditJobReq) -> None:
57
+ """
58
+ POST /job/v1alpha1/EditJob
59
+ Action: EditJob
60
+
61
+ Raises YiCloudException on error.
62
+ """
63
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/EditJob"
64
+ rsp = msgs.Rsp[None].empty()
65
+ client.base.post(ctx, path, req.__dict__, rsp)
66
+
67
+
68
+ def batch_delete_jobs(ctx: Optional[dict], req: models.BatchDeleteJobsReq) -> None:
69
+ """
70
+ POST /job/v1alpha1/BatchDeleteJobs
71
+ Action: BatchDeleteJobs
72
+
73
+ Raises YiCloudException on error.
74
+ """
75
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/BatchDeleteJobs"
76
+ rsp = msgs.Rsp[None].empty()
77
+ client.base.post(ctx, path, req.__dict__, rsp)
78
+
79
+
80
+ def batch_stop_jobs(ctx: Optional[dict], req: models.BatchStopJobsReq) -> models.BatchStopJobsData:
81
+ """
82
+ POST /job/v1alpha1/BatchStopJobs
83
+ Action: BatchStopJobs
84
+
85
+ Returns BatchStopJobsData on success.
86
+
87
+ Raises YiCloudException on error.
88
+ """
89
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/BatchStopJobs"
90
+ rsp = msgs.Rsp[models.BatchStopJobsData]()
91
+ client.base.post(ctx, path, req.__dict__, rsp)
92
+ return rsp.get_typed_data()
93
+
94
+
95
+ def get_logs(ctx: Optional[dict], req: models.GetLogsReq) -> models.GetLogsResponse:
96
+ """
97
+ GET /job/v1alpha1/GetLogs
98
+ Action: GetLogs
99
+
100
+ Returns GetLogsResponse on success.
101
+
102
+ Raises YiCloudException on error.
103
+ """
104
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/GetLogs"
105
+ rsp = msgs.Rsp[models.GetLogsResponse]()
106
+ client.base.get(ctx, path, req, rsp)
107
+ return rsp.get_typed_data()
108
+
109
+
110
+ def get_logs_volume(ctx: Optional[dict], req: models.GetLogsVolumeReq) -> models.GetLogsVolumeResponse:
111
+ """
112
+ GET /job/v1alpha1/GetLogsVolume
113
+ Action: GetLogsVolume
114
+
115
+ Returns GetLogsVolumeResponse on success.
116
+
117
+ Raises YiCloudException on error.
118
+ """
119
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/GetLogsVolume"
120
+ rsp = msgs.Rsp[models.GetLogsVolumeResponse]()
121
+ client.base.get(ctx, path, req, rsp)
122
+ return rsp.get_typed_data()
123
+
124
+
125
+ def list_job_replicas(ctx: Optional[dict], req: models.ListJobReplicasReq) -> models.ListJobReplicasData:
126
+ """
127
+ GET /job/v1alpha1/ListJobReplicas
128
+ Action: ListJobReplicas
129
+
130
+ Returns ListJobReplicasData on success.
131
+
132
+ Raises YiCloudException on error.
133
+ """
134
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/ListJobReplicas"
135
+ rsp = msgs.Rsp[models.ListJobReplicasData]()
136
+ client.base.get(ctx, path, req, rsp)
137
+ return rsp.get_typed_data()
138
+
139
+
140
+ def get_job_replica(ctx: Optional[dict], req: models.GetJobReplicaReq) -> models.ReplicaData:
141
+ """
142
+ GET /job/v1alpha1/GetJobReplica
143
+ Action: GetJobReplica
144
+
145
+ Returns ReplicaData on success.
146
+
147
+ Raises YiCloudException on error.
148
+ """
149
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/GetJobReplica"
150
+ rsp = msgs.Rsp[models.ReplicaData]()
151
+ client.base.get(ctx, path, req, rsp)
152
+ return rsp.get_typed_data()
153
+
154
+
155
+ def get_job_replica_pid(ctx: Optional[dict], req: models.GetJobReplicaPidReq) -> Optional[dict]:
156
+ """
157
+ GET /job/v1alpha1/GetJobReplicaPid
158
+ Action: GetJobReplicaPid
159
+
160
+ Returns list of PIDs.
161
+
162
+ Raises YiCloudException on error.
163
+ """
164
+ path = f"/{_PRODUCT_CODE}/{_LAST_VERSION}/GetJobReplicaPid"
165
+ rsp = msgs.Rsp[None]()
166
+ client.base.get(ctx, path, req, rsp)
167
+ return rsp.get_typed_data()
@@ -0,0 +1,19 @@
1
+ from yicloud.base import Client
2
+
3
+
4
+ class JobClient:
5
+ """Job service client, matching Go SDK's services/job/client.go."""
6
+
7
+ def __init__(self, base_client: Client = None):
8
+ self.base = base_client
9
+ self.product_code = "job"
10
+ self.last_version = "v1alpha1"
11
+
12
+
13
+ # Singleton matching Go SDK
14
+ client: JobClient = JobClient()
15
+
16
+
17
+ def use_client(cli: Client) -> None:
18
+ """Set the base client for Job service."""
19
+ client.base = cli