Skip to content

Commit 362abca

Browse files
Generate certificates
1 parent e4f8b98 commit 362abca

7 files changed

Lines changed: 441 additions & 3 deletions

File tree

services/certificates/oas_commit

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
8ccf08fdae6320251259ca695f1e7180eeb21275
1+
5e44a8a3aa0447f4f0511f53cc4eead9b6e6384e

services/certificates/src/stackit/certificates/__init__.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,17 @@
2828
"ApiKeyError",
2929
"ApiAttributeError",
3030
"ApiException",
31+
"CertificateUsageItem",
3132
"CertificatesQuota",
3233
"CreateCertificatePayload",
34+
"Data",
3335
"GetCertificateResponse",
3436
"GetQuotaResponse",
3537
"GoogleProtobufAny",
3638
"ListCertificatesResponse",
3739
"Quotas",
3840
"Status",
41+
"Usage",
3942
]
4043

4144
# import apis into sdk package
@@ -53,12 +56,16 @@
5356
from stackit.certificates.exceptions import OpenApiException as OpenApiException
5457

5558
# import models into sdk package
59+
from stackit.certificates.models.certificate_usage_item import (
60+
CertificateUsageItem as CertificateUsageItem,
61+
)
5662
from stackit.certificates.models.certificates_quota import (
5763
CertificatesQuota as CertificatesQuota,
5864
)
5965
from stackit.certificates.models.create_certificate_payload import (
6066
CreateCertificatePayload as CreateCertificatePayload,
6167
)
68+
from stackit.certificates.models.data import Data as Data
6269
from stackit.certificates.models.get_certificate_response import (
6370
GetCertificateResponse as GetCertificateResponse,
6471
)
@@ -73,3 +80,4 @@
7380
)
7481
from stackit.certificates.models.quotas import Quotas as Quotas
7582
from stackit.certificates.models.status import Status as Status
83+
from stackit.certificates.models.usage import Usage as Usage

services/certificates/src/stackit/certificates/models/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@
1313
""" # noqa: E501
1414

1515
# import models into model package
16+
from stackit.certificates.models.certificate_usage_item import CertificateUsageItem
1617
from stackit.certificates.models.certificates_quota import CertificatesQuota
1718
from stackit.certificates.models.create_certificate_payload import (
1819
CreateCertificatePayload,
1920
)
21+
from stackit.certificates.models.data import Data
2022
from stackit.certificates.models.get_certificate_response import GetCertificateResponse
2123
from stackit.certificates.models.get_quota_response import GetQuotaResponse
2224
from stackit.certificates.models.google_protobuf_any import GoogleProtobufAny
@@ -25,3 +27,4 @@
2527
)
2628
from stackit.certificates.models.quotas import Quotas
2729
from stackit.certificates.models.status import Status
30+
from stackit.certificates.models.usage import Usage
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT Application Load Balancer Certificates API
5+
6+
This API offers the ability to store TLS certificates, which can be used by load balancing servers in STACKIT. They can be between consumer and load balancing server and/or between load balancing server and endpoint server.
7+
8+
The version of the OpenAPI document: 2.0.0
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501
13+
14+
from __future__ import annotations
15+
16+
import json
17+
import pprint
18+
from typing import Any, ClassVar, Dict, List, Optional, Set
19+
20+
from pydantic import BaseModel, ConfigDict, Field, StrictStr
21+
from pydantic_core import to_jsonable_python
22+
from typing_extensions import Self
23+
24+
25+
class CertificateUsageItem(BaseModel):
26+
"""
27+
CertificateUsageItem
28+
""" # noqa: E501
29+
30+
listener_names: Optional[List[StrictStr]] = Field(
31+
default=None,
32+
description="A list of listener names on this Load Balancer that are using the certificate.",
33+
alias="listenerNames",
34+
)
35+
load_balancer_name: Optional[StrictStr] = Field(
36+
default=None, description="The display name of the Load Balancer.", alias="loadBalancerName"
37+
)
38+
__properties: ClassVar[List[str]] = ["listenerNames", "loadBalancerName"]
39+
40+
model_config = ConfigDict(
41+
validate_by_name=True,
42+
validate_by_alias=True,
43+
validate_assignment=True,
44+
protected_namespaces=(),
45+
)
46+
47+
def to_str(self) -> str:
48+
"""Returns the string representation of the model using alias"""
49+
return pprint.pformat(self.model_dump(by_alias=True))
50+
51+
def to_json(self) -> str:
52+
"""Returns the JSON representation of the model using alias"""
53+
return json.dumps(to_jsonable_python(self.to_dict()))
54+
55+
@classmethod
56+
def from_json(cls, json_str: str) -> Optional[Self]:
57+
"""Create an instance of CertificateUsageItem from a JSON string"""
58+
return cls.from_dict(json.loads(json_str))
59+
60+
def to_dict(self) -> Dict[str, Any]:
61+
"""Return the dictionary representation of the model using alias.
62+
63+
This has the following differences from calling pydantic's
64+
`self.model_dump(by_alias=True)`:
65+
66+
* `None` is only added to the output dict for nullable fields that
67+
were set at model initialization. Other fields with value `None`
68+
are ignored.
69+
"""
70+
excluded_fields: Set[str] = set([])
71+
72+
_dict = self.model_dump(
73+
by_alias=True,
74+
exclude=excluded_fields,
75+
exclude_none=True,
76+
)
77+
return _dict
78+
79+
@classmethod
80+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
81+
"""Create an instance of CertificateUsageItem from a dict"""
82+
if obj is None:
83+
return None
84+
85+
if not isinstance(obj, dict):
86+
return cls.model_validate(obj)
87+
88+
_obj = cls.model_validate(
89+
{"listenerNames": obj.get("listenerNames"), "loadBalancerName": obj.get("loadBalancerName")}
90+
)
91+
return _obj
Lines changed: 220 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,220 @@
1+
# coding: utf-8
2+
3+
"""
4+
STACKIT Application Load Balancer Certificates API
5+
6+
This API offers the ability to store TLS certificates, which can be used by load balancing servers in STACKIT. They can be between consumer and load balancing server and/or between load balancing server and endpoint server.
7+
8+
The version of the OpenAPI document: 2.0.0
9+
Generated by OpenAPI Generator (https://openapi-generator.tech)
10+
11+
Do not edit the class manually.
12+
""" # noqa: E501
13+
14+
from __future__ import annotations
15+
16+
import json
17+
import pprint
18+
import re # noqa: F401
19+
from typing import Any, ClassVar, Dict, List, Optional, Set
20+
21+
from pydantic import (
22+
BaseModel,
23+
ConfigDict,
24+
Field,
25+
StrictBool,
26+
StrictStr,
27+
field_validator,
28+
)
29+
from pydantic_core import to_jsonable_python
30+
from typing_extensions import Annotated, Self
31+
32+
33+
class Data(BaseModel):
34+
"""
35+
Data
36+
""" # noqa: E501
37+
38+
dns_names: Optional[StrictStr] = Field(
39+
default=None,
40+
description="Comma-separated list of all domains and IP addresses the certificate is valid for (Subject Alternative Names).",
41+
alias="dnsNames",
42+
)
43+
extended_key_usage: Optional[StrictStr] = Field(
44+
default=None,
45+
description="Comma-separated list of purposes the cert is valid for. 'Server Auth' is required for Load Balancer use.",
46+
alias="extendedKeyUsage",
47+
)
48+
fingerprint_sha1: Optional[Annotated[str, Field(strict=True)]] = Field(
49+
default=None,
50+
description="The legacy SHA1 thumbprint. Provided for cross-referencing with older systems and browsers.",
51+
alias="fingerprintSha1",
52+
)
53+
fingerprint_sha256: Optional[Annotated[str, Field(strict=True)]] = Field(
54+
default=None,
55+
description="The unique SHA256 hash of the raw certificate bytes. Use this as the primary unique identifier.",
56+
alias="fingerprintSha256",
57+
)
58+
is_ca: Optional[StrictBool] = Field(
59+
default=None,
60+
description="Indicates if the certificate is a Certificate Authority, meaning it can sign other certificates.",
61+
alias="isCa",
62+
)
63+
is_self_signed: Optional[StrictBool] = Field(
64+
default=None,
65+
description="Indicates if the certificate was signed by its own private key rather than a trusted third-party CA.",
66+
alias="isSelfSigned",
67+
)
68+
issuer_cn: Optional[StrictStr] = Field(
69+
default=None,
70+
description="The Common Name of the Certificate Authority (CA) that signed and issued the certificate.",
71+
alias="issuerCn",
72+
)
73+
key_strength: Optional[StrictStr] = Field(
74+
default=None,
75+
description="Human-readable summary of the public key's algorithm and bit-length or curve name.",
76+
alias="keyStrength",
77+
)
78+
not_after: Optional[StrictStr] = Field(
79+
default=None,
80+
description="The expiration timestamp. After this date, browsers will show security warnings (RFC3339 format).",
81+
alias="notAfter",
82+
)
83+
not_before: Optional[StrictStr] = Field(
84+
default=None,
85+
description="The timestamp indicating when the certificate starts being valid (RFC3339 format).",
86+
alias="notBefore",
87+
)
88+
organization: Optional[StrictStr] = Field(
89+
default=None, description="Organization name associated with the certificate subject."
90+
)
91+
public_key_algorithm: Optional[StrictStr] = Field(
92+
default=None,
93+
description="The cryptographic algorithm used to generate the public/private key pair.",
94+
alias="publicKeyAlgorithm",
95+
)
96+
serial_number: Optional[StrictStr] = Field(
97+
default=None,
98+
description="The unique serial number assigned by the CA, represented in uppercase hexadecimal format.",
99+
alias="serialNumber",
100+
)
101+
signature_algorithm: Optional[StrictStr] = Field(
102+
default=None, description="The algorithm used by the CA to sign this certificate.", alias="signatureAlgorithm"
103+
)
104+
subject_cn: Optional[StrictStr] = Field(
105+
default=None,
106+
description="The primary identity of the certificate. Fallback sequence: Common Name -> First DNS Name -> Full Subject String.",
107+
alias="subjectCn",
108+
)
109+
__properties: ClassVar[List[str]] = [
110+
"dnsNames",
111+
"extendedKeyUsage",
112+
"fingerprintSha1",
113+
"fingerprintSha256",
114+
"isCa",
115+
"isSelfSigned",
116+
"issuerCn",
117+
"keyStrength",
118+
"notAfter",
119+
"notBefore",
120+
"organization",
121+
"publicKeyAlgorithm",
122+
"serialNumber",
123+
"signatureAlgorithm",
124+
"subjectCn",
125+
]
126+
127+
@field_validator("fingerprint_sha1")
128+
def fingerprint_sha1_validate_regular_expression(cls, value):
129+
"""Validates the regular expression"""
130+
if value is None:
131+
return value
132+
133+
if not isinstance(value, str):
134+
value = str(value)
135+
136+
if not re.match(r"^[a-fA-F0-9]{40}$", value):
137+
raise ValueError(r"must validate the regular expression /^[a-fA-F0-9]{40}$/")
138+
return value
139+
140+
@field_validator("fingerprint_sha256")
141+
def fingerprint_sha256_validate_regular_expression(cls, value):
142+
"""Validates the regular expression"""
143+
if value is None:
144+
return value
145+
146+
if not isinstance(value, str):
147+
value = str(value)
148+
149+
if not re.match(r"^[a-fA-F0-9]{64}$", value):
150+
raise ValueError(r"must validate the regular expression /^[a-fA-F0-9]{64}$/")
151+
return value
152+
153+
model_config = ConfigDict(
154+
validate_by_name=True,
155+
validate_by_alias=True,
156+
validate_assignment=True,
157+
protected_namespaces=(),
158+
)
159+
160+
def to_str(self) -> str:
161+
"""Returns the string representation of the model using alias"""
162+
return pprint.pformat(self.model_dump(by_alias=True))
163+
164+
def to_json(self) -> str:
165+
"""Returns the JSON representation of the model using alias"""
166+
return json.dumps(to_jsonable_python(self.to_dict()))
167+
168+
@classmethod
169+
def from_json(cls, json_str: str) -> Optional[Self]:
170+
"""Create an instance of Data from a JSON string"""
171+
return cls.from_dict(json.loads(json_str))
172+
173+
def to_dict(self) -> Dict[str, Any]:
174+
"""Return the dictionary representation of the model using alias.
175+
176+
This has the following differences from calling pydantic's
177+
`self.model_dump(by_alias=True)`:
178+
179+
* `None` is only added to the output dict for nullable fields that
180+
were set at model initialization. Other fields with value `None`
181+
are ignored.
182+
"""
183+
excluded_fields: Set[str] = set([])
184+
185+
_dict = self.model_dump(
186+
by_alias=True,
187+
exclude=excluded_fields,
188+
exclude_none=True,
189+
)
190+
return _dict
191+
192+
@classmethod
193+
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
194+
"""Create an instance of Data from a dict"""
195+
if obj is None:
196+
return None
197+
198+
if not isinstance(obj, dict):
199+
return cls.model_validate(obj)
200+
201+
_obj = cls.model_validate(
202+
{
203+
"dnsNames": obj.get("dnsNames"),
204+
"extendedKeyUsage": obj.get("extendedKeyUsage"),
205+
"fingerprintSha1": obj.get("fingerprintSha1"),
206+
"fingerprintSha256": obj.get("fingerprintSha256"),
207+
"isCa": obj.get("isCa"),
208+
"isSelfSigned": obj.get("isSelfSigned"),
209+
"issuerCn": obj.get("issuerCn"),
210+
"keyStrength": obj.get("keyStrength"),
211+
"notAfter": obj.get("notAfter"),
212+
"notBefore": obj.get("notBefore"),
213+
"organization": obj.get("organization"),
214+
"publicKeyAlgorithm": obj.get("publicKeyAlgorithm"),
215+
"serialNumber": obj.get("serialNumber"),
216+
"signatureAlgorithm": obj.get("signatureAlgorithm"),
217+
"subjectCn": obj.get("subjectCn"),
218+
}
219+
)
220+
return _obj

0 commit comments

Comments
 (0)