Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion services/certificates/oas_commit
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8ccf08fdae6320251259ca695f1e7180eeb21275
5e44a8a3aa0447f4f0511f53cc4eead9b6e6384e
8 changes: 8 additions & 0 deletions services/certificates/src/stackit/certificates/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,17 @@
"ApiKeyError",
"ApiAttributeError",
"ApiException",
"CertificateUsageItem",
"CertificatesQuota",
"CreateCertificatePayload",
"Data",
"GetCertificateResponse",
"GetQuotaResponse",
"GoogleProtobufAny",
"ListCertificatesResponse",
"Quotas",
"Status",
"Usage",
]

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

# import models into sdk package
from stackit.certificates.models.certificate_usage_item import (
CertificateUsageItem as CertificateUsageItem,
)
from stackit.certificates.models.certificates_quota import (
CertificatesQuota as CertificatesQuota,
)
from stackit.certificates.models.create_certificate_payload import (
CreateCertificatePayload as CreateCertificatePayload,
)
from stackit.certificates.models.data import Data as Data
from stackit.certificates.models.get_certificate_response import (
GetCertificateResponse as GetCertificateResponse,
)
Expand All @@ -73,3 +80,4 @@
)
from stackit.certificates.models.quotas import Quotas as Quotas
from stackit.certificates.models.status import Status as Status
from stackit.certificates.models.usage import Usage as Usage
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@
""" # noqa: E501

# import models into model package
from stackit.certificates.models.certificate_usage_item import CertificateUsageItem
from stackit.certificates.models.certificates_quota import CertificatesQuota
from stackit.certificates.models.create_certificate_payload import (
CreateCertificatePayload,
)
from stackit.certificates.models.data import Data
from stackit.certificates.models.get_certificate_response import GetCertificateResponse
from stackit.certificates.models.get_quota_response import GetQuotaResponse
from stackit.certificates.models.google_protobuf_any import GoogleProtobufAny
Expand All @@ -25,3 +27,4 @@
)
from stackit.certificates.models.quotas import Quotas
from stackit.certificates.models.status import Status
from stackit.certificates.models.usage import Usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# coding: utf-8

"""
STACKIT Application Load Balancer Certificates API

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.

The version of the OpenAPI document: 2.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501

from __future__ import annotations

import json
import pprint
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import BaseModel, ConfigDict, Field, StrictStr
from pydantic_core import to_jsonable_python
from typing_extensions import Self


class CertificateUsageItem(BaseModel):
"""
CertificateUsageItem
""" # noqa: E501

listener_names: Optional[List[StrictStr]] = Field(
default=None,
description="A list of listener names on this Load Balancer that are using the certificate.",
alias="listenerNames",
)
load_balancer_name: Optional[StrictStr] = Field(
default=None, description="The display name of the Load Balancer.", alias="loadBalancerName"
)
__properties: ClassVar[List[str]] = ["listenerNames", "loadBalancerName"]

model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=True,
validate_assignment=True,
protected_namespaces=(),
)

def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(to_jsonable_python(self.to_dict()))

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of CertificateUsageItem from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:

* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([])

_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
return _dict

@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of CertificateUsageItem from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate(
{"listenerNames": obj.get("listenerNames"), "loadBalancerName": obj.get("loadBalancerName")}
)
return _obj
220 changes: 220 additions & 0 deletions services/certificates/src/stackit/certificates/models/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
# coding: utf-8

"""
STACKIT Application Load Balancer Certificates API

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.

The version of the OpenAPI document: 2.0.0
Generated by OpenAPI Generator (https://openapi-generator.tech)

Do not edit the class manually.
""" # noqa: E501

from __future__ import annotations

import json
import pprint
import re # noqa: F401
from typing import Any, ClassVar, Dict, List, Optional, Set

from pydantic import (
BaseModel,
ConfigDict,
Field,
StrictBool,
StrictStr,
field_validator,
)
from pydantic_core import to_jsonable_python
from typing_extensions import Annotated, Self


class Data(BaseModel):
"""
Data
""" # noqa: E501

dns_names: Optional[StrictStr] = Field(
default=None,
description="Comma-separated list of all domains and IP addresses the certificate is valid for (Subject Alternative Names).",
alias="dnsNames",
)
extended_key_usage: Optional[StrictStr] = Field(
default=None,
description="Comma-separated list of purposes the cert is valid for. 'Server Auth' is required for Load Balancer use.",
alias="extendedKeyUsage",
)
fingerprint_sha1: Optional[Annotated[str, Field(strict=True)]] = Field(
default=None,
description="The legacy SHA1 thumbprint. Provided for cross-referencing with older systems and browsers.",
alias="fingerprintSha1",
)
fingerprint_sha256: Optional[Annotated[str, Field(strict=True)]] = Field(
default=None,
description="The unique SHA256 hash of the raw certificate bytes. Use this as the primary unique identifier.",
alias="fingerprintSha256",
)
is_ca: Optional[StrictBool] = Field(
default=None,
description="Indicates if the certificate is a Certificate Authority, meaning it can sign other certificates.",
alias="isCa",
)
is_self_signed: Optional[StrictBool] = Field(
default=None,
description="Indicates if the certificate was signed by its own private key rather than a trusted third-party CA.",
alias="isSelfSigned",
)
issuer_cn: Optional[StrictStr] = Field(
default=None,
description="The Common Name of the Certificate Authority (CA) that signed and issued the certificate.",
alias="issuerCn",
)
key_strength: Optional[StrictStr] = Field(
default=None,
description="Human-readable summary of the public key's algorithm and bit-length or curve name.",
alias="keyStrength",
)
not_after: Optional[StrictStr] = Field(
default=None,
description="The expiration timestamp. After this date, browsers will show security warnings (RFC3339 format).",
alias="notAfter",
)
not_before: Optional[StrictStr] = Field(
default=None,
description="The timestamp indicating when the certificate starts being valid (RFC3339 format).",
alias="notBefore",
)
organization: Optional[StrictStr] = Field(
default=None, description="Organization name associated with the certificate subject."
)
public_key_algorithm: Optional[StrictStr] = Field(
default=None,
description="The cryptographic algorithm used to generate the public/private key pair.",
alias="publicKeyAlgorithm",
)
serial_number: Optional[StrictStr] = Field(
default=None,
description="The unique serial number assigned by the CA, represented in uppercase hexadecimal format.",
alias="serialNumber",
)
signature_algorithm: Optional[StrictStr] = Field(
default=None, description="The algorithm used by the CA to sign this certificate.", alias="signatureAlgorithm"
)
subject_cn: Optional[StrictStr] = Field(
default=None,
description="The primary identity of the certificate. Fallback sequence: Common Name -> First DNS Name -> Full Subject String.",
alias="subjectCn",
)
__properties: ClassVar[List[str]] = [
"dnsNames",
"extendedKeyUsage",
"fingerprintSha1",
"fingerprintSha256",
"isCa",
"isSelfSigned",
"issuerCn",
"keyStrength",
"notAfter",
"notBefore",
"organization",
"publicKeyAlgorithm",
"serialNumber",
"signatureAlgorithm",
"subjectCn",
]

@field_validator("fingerprint_sha1")
def fingerprint_sha1_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if value is None:
return value

if not isinstance(value, str):
value = str(value)

if not re.match(r"^[a-fA-F0-9]{40}$", value):
raise ValueError(r"must validate the regular expression /^[a-fA-F0-9]{40}$/")
return value

@field_validator("fingerprint_sha256")
def fingerprint_sha256_validate_regular_expression(cls, value):
"""Validates the regular expression"""
if value is None:
return value

if not isinstance(value, str):
value = str(value)

if not re.match(r"^[a-fA-F0-9]{64}$", value):
raise ValueError(r"must validate the regular expression /^[a-fA-F0-9]{64}$/")
return value

model_config = ConfigDict(
validate_by_name=True,
validate_by_alias=True,
validate_assignment=True,
protected_namespaces=(),
)

def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
return json.dumps(to_jsonable_python(self.to_dict()))

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of Data from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:

* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([])

_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
return _dict

@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of Data from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_obj = cls.model_validate(
{
"dnsNames": obj.get("dnsNames"),
"extendedKeyUsage": obj.get("extendedKeyUsage"),
"fingerprintSha1": obj.get("fingerprintSha1"),
"fingerprintSha256": obj.get("fingerprintSha256"),
"isCa": obj.get("isCa"),
"isSelfSigned": obj.get("isSelfSigned"),
"issuerCn": obj.get("issuerCn"),
"keyStrength": obj.get("keyStrength"),
"notAfter": obj.get("notAfter"),
"notBefore": obj.get("notBefore"),
"organization": obj.get("organization"),
"publicKeyAlgorithm": obj.get("publicKeyAlgorithm"),
"serialNumber": obj.get("serialNumber"),
"signatureAlgorithm": obj.get("signatureAlgorithm"),
"subjectCn": obj.get("subjectCn"),
}
)
return _obj
Loading
Loading