vectorize_client.models.sharepoint
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 pprint 17import re # noqa: F401 18import json 19 20from pydantic import BaseModel, ConfigDict, Field, StrictStr, field_validator 21from typing import Any, ClassVar, Dict, List 22from vectorize_client.models.sharepoint_auth_config import SHAREPOINTAuthConfig 23from typing import Optional, Set 24from typing_extensions import Self 25 26class Sharepoint(BaseModel): 27 """ 28 Sharepoint 29 """ # noqa: E501 30 name: StrictStr = Field(description="Name of the connector") 31 type: StrictStr = Field(description="Connector type (must be \"SHAREPOINT\")") 32 config: SHAREPOINTAuthConfig 33 __properties: ClassVar[List[str]] = ["name", "type", "config"] 34 35 @field_validator('type') 36 def type_validate_enum(cls, value): 37 """Validates the enum""" 38 if value not in set(['SHAREPOINT']): 39 raise ValueError("must be one of enum values ('SHAREPOINT')") 40 return value 41 42 model_config = ConfigDict( 43 populate_by_name=True, 44 validate_assignment=True, 45 protected_namespaces=(), 46 ) 47 48 49 def to_str(self) -> str: 50 """Returns the string representation of the model using alias""" 51 return pprint.pformat(self.model_dump(by_alias=True)) 52 53 def to_json(self) -> str: 54 """Returns the JSON representation of the model using alias""" 55 # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead 56 return json.dumps(self.to_dict()) 57 58 @classmethod 59 def from_json(cls, json_str: str) -> Optional[Self]: 60 """Create an instance of Sharepoint from a JSON string""" 61 return cls.from_dict(json.loads(json_str)) 62 63 def to_dict(self) -> Dict[str, Any]: 64 """Return the dictionary representation of the model using alias. 65 66 This has the following differences from calling pydantic's 67 `self.model_dump(by_alias=True)`: 68 69 * `None` is only added to the output dict for nullable fields that 70 were set at model initialization. Other fields with value `None` 71 are ignored. 72 """ 73 excluded_fields: Set[str] = set([ 74 ]) 75 76 _dict = self.model_dump( 77 by_alias=True, 78 exclude=excluded_fields, 79 exclude_none=True, 80 ) 81 # override the default output from pydantic by calling `to_dict()` of config 82 if self.config: 83 _dict['config'] = self.config.to_dict() 84 return _dict 85 86 @classmethod 87 def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]: 88 """Create an instance of Sharepoint from a dict""" 89 if obj is None: 90 return None 91 92 if not isinstance(obj, dict): 93 return cls.model_validate(obj) 94 95 _obj = cls.model_validate({ 96 "name": obj.get("name"), 97 "type": obj.get("type"), 98 "config": SHAREPOINTAuthConfig.from_dict(obj["config"]) if obj.get("config") is not None else None 99 }) 100 return _obj