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
124 changes: 85 additions & 39 deletions phrasetms_client/models/abstract_analyse_settings_dto.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# coding: utf-8

"""
Phrase TMS API
Phrase TMS API

Welcome to Phrase's TMS API documentation. Please visit our [help center](https://support.phrase.com/hc/en-us/sections/5709662083612) for more information about the APIs. If you have any questions, please contact [Support](https://support.phrase.com/hc/requests/new). Please, include the `User-Agent` header with the name of your application or project. It might be a good idea to include some sort of contact information as well, so that we can get in touch if necessary. Examples of excellent `User-Agent` headers: > User-Agent: Example mobile app (example@phrase.com) <br/> User-Agent: ACME Inc Java 1.8 Client (http://acmeinc.com/contact) # noqa: E501
Welcome to Phrase's TMS API documentation. Please visit our [help center](https://support.phrase.com/hc/en-us/sections/5709662083612) for more information about the APIs. If you have any questions, please contact [Support](https://support.phrase.com/hc/requests/new). Please, include the `User-Agent` header with the name of your application or project. It might be a good idea to include some sort of contact information as well, so that we can get in touch if necessary. Examples of excellent `User-Agent` headers: > User-Agent: Example mobile app (example@phrase.com) <br/> User-Agent: ACME Inc Java 1.8 Client (http://acmeinc.com/contact) # noqa: E501

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

Do not edit the class manually.
Do not edit the class manually.
"""


from __future__ import annotations
import pprint
import re # noqa: F401
Expand All @@ -20,53 +19,95 @@


from typing import Optional, Union
from pydantic import BaseModel, Field, ConfigDict, StrictBool, StrictStr, field_validator
from pydantic import (
BaseModel,
Field,
ConfigDict,
StrictBool,
StrictStr,
field_validator,
)


class AbstractAnalyseSettingsDto(BaseModel):
"""
Base analyseSettingsDto
"""
type: Optional[StrictStr] = Field(None, description="Response differs based on analyse type")
include_confirmed_segments: Optional[StrictBool] = Field(None, alias="includeConfirmedSegments", description="Default: false")
include_numbers: Optional[StrictBool] = Field(None, alias="includeNumbers", description="Default: false")
include_locked_segments: Optional[StrictBool] = Field(None, alias="includeLockedSegments", description="Default: false")
count_source_units: Optional[StrictBool] = Field(None, alias="countSourceUnits", description="Default: false")
include_trans_memory: Optional[StrictBool] = Field(None, alias="includeTransMemory", description="Default: false")
naming_pattern: Optional[StrictStr] = Field(None, alias="namingPattern")
analyze_by_language: Optional[StrictBool] = Field(None, alias="analyzeByLanguage", description="Default: false")
analyze_by_provider: Optional[StrictBool] = Field(None, alias="analyzeByProvider", description="Default: false")
allow_automatic_post_analysis: Optional[StrictBool] = Field(None, alias="allowAutomaticPostAnalysis", description="If automatic post analysis should be created after update source. Default: false")
__properties = ["type", "includeConfirmedSegments", "includeNumbers", "includeLockedSegments", "countSourceUnits", "includeTransMemory", "namingPattern", "analyzeByLanguage", "analyzeByProvider", "allowAutomaticPostAnalysis"]

@field_validator('type')
type: Optional[StrictStr] = Field(
None, description="Response differs based on analyse type"
)
include_confirmed_segments: Optional[StrictBool] = Field(
None, alias="includeConfirmedSegments", description="Default: false"
)
include_numbers: Optional[StrictBool] = Field(
None, alias="includeNumbers", description="Default: false"
)
include_locked_segments: Optional[StrictBool] = Field(
None, alias="includeLockedSegments", description="Default: false"
)
count_source_units: Optional[StrictBool] = Field(
None, alias="countSourceUnits", description="Default: false"
)
include_trans_memory: Optional[StrictBool] = Field(
None, alias="includeTransMemory", description="Default: false"
)
naming_pattern: Optional[StrictStr] = Field(None, alias="namingPattern")
analyze_by_language: Optional[StrictBool] = Field(
None, alias="analyzeByLanguage", description="Default: false"
)
analyze_by_provider: Optional[StrictBool] = Field(
None, alias="analyzeByProvider", description="Default: false"
)
allow_automatic_post_analysis: Optional[StrictBool] = Field(
None,
alias="allowAutomaticPostAnalysis",
description="If automatic post analysis should be created after update source. Default: false",
)
__properties = [
"type",
"includeConfirmedSegments",
"includeNumbers",
"includeLockedSegments",
"countSourceUnits",
"includeTransMemory",
"namingPattern",
"analyzeByLanguage",
"analyzeByProvider",
"allowAutomaticPostAnalysis",
]

@field_validator("type")
@classmethod
def type_validate_enum(cls, value):
"""Validates the enum"""
if value is None:
return value

if value not in ('PreAnalyse', 'PostAnalyse', 'PreAnalyseTarget', 'Compare'):
raise ValueError("must be one of enum values ('PreAnalyse', 'PostAnalyse', 'PreAnalyseTarget', 'Compare')")
if value not in ("PreAnalyse", "PostAnalyse", "PreAnalyseTarget", "Compare"):
raise ValueError(
"must be one of enum values ('PreAnalyse', 'PostAnalyse', 'PreAnalyseTarget', 'Compare')"
)
return value

model_config = ConfigDict(populate_by_name=True, validate_assignment=True)
# JSON field name that stores the object type
__discriminator_property_name = 'type'
_discriminator_property_name = "type"

# discriminator mappings
__discriminator_value_class_map = {
'PostAnalyse': 'PostAnalyse',
'PreAnalyse': 'PreAnalyse',
'PreAnalyseTarget': 'PreAnalyseTargetCompare',
'Compare': 'PreAnalyseTargetCompare'
_discriminator_value_class_map = {
"PostAnalyse": "PostAnalyse",
"PreAnalyse": "PreAnalyse",
"PreAnalyseTarget": "PreAnalyseTargetCompare",
"Compare": "PreAnalyseTargetCompare",
}

@classmethod
def get_discriminator_value(cls, obj: dict) -> str:
"""Returns the discriminator value (object type) of the data"""
discriminator_value = obj[cls.__discriminator_property_name]
discriminator_value = obj[cls._discriminator_property_name.default]
if discriminator_value:
return cls.__discriminator_value_class_map.get(discriminator_value)
return cls._discriminator_value_class_map.default.get(discriminator_value)
else:
return None

Expand All @@ -79,28 +120,33 @@ def to_json(self) -> str:
return json.dumps(self.to_dict())

@classmethod
def from_json(cls, json_str: str) -> Union(PostAnalyse, PreAnalyse, PreAnalyseTargetCompare): # noqa: F821
def from_json(
cls, json_str: str
) -> Union["PostAnalyse", "PreAnalyse", "PreAnalyseTargetCompare"]:
"""Create an instance of AbstractAnalyseSettingsDto from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.model_dump(by_alias=True,
exclude={
},
exclude_none=True)
_dict = self.model_dump(by_alias=True, exclude={}, exclude_none=True)
return _dict

@classmethod
def from_dict(cls, obj: dict) -> Union(PostAnalyse, PreAnalyse, PreAnalyseTargetCompare): # noqa: F821
def from_dict(
cls, obj: dict
) -> Union["PostAnalyse", "PreAnalyse", "PreAnalyseTargetCompare"]:
"""Create an instance of AbstractAnalyseSettingsDto from a dict"""
# look up the object type based on discriminator mapping
object_type = cls.get_discriminator_value(obj)
if object_type:
klass = getattr(phrasetms_client.models, object_type)
return klass.from_dict(obj)
else:
raise ValueError("AbstractAnalyseSettingsDto failed to lookup discriminator value from " +
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
", mapping: " + json.dumps(cls.__discriminator_value_class_map))

raise ValueError(
"AbstractAnalyseSettingsDto failed to lookup discriminator value from "
+ json.dumps(obj)
+ ". Discriminator property name: "
+ cls._discriminator_property_name.default
+ ", mapping: "
+ json.dumps(cls._discriminator_value_class_map.default)
)
121 changes: 82 additions & 39 deletions phrasetms_client/models/abstract_connector_dto.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
# coding: utf-8

"""
Phrase TMS API
Phrase TMS API

Welcome to Phrase's TMS API documentation. Please visit our [help center](https://support.phrase.com/hc/en-us/sections/5709662083612) for more information about the APIs. If you have any questions, please contact [Support](https://support.phrase.com/hc/requests/new). Please, include the `User-Agent` header with the name of your application or project. It might be a good idea to include some sort of contact information as well, so that we can get in touch if necessary. Examples of excellent `User-Agent` headers: > User-Agent: Example mobile app (example@phrase.com) <br/> User-Agent: ACME Inc Java 1.8 Client (http://acmeinc.com/contact) # noqa: E501
Welcome to Phrase's TMS API documentation. Please visit our [help center](https://support.phrase.com/hc/en-us/sections/5709662083612) for more information about the APIs. If you have any questions, please contact [Support](https://support.phrase.com/hc/requests/new). Please, include the `User-Agent` header with the name of your application or project. It might be a good idea to include some sort of contact information as well, so that we can get in touch if necessary. Examples of excellent `User-Agent` headers: > User-Agent: Example mobile app (example@phrase.com) <br/> User-Agent: ACME Inc Java 1.8 Client (http://acmeinc.com/contact) # noqa: E501

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

Do not edit the class manually.
Do not edit the class manually.
"""


from __future__ import annotations
import pprint
import re # noqa: F401
Expand All @@ -21,48 +20,51 @@
import phrasetms_client.models



from pydantic import BaseModel, Field, ConfigDict, StrictStr, StringConstraints


class AbstractConnectorDto(BaseModel):
"""
AbstractConnectorDto
"""
name: Annotated[str, StringConstraints(strict=True, max_length=255, min_length=0)] = Field(..., description="Name of the connector")

name: Annotated[
str, StringConstraints(strict=True, max_length=255, min_length=0)
] = Field(..., description="Name of the connector")
type: StrictStr = Field(..., description="Connector type")
__properties = ["name", "type"]

model_config = ConfigDict(populate_by_name=True, validate_assignment=True)
# JSON field name that stores the object type
__discriminator_property_name = 'type'
_discriminator_property_name = "type"

# discriminator mappings
__discriminator_value_class_map = {
'AdobeExperienceManager': 'AdobeExperienceManager',
'AmazonS3': 'AmazonS3',
'BitbucketServer': 'BitbucketServer',
'Contentstack': 'Contentstack',
'Ftp': 'Ftp',
'Git': 'Git',
'GitLab': 'GitLab',
'Joomla': 'Joomla',
'Kentico': 'Kentico',
'Magento': 'Magento',
'Marketo': 'Marketo',
'MicrosoftAzure': 'MicrosoftAzure',
'Sftp': 'Sftp',
'Sitecore': 'Sitecore',
'Tridion': 'Tridion',
'Typo3': 'Typo3',
'Wordpress': 'Wordpress'
_discriminator_value_class_map = {
"AdobeExperienceManager": "AdobeExperienceManager",
"AmazonS3": "AmazonS3",
"BitbucketServer": "BitbucketServer",
"Contentstack": "Contentstack",
"Ftp": "Ftp",
"Git": "Git",
"GitLab": "GitLab",
"Joomla": "Joomla",
"Kentico": "Kentico",
"Magento": "Magento",
"Marketo": "Marketo",
"MicrosoftAzure": "MicrosoftAzure",
"Sftp": "Sftp",
"Sitecore": "Sitecore",
"Tridion": "Tridion",
"Typo3": "Typo3",
"Wordpress": "Wordpress",
}

@classmethod
def get_discriminator_value(cls, obj: dict) -> str:
"""Returns the discriminator value (object type) of the data"""
discriminator_value = obj[cls.__discriminator_property_name]
discriminator_value = obj[cls._discriminator_property_name.default]
if discriminator_value:
return cls.__discriminator_value_class_map.get(discriminator_value)
return cls._discriminator_value_class_map.default.get(discriminator_value)
else:
return None

Expand All @@ -75,28 +77,69 @@ def to_json(self) -> str:
return json.dumps(self.to_dict())

@classmethod
def from_json(cls, json_str: str) -> Union(AdobeExperienceManager, AmazonS3, BitbucketServer, Contentstack, Ftp, Git, GitLab, Joomla, Kentico, Magento, Marketo, MicrosoftAzure, Sftp, Sitecore, Tridion, Typo3, Wordpress): # noqa: F821
def from_json(
cls, json_str: str
) -> Union[
"AdobeExperienceManager",
"AmazonS3",
"BitbucketServer",
"Contentstack",
"Ftp",
"Git",
"GitLab",
"Joomla",
"Kentico",
"Magento",
"Marketo",
"MicrosoftAzure",
"Sftp",
"Sitecore",
"Tridion",
"Typo3",
"Wordpress",
]:
"""Create an instance of AbstractConnectorDto from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self):
"""Returns the dictionary representation of the model using alias"""
_dict = self.model_dump(by_alias=True,
exclude={
},
exclude_none=True)
_dict = self.model_dump(by_alias=True, exclude={}, exclude_none=True)
return _dict

@classmethod
def from_dict(cls, obj: dict) -> Union(AdobeExperienceManager, AmazonS3, BitbucketServer, Contentstack, Ftp, Git, GitLab, Joomla, Kentico, Magento, Marketo, MicrosoftAzure, Sftp, Sitecore, Tridion, Typo3, Wordpress): # noqa: F821
def from_dict(
cls, obj: dict
) -> Union[
"AdobeExperienceManager",
"AmazonS3",
"BitbucketServer",
"Contentstack",
"Ftp",
"Git",
"GitLab",
"Joomla",
"Kentico",
"Magento",
"Marketo",
"MicrosoftAzure",
"Sftp",
"Sitecore",
"Tridion",
"Typo3",
"Wordpress",
]:
"""Create an instance of AbstractConnectorDto from a dict"""
# look up the object type based on discriminator mapping
object_type = cls.get_discriminator_value(obj)
if object_type:
klass = getattr(phrasetms_client.models, object_type)
return klass.from_dict(obj)
else:
raise ValueError("AbstractConnectorDto failed to lookup discriminator value from " +
json.dumps(obj) + ". Discriminator property name: " + cls.__discriminator_property_name +
", mapping: " + json.dumps(cls.__discriminator_value_class_map))

raise ValueError(
"AbstractConnectorDto failed to lookup discriminator value from "
+ json.dumps(obj)
+ ". Discriminator property name: "
+ cls._discriminator_property_name.default
+ ", mapping: "
+ json.dumps(cls._discriminator_value_class_map.default)
)
Loading