build a Kubernetes Custom Resource Definition manifest, named as "Mediaplan" by this…
- User
build a Kubernetes Custom Resource Definition manifest, named as "Mediaplan" by this pydantic specification
from typing import List, Dict, Any, Optional
from pydantic import BaseModel
class Channel(BaseModel): name: str guid: str id: Optional[int] discussion_id: int link: Optional[int] discussion_link: str
class Topic(BaseModel): code: str weight: int = 1
class MessagingSettings(BaseModel): kind: str = 'topic' # topic topics: List[Topic] = []
class BotSettings(BaseModel): totalCount: int = 10 credentials: Dict[str, str] = {} mimicry: Dict[str, str] = {}
class CommonSettings(BaseModel): totalMessageCount: int = 1000 * 1000 estimatedLeadTime: str = '1h' disableMimicryOptions: bool = False didImageUsedForGeneration: bool = False
class MediaplanSpec(BaseModel): schedule: Optional[str] = None channel: Channel messagingSettings: MessagingSettings = MessagingSettings() settings: CommonSettings = CommonSettings() botSettings: BotSettings = BotSettings()
class Mediaplan(BaseModel): apiVersion: str = "crds.idom.project/v1alpha1" kind: str = "Mediaplan" metadata: Dict[str, Any] spec: MediaplanSpec
- Assistant
apiVersion: crds.idom.project/v1alpha1 kind: Mediaplan metadata: name: spec: schedule: channel: name: guid: id: discussion_id: link: discussion_link: messagingSettings: kind: topic topics: - code: weight: - code: weight: settings: totalMessageCount: estimatedLeadTime: disableMimicryOptions: didImageUsedForGeneration: botSettings: totalCount: credentials: : : . . : mimicry: : : . . :
- User
build a Kubernetes Custom Resource Definition by this pydantic specification
from typing import List, Dict, Any, Optional
from pydantic import BaseModel
class Channel(BaseModel): name: str guid: str id: Optional[int] discussion_id: int link: Optional[int] discussion_link: str
class Topic(BaseModel): code: str weight: int = 1
class MessagingSettings(BaseModel): kind: str = 'topic' # topic topics: List[Topic] = []
class BotSettings(BaseModel): totalCount: int = 10 credentials: Dict[str, str] = {} mimicry: Dict[str, str] = {}
class CommonSettings(BaseModel): totalMessageCount: int = 1000 * 1000 estimatedLeadTime: str = '1h' disableMimicryOptions: bool = False didImageUsedForGeneration: bool = False
class MediaplanSpec(BaseModel): schedule: Optional[str] = None channel: Channel messagingSettings: MessagingSettings = MessagingSettings() settings: CommonSettings = CommonSettings() botSettings: BotSettings = BotSettings()
class Mediaplan(BaseModel): apiVersion: str = "crds.idom.project/v1alpha1" kind: str = "Mediaplan" metadata: Dict[str, Any] spec: MediaplanSpec
- Assistant
apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: mediaplans.crds.idom.project spec: group: crds.idom.project names: kind: Mediaplan plural: mediaplans singular: mediaplan scope: Namespaced version: v1alpha1 validation: openAPIV3Schema: properties: apiVersion: type: string kind: type: string metadata: type: object properties: name: type: string spec: type: object properties: schedule: type: string channel: type: object properties: name: type: string guid: type: string id: type: integer discussion_id: type: integer link: type: integer discussion_link: type: string required: - name - guid - discussion_id - discussion_link messagingSettings: type: object properties: kind: type: string default: topic topics: type: array items: type: object properties: code: type: string weight: type: integer default: 1 settings: type: object properties: totalMessageCount: type: integer default: 1000000 estimatedLeadTime: type: string default: 1h disableMimicryOptions: type: boolean default: false didImageUsedForGeneration: type: boolean default: false botSettings: type: object properties: totalCount: type: integer default: 10 credentials: type: object additionalProperties: type: string mimicry: type: object additionalProperties: type: string
Note: Replace "<" and ">" along with their contents in this yaml manifest with the appropriate values. Also, don't forget to apply this manifest on your Kubernetes cluster using "kubectl apply -f your_manifest.yaml".
- User
build a Kubernetes Custom Resource Definition by this pydantic specification, with correct indentation
from typing import List, Dict, Any, Optional
from pydantic import BaseModel
class Channel(BaseModel): name: str guid: str id: Optional[int] discussion_id: int link: Optional[int] discussion_link: str
class Topic(BaseModel): code: str weight: int = 1
class MessagingSettings(BaseModel): kind: str = ‘topic’ # topic topics: List[Topic] = []
class BotSettings(BaseModel): totalCount: int = 10 credentials: Dict[str, str] = {} mimicry: Dict[str, str] = {}
class CommonSettings(BaseModel): totalMessageCount: int = 1000 * 1000 estimatedLeadTime: str = ‘1h’ disableMimicryOptions: bool = False didImageUsedForGeneration: bool = False
class MediaplanSpec(BaseModel): schedule: Optional[str] = None channel: Channel messagingSettings: MessagingSettings = MessagingSettings() settings: CommonSettings = CommonSettings() botSettings: BotSettings = BotSettings()
class Mediaplan(BaseModel): apiVersion: str = “crds.idom.project/v1alpha1” kind: str = “Mediaplan” metadata: Dict[str, Any] spec: MediaplanSpec
- Assistant
apiVersion: apiextensions.k8s.io/v1 kind: CustomResourceDefinition metadata: name: mediaplans.crds.idom.project spec: group: crds.idom.project names: kind: Mediaplan plural: mediaplans singular: mediaplan scope: Namespaced version: v1alpha1 validation: openAPIV3Schema: properties: apiVersion: type: string kind: type: string metadata: type: object properties: name: type: string spec: type: object properties: schedule: type: string channel: type: object properties: name: type: string guid: type: string id: type: integer discussion_id: type: integer link: type: integer discussion_link: type: string required: - name - guid - discussion_id - discussion_link messagingSettings: type: object properties: kind: type: string default: topic topics: type: array items: type: object properties: code: type: string weight: type: integer default: 1 settings: type: object properties: totalMessageCount: type: integer default: 1000000 estimatedLeadTime: type: string default: 1h disableMimicryOptions: type: boolean default: false didImageUsedForGeneration: type: boolean default: false botSettings: type: object properties: totalCount: type: integer default: 10 credentials: type: object additionalProperties: type: string mimicry: type: object additionalProperties: type: string
Note: The code should be properly indented to be interpreted as yaml file. Don't forget to replace the double quotes which are curly ( ” ) in the yaml file to normal ones(") after you copy it so that it can be accepted as a valid definition file.