Skip to content
Merged
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
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import json
from typing import Union, Literal, List, Dict, Any, Type

from typing_extensions import Annotated
from pydantic import (
Field,
BaseModel,
ValidationError,
constr,
Expand Down Expand Up @@ -109,11 +110,18 @@ def _literal_name(class_):
+ ")$)"
)


class ApigeeProductAttribute(BaseModel):
class ApigeeProductAttributeOther(BaseModel):
name: constr(regex=PRODUCT_ATTRIBUTE_REGEX)
value: str

ApigeeProductAttributeSpecial = Annotated[
Union [
ApigeeProductAttributeAccess,
ApigeeProductAttributeRateLimit,
ApigeeProductAttributeRateLimiting,
],
Field(discriminator="name")
]

def _count_cls(items: List[Any], cls: Type):
return sum(isinstance(item, cls) for item in items)
Expand All @@ -122,14 +130,7 @@ def _count_cls(items: List[Any], cls: Type):
class ApigeeProduct(BaseModel):
name: str
approvalType: Literal["auto", "manual"] = "manual"
attributes: List[
Union[
ApigeeProductAttributeAccess,
ApigeeProductAttributeRateLimit,
ApigeeProductAttributeRateLimiting,
ApigeeProductAttribute,
],
] = [{"name": "access", "value": "private"}]
attributes: List[Union[ApigeeProductAttributeSpecial, ApigeeProductAttributeOther]] = [{"name": "access", "value": "private"}]
description: str = None
displayName: str = None

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from ansible_collections.nhsd.apigee.plugins.module_utils.paas import api_registry

SCHEMA_VERSION = "1.1.4"
SCHEMA_VERSION = "1.1.5"

_REGISTRY_DATA = {}

Expand Down
Loading