vectorize_client.models.create_ai_platform_connector_request

Vectorize API

API for Vectorize services (Beta)

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

Do not edit the class manually.

  1# coding: utf-8
  2
  3"""
  4    Vectorize API
  5
  6    API for Vectorize services (Beta)
  7
  8    The version of the OpenAPI document: 0.1.2
  9    Generated by OpenAPI Generator (https://openapi-generator.tech)
 10
 11    Do not edit the class manually.
 12"""  # noqa: E501
 13
 14
 15from __future__ import annotations
 16import json
 17import pprint
 18from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
 19from typing import Any, List, Optional
 20from vectorize_client.models.bedrock import Bedrock
 21from vectorize_client.models.openai import Openai
 22from vectorize_client.models.vertex import Vertex
 23from vectorize_client.models.voyage import Voyage
 24from pydantic import StrictStr, Field
 25from typing import Union, List, Set, Optional, Dict
 26from typing_extensions import Literal, Self
 27
 28CREATEAIPLATFORMCONNECTORREQUEST_ONE_OF_SCHEMAS = ["Bedrock", "Openai", "Vertex", "Voyage"]
 29
 30class CreateAIPlatformConnectorRequest(BaseModel):
 31    """
 32    CreateAIPlatformConnectorRequest
 33    """
 34    # data type: Bedrock
 35    oneof_schema_1_validator: Optional[Bedrock] = None
 36    # data type: Vertex
 37    oneof_schema_2_validator: Optional[Vertex] = None
 38    # data type: Openai
 39    oneof_schema_3_validator: Optional[Openai] = None
 40    # data type: Voyage
 41    oneof_schema_4_validator: Optional[Voyage] = None
 42    actual_instance: Optional[Union[Bedrock, Openai, Vertex, Voyage]] = None
 43    one_of_schemas: Set[str] = { "Bedrock", "Openai", "Vertex", "Voyage" }
 44
 45    model_config = ConfigDict(
 46        validate_assignment=True,
 47        protected_namespaces=(),
 48    )
 49
 50
 51    discriminator_value_class_map: Dict[str, str] = {
 52    }
 53
 54    def __init__(self, *args, **kwargs) -> None:
 55        if args:
 56            if len(args) > 1:
 57                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
 58            if kwargs:
 59                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
 60            super().__init__(actual_instance=args[0])
 61        else:
 62            super().__init__(**kwargs)
 63
 64    @field_validator('actual_instance')
 65    def actual_instance_must_validate_oneof(cls, v):
 66        instance = CreateAIPlatformConnectorRequest.model_construct()
 67        error_messages = []
 68        match = 0
 69        # validate data type: Bedrock
 70        if not isinstance(v, Bedrock):
 71            error_messages.append(f"Error! Input type `{type(v)}` is not `Bedrock`")
 72        else:
 73            match += 1
 74        # validate data type: Vertex
 75        if not isinstance(v, Vertex):
 76            error_messages.append(f"Error! Input type `{type(v)}` is not `Vertex`")
 77        else:
 78            match += 1
 79        # validate data type: Openai
 80        if not isinstance(v, Openai):
 81            error_messages.append(f"Error! Input type `{type(v)}` is not `Openai`")
 82        else:
 83            match += 1
 84        # validate data type: Voyage
 85        if not isinstance(v, Voyage):
 86            error_messages.append(f"Error! Input type `{type(v)}` is not `Voyage`")
 87        else:
 88            match += 1
 89        if match > 1:
 90            # more than 1 match
 91            raise ValueError("Multiple matches found when setting `actual_instance` in CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
 92        elif match == 0:
 93            # no match
 94            raise ValueError("No match found when setting `actual_instance` in CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
 95        else:
 96            return v
 97
 98    @classmethod
 99    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
100        return cls.from_json(json.dumps(obj))
101
102    @classmethod
103    def from_json(cls, json_str: str) -> Self:
104        """Returns the object represented by the json string"""
105        instance = cls.model_construct()
106        error_messages = []
107        match = 0
108
109        # deserialize data into Bedrock
110        try:
111            instance.actual_instance = Bedrock.from_json(json_str)
112            match += 1
113        except (ValidationError, ValueError) as e:
114            error_messages.append(str(e))
115        # deserialize data into Vertex
116        try:
117            instance.actual_instance = Vertex.from_json(json_str)
118            match += 1
119        except (ValidationError, ValueError) as e:
120            error_messages.append(str(e))
121        # deserialize data into Openai
122        try:
123            instance.actual_instance = Openai.from_json(json_str)
124            match += 1
125        except (ValidationError, ValueError) as e:
126            error_messages.append(str(e))
127        # deserialize data into Voyage
128        try:
129            instance.actual_instance = Voyage.from_json(json_str)
130            match += 1
131        except (ValidationError, ValueError) as e:
132            error_messages.append(str(e))
133
134        if match > 1:
135            # more than 1 match
136            raise ValueError("Multiple matches found when deserializing the JSON string into CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
137        elif match == 0:
138            # no match
139            raise ValueError("No match found when deserializing the JSON string into CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
140        else:
141            return instance
142
143    def to_json(self) -> str:
144        """Returns the JSON representation of the actual instance"""
145        if self.actual_instance is None:
146            return "null"
147
148        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
149            return self.actual_instance.to_json()
150        else:
151            return json.dumps(self.actual_instance)
152
153    def to_dict(self) -> Optional[Union[Dict[str, Any], Bedrock, Openai, Vertex, Voyage]]:
154        """Returns the dict representation of the actual instance"""
155        if self.actual_instance is None:
156            return None
157
158        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
159            return self.actual_instance.to_dict()
160        else:
161            # primitive type
162            return self.actual_instance
163
164    def to_str(self) -> str:
165        """Returns the string representation of the actual instance"""
166        return pprint.pformat(self.model_dump())
CREATEAIPLATFORMCONNECTORREQUEST_ONE_OF_SCHEMAS = ['Bedrock', 'Openai', 'Vertex', 'Voyage']
class CreateAIPlatformConnectorRequest(pydantic.main.BaseModel):
 31class CreateAIPlatformConnectorRequest(BaseModel):
 32    """
 33    CreateAIPlatformConnectorRequest
 34    """
 35    # data type: Bedrock
 36    oneof_schema_1_validator: Optional[Bedrock] = None
 37    # data type: Vertex
 38    oneof_schema_2_validator: Optional[Vertex] = None
 39    # data type: Openai
 40    oneof_schema_3_validator: Optional[Openai] = None
 41    # data type: Voyage
 42    oneof_schema_4_validator: Optional[Voyage] = None
 43    actual_instance: Optional[Union[Bedrock, Openai, Vertex, Voyage]] = None
 44    one_of_schemas: Set[str] = { "Bedrock", "Openai", "Vertex", "Voyage" }
 45
 46    model_config = ConfigDict(
 47        validate_assignment=True,
 48        protected_namespaces=(),
 49    )
 50
 51
 52    discriminator_value_class_map: Dict[str, str] = {
 53    }
 54
 55    def __init__(self, *args, **kwargs) -> None:
 56        if args:
 57            if len(args) > 1:
 58                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
 59            if kwargs:
 60                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
 61            super().__init__(actual_instance=args[0])
 62        else:
 63            super().__init__(**kwargs)
 64
 65    @field_validator('actual_instance')
 66    def actual_instance_must_validate_oneof(cls, v):
 67        instance = CreateAIPlatformConnectorRequest.model_construct()
 68        error_messages = []
 69        match = 0
 70        # validate data type: Bedrock
 71        if not isinstance(v, Bedrock):
 72            error_messages.append(f"Error! Input type `{type(v)}` is not `Bedrock`")
 73        else:
 74            match += 1
 75        # validate data type: Vertex
 76        if not isinstance(v, Vertex):
 77            error_messages.append(f"Error! Input type `{type(v)}` is not `Vertex`")
 78        else:
 79            match += 1
 80        # validate data type: Openai
 81        if not isinstance(v, Openai):
 82            error_messages.append(f"Error! Input type `{type(v)}` is not `Openai`")
 83        else:
 84            match += 1
 85        # validate data type: Voyage
 86        if not isinstance(v, Voyage):
 87            error_messages.append(f"Error! Input type `{type(v)}` is not `Voyage`")
 88        else:
 89            match += 1
 90        if match > 1:
 91            # more than 1 match
 92            raise ValueError("Multiple matches found when setting `actual_instance` in CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
 93        elif match == 0:
 94            # no match
 95            raise ValueError("No match found when setting `actual_instance` in CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
 96        else:
 97            return v
 98
 99    @classmethod
100    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
101        return cls.from_json(json.dumps(obj))
102
103    @classmethod
104    def from_json(cls, json_str: str) -> Self:
105        """Returns the object represented by the json string"""
106        instance = cls.model_construct()
107        error_messages = []
108        match = 0
109
110        # deserialize data into Bedrock
111        try:
112            instance.actual_instance = Bedrock.from_json(json_str)
113            match += 1
114        except (ValidationError, ValueError) as e:
115            error_messages.append(str(e))
116        # deserialize data into Vertex
117        try:
118            instance.actual_instance = Vertex.from_json(json_str)
119            match += 1
120        except (ValidationError, ValueError) as e:
121            error_messages.append(str(e))
122        # deserialize data into Openai
123        try:
124            instance.actual_instance = Openai.from_json(json_str)
125            match += 1
126        except (ValidationError, ValueError) as e:
127            error_messages.append(str(e))
128        # deserialize data into Voyage
129        try:
130            instance.actual_instance = Voyage.from_json(json_str)
131            match += 1
132        except (ValidationError, ValueError) as e:
133            error_messages.append(str(e))
134
135        if match > 1:
136            # more than 1 match
137            raise ValueError("Multiple matches found when deserializing the JSON string into CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
138        elif match == 0:
139            # no match
140            raise ValueError("No match found when deserializing the JSON string into CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
141        else:
142            return instance
143
144    def to_json(self) -> str:
145        """Returns the JSON representation of the actual instance"""
146        if self.actual_instance is None:
147            return "null"
148
149        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
150            return self.actual_instance.to_json()
151        else:
152            return json.dumps(self.actual_instance)
153
154    def to_dict(self) -> Optional[Union[Dict[str, Any], Bedrock, Openai, Vertex, Voyage]]:
155        """Returns the dict representation of the actual instance"""
156        if self.actual_instance is None:
157            return None
158
159        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
160            return self.actual_instance.to_dict()
161        else:
162            # primitive type
163            return self.actual_instance
164
165    def to_str(self) -> str:
166        """Returns the string representation of the actual instance"""
167        return pprint.pformat(self.model_dump())

CreateAIPlatformConnectorRequest

CreateAIPlatformConnectorRequest(*args, **kwargs)
55    def __init__(self, *args, **kwargs) -> None:
56        if args:
57            if len(args) > 1:
58                raise ValueError("If a position argument is used, only 1 is allowed to set `actual_instance`")
59            if kwargs:
60                raise ValueError("If a position argument is used, keyword arguments cannot be used.")
61            super().__init__(actual_instance=args[0])
62        else:
63            super().__init__(**kwargs)

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

oneof_schema_1_validator: Optional[vectorize_client.models.bedrock.Bedrock]
oneof_schema_2_validator: Optional[vectorize_client.models.vertex.Vertex]
oneof_schema_3_validator: Optional[vectorize_client.models.openai.Openai]
oneof_schema_4_validator: Optional[vectorize_client.models.voyage.Voyage]
one_of_schemas: Set[str]
model_config = {'validate_assignment': True, 'protected_namespaces': ()}

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

discriminator_value_class_map: Dict[str, str]
@field_validator('actual_instance')
def actual_instance_must_validate_oneof(cls, v):
65    @field_validator('actual_instance')
66    def actual_instance_must_validate_oneof(cls, v):
67        instance = CreateAIPlatformConnectorRequest.model_construct()
68        error_messages = []
69        match = 0
70        # validate data type: Bedrock
71        if not isinstance(v, Bedrock):
72            error_messages.append(f"Error! Input type `{type(v)}` is not `Bedrock`")
73        else:
74            match += 1
75        # validate data type: Vertex
76        if not isinstance(v, Vertex):
77            error_messages.append(f"Error! Input type `{type(v)}` is not `Vertex`")
78        else:
79            match += 1
80        # validate data type: Openai
81        if not isinstance(v, Openai):
82            error_messages.append(f"Error! Input type `{type(v)}` is not `Openai`")
83        else:
84            match += 1
85        # validate data type: Voyage
86        if not isinstance(v, Voyage):
87            error_messages.append(f"Error! Input type `{type(v)}` is not `Voyage`")
88        else:
89            match += 1
90        if match > 1:
91            # more than 1 match
92            raise ValueError("Multiple matches found when setting `actual_instance` in CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
93        elif match == 0:
94            # no match
95            raise ValueError("No match found when setting `actual_instance` in CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
96        else:
97            return v
@classmethod
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
 99    @classmethod
100    def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
101        return cls.from_json(json.dumps(obj))
@classmethod
def from_json(cls, json_str: str) -> Self:
103    @classmethod
104    def from_json(cls, json_str: str) -> Self:
105        """Returns the object represented by the json string"""
106        instance = cls.model_construct()
107        error_messages = []
108        match = 0
109
110        # deserialize data into Bedrock
111        try:
112            instance.actual_instance = Bedrock.from_json(json_str)
113            match += 1
114        except (ValidationError, ValueError) as e:
115            error_messages.append(str(e))
116        # deserialize data into Vertex
117        try:
118            instance.actual_instance = Vertex.from_json(json_str)
119            match += 1
120        except (ValidationError, ValueError) as e:
121            error_messages.append(str(e))
122        # deserialize data into Openai
123        try:
124            instance.actual_instance = Openai.from_json(json_str)
125            match += 1
126        except (ValidationError, ValueError) as e:
127            error_messages.append(str(e))
128        # deserialize data into Voyage
129        try:
130            instance.actual_instance = Voyage.from_json(json_str)
131            match += 1
132        except (ValidationError, ValueError) as e:
133            error_messages.append(str(e))
134
135        if match > 1:
136            # more than 1 match
137            raise ValueError("Multiple matches found when deserializing the JSON string into CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
138        elif match == 0:
139            # no match
140            raise ValueError("No match found when deserializing the JSON string into CreateAIPlatformConnectorRequest with oneOf schemas: Bedrock, Openai, Vertex, Voyage. Details: " + ", ".join(error_messages))
141        else:
142            return instance

Returns the object represented by the json string

def to_json(self) -> str:
144    def to_json(self) -> str:
145        """Returns the JSON representation of the actual instance"""
146        if self.actual_instance is None:
147            return "null"
148
149        if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
150            return self.actual_instance.to_json()
151        else:
152            return json.dumps(self.actual_instance)

Returns the JSON representation of the actual instance

154    def to_dict(self) -> Optional[Union[Dict[str, Any], Bedrock, Openai, Vertex, Voyage]]:
155        """Returns the dict representation of the actual instance"""
156        if self.actual_instance is None:
157            return None
158
159        if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict):
160            return self.actual_instance.to_dict()
161        else:
162            # primitive type
163            return self.actual_instance

Returns the dict representation of the actual instance

def to_str(self) -> str:
165    def to_str(self) -> str:
166        """Returns the string representation of the actual instance"""
167        return pprint.pformat(self.model_dump())

Returns the string representation of the actual instance