|
| 1 | +from mpt_api_client.http import AsyncService, Service |
| 2 | +from mpt_api_client.http.mixins import ( |
| 3 | + AsyncCollectionMixin, |
| 4 | + AsyncManagedResourceMixin, |
| 5 | + CollectionMixin, |
| 6 | + ManagedResourceMixin, |
| 7 | +) |
| 8 | +from mpt_api_client.models import Model |
| 9 | +from mpt_api_client.models.model import BaseModel, ResourceData |
| 10 | + |
| 11 | + |
| 12 | +class Certificate(Model): |
| 13 | + """Program certificate resource. |
| 14 | +
|
| 15 | + Attributes: |
| 16 | + name: Certificate name. |
| 17 | + program: Reference to the program. |
| 18 | + vendor: Reference to the vendor. |
| 19 | + external_ids: External identifiers. |
| 20 | + client: Reference to the client. |
| 21 | + applicable_to: Applicable to which entities. |
| 22 | + licensee: Reference to the licensee. |
| 23 | + eligibility: Eligibility criteria. |
| 24 | + status: Certificate status. |
| 25 | + status_notes: Additional notes on the certificate status. |
| 26 | + parameters: Certificate parameters. |
| 27 | + audit: Audit information. |
| 28 | + """ |
| 29 | + |
| 30 | + name: str | None |
| 31 | + program: BaseModel | None |
| 32 | + vendor: BaseModel | None |
| 33 | + external_ids: BaseModel | None |
| 34 | + client: BaseModel | None |
| 35 | + applicable_to: str | None |
| 36 | + licensee: BaseModel | None |
| 37 | + eligibility: BaseModel | None |
| 38 | + status: str | None |
| 39 | + status_notes: str | None |
| 40 | + parameters: BaseModel | None # noqa: WPS110 |
| 41 | + audit: BaseModel | None |
| 42 | + |
| 43 | + |
| 44 | +class CertificateServiceConfig: |
| 45 | + """Program certificate service config.""" |
| 46 | + |
| 47 | + _endpoint = "/public/v1/program/certificates" |
| 48 | + _model_class = Certificate |
| 49 | + _collection_key = "data" |
| 50 | + |
| 51 | + |
| 52 | +class CertificateService( |
| 53 | + ManagedResourceMixin[Certificate], |
| 54 | + CollectionMixin[Certificate], |
| 55 | + Service[Certificate], |
| 56 | + CertificateServiceConfig, |
| 57 | +): |
| 58 | + """Program certificate service.""" |
| 59 | + |
| 60 | + def terminate(self, resource_id: str, resource_data: ResourceData | None = None) -> Certificate: |
| 61 | + """Terminate a certificate. |
| 62 | +
|
| 63 | + Args: |
| 64 | + resource_id: Certificate ID. |
| 65 | + resource_data: Additional data for termination. |
| 66 | +
|
| 67 | + Returns: |
| 68 | + Terminated certificate. |
| 69 | + """ |
| 70 | + return self._resource(resource_id).post("/terminate", json=resource_data) |
| 71 | + |
| 72 | + |
| 73 | +class AsyncCertificateService( |
| 74 | + AsyncManagedResourceMixin[Certificate], |
| 75 | + AsyncCollectionMixin[Certificate], |
| 76 | + AsyncService[Certificate], |
| 77 | + CertificateServiceConfig, |
| 78 | +): |
| 79 | + """Asynchronous program certificate service.""" |
| 80 | + |
| 81 | + async def terminate( |
| 82 | + self, resource_id: str, resource_data: ResourceData | None = None |
| 83 | + ) -> Certificate: |
| 84 | + """Asynchronously terminate a certificate. |
| 85 | +
|
| 86 | + Args: |
| 87 | + resource_id: Certificate ID. |
| 88 | + resource_data: Additional data for termination. |
| 89 | +
|
| 90 | + Returns: |
| 91 | + Terminated certificate. |
| 92 | + """ |
| 93 | + return await self._resource(resource_id).post("/terminate", json=resource_data) |
0 commit comments