-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcertificates.py
More file actions
93 lines (76 loc) · 2.69 KB
/
certificates.py
File metadata and controls
93 lines (76 loc) · 2.69 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
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
from mpt_api_client.http import AsyncService, Service
from mpt_api_client.http.mixins import (
AsyncCollectionMixin,
AsyncManagedResourceMixin,
CollectionMixin,
ManagedResourceMixin,
)
from mpt_api_client.models import Model
from mpt_api_client.models.model import BaseModel, ResourceData
class Certificate(Model):
"""Program certificate resource.
Attributes:
name: Certificate name.
program: Reference to the program.
vendor: Reference to the vendor.
external_ids: External identifiers.
client: Reference to the client.
applicable_to: Applicable to which entities.
licensee: Reference to the licensee.
eligibility: Eligibility criteria.
status: Certificate status.
status_notes: Additional notes on the certificate status.
parameters: Certificate parameters.
audit: Audit information.
"""
name: str | None
program: BaseModel | None
vendor: BaseModel | None
external_ids: BaseModel | None
client: BaseModel | None
applicable_to: str | None
licensee: BaseModel | None
eligibility: BaseModel | None
status: str | None
status_notes: str | None
parameters: BaseModel | None # noqa: WPS110
audit: BaseModel | None
class CertificateServiceConfig:
"""Program certificate service config."""
_endpoint = "/public/v1/program/certificates"
_model_class = Certificate
_collection_key = "data"
class CertificateService(
ManagedResourceMixin[Certificate],
CollectionMixin[Certificate],
Service[Certificate],
CertificateServiceConfig,
):
"""Program certificate service."""
def terminate(self, resource_id: str, resource_data: ResourceData | None = None) -> Certificate:
"""Terminate a certificate.
Args:
resource_id: Certificate ID.
resource_data: Additional data for termination.
Returns:
Terminated certificate.
"""
return self._resource(resource_id).post("/terminate", json=resource_data)
class AsyncCertificateService(
AsyncManagedResourceMixin[Certificate],
AsyncCollectionMixin[Certificate],
AsyncService[Certificate],
CertificateServiceConfig,
):
"""Asynchronous program certificate service."""
async def terminate(
self, resource_id: str, resource_data: ResourceData | None = None
) -> Certificate:
"""Asynchronously terminate a certificate.
Args:
resource_id: Certificate ID.
resource_data: Additional data for termination.
Returns:
Terminated certificate.
"""
return await self._resource(resource_id).post("/terminate", json=resource_data)