diff --git a/sailpoint/v2024/models/campaign.py b/sailpoint/v2024/models/campaign.py index a38f8d57..6f45faaf 100644 --- a/sailpoint/v2024/models/campaign.py +++ b/sailpoint/v2024/models/campaign.py @@ -36,7 +36,7 @@ class Campaign(BaseModel): """ # noqa: E501 id: Optional[StrictStr] = Field(default=None, description="Id of the campaign") name: StrictStr = Field(description="The campaign name. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") - description: StrictStr = Field(description="The campaign description. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") + description: Optional[StrictStr] = Field(description="The campaign description. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") deadline: Optional[datetime] = Field(default=None, description="The campaign's completion deadline. This date must be in the future in order to activate the campaign. If you try to activate a campaign with a deadline of today or in the past, you will receive a 400 error response.") type: StrictStr = Field(description="The type of campaign. Could be extended in the future.") email_notification_enabled: Optional[StrictBool] = Field(default=False, description="Enables email notification for this campaign", alias="emailNotificationEnabled") @@ -180,6 +180,11 @@ def to_dict(self) -> Dict[str, Any]: if _item_sources_with_orphan_entitlements: _items.append(_item_sources_with_orphan_entitlements.to_dict()) _dict['sourcesWithOrphanEntitlements'] = _items + # set to None if description (nullable) is None + # and model_fields_set contains the field + if self.description is None and "description" in self.model_fields_set: + _dict['description'] = None + return _dict @classmethod diff --git a/sailpoint/v2024/models/get_active_campaigns200_response_inner.py b/sailpoint/v2024/models/get_active_campaigns200_response_inner.py index 1c1e7395..6b6379d9 100644 --- a/sailpoint/v2024/models/get_active_campaigns200_response_inner.py +++ b/sailpoint/v2024/models/get_active_campaigns200_response_inner.py @@ -13,34 +13,39 @@ from __future__ import annotations +from inspect import getfullargspec import json import pprint +import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator -from typing import Any, List, Optional +from typing import Optional from sailpoint.v2024.models.campaign import Campaign from sailpoint.v2024.models.slim_campaign import SlimCampaign -from pydantic import StrictStr, Field -from typing import Union, List, Set, Optional, Dict +from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self +from pydantic import Field -GETACTIVECAMPAIGNS200RESPONSEINNER_ONE_OF_SCHEMAS = ["Campaign", "SlimCampaign"] +GETACTIVECAMPAIGNS200RESPONSEINNER_ANY_OF_SCHEMAS = ["Campaign", "SlimCampaign"] class GetActiveCampaigns200ResponseInner(BaseModel): """ GetActiveCampaigns200ResponseInner """ + # data type: SlimCampaign - oneof_schema_1_validator: Optional[SlimCampaign] = None + anyof_schema_1_validator: Optional[SlimCampaign] = None # data type: Campaign - oneof_schema_2_validator: Optional[Campaign] = None - actual_instance: Optional[Union[Campaign, SlimCampaign]] = None - one_of_schemas: Set[str] = { "Campaign", "SlimCampaign" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), - ) - + anyof_schema_2_validator: Optional[Campaign] = None + if TYPE_CHECKING: + actual_instance: Optional[Union[Campaign, SlimCampaign]] = None + else: + actual_instance: Any = None + any_of_schemas: Set[str] = { "Campaign", "SlimCampaign" } + + model_config = { + "validate_assignment": True, + "protected_namespaces": (), + } def __init__(self, *args, **kwargs) -> None: if args: @@ -53,31 +58,29 @@ def __init__(self, *args, **kwargs) -> None: super().__init__(**kwargs) @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): + def actual_instance_must_validate_anyof(cls, v): instance = GetActiveCampaigns200ResponseInner.model_construct() error_messages = [] - match = 0 # validate data type: SlimCampaign if not isinstance(v, SlimCampaign): error_messages.append(f"Error! Input type `{type(v)}` is not `SlimCampaign`") else: - match += 1 + return v + # validate data type: Campaign if not isinstance(v, Campaign): error_messages.append(f"Error! Input type `{type(v)}` is not `Campaign`") else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in GetActiveCampaigns200ResponseInner with oneOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) - elif match == 0: + return v + + if error_messages: # no match - raise ValueError("No match found when setting `actual_instance` in GetActiveCampaigns200ResponseInner with oneOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when setting the actual_instance in GetActiveCampaigns200ResponseInner with anyOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) else: return v @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + def from_dict(cls, obj: Dict[str, Any]) -> Self: return cls.from_json(json.dumps(obj)) @classmethod @@ -85,27 +88,22 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" instance = cls.model_construct() error_messages = [] - match = 0 - - # deserialize data into SlimCampaign + # anyof_schema_1_validator: Optional[SlimCampaign] = None try: instance.actual_instance = SlimCampaign.from_json(json_str) - match += 1 + return instance except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Campaign + error_messages.append(str(e)) + # anyof_schema_2_validator: Optional[Campaign] = None try: instance.actual_instance = Campaign.from_json(json_str) - match += 1 + return instance except (ValidationError, ValueError) as e: - error_messages.append(str(e)) + error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into GetActiveCampaigns200ResponseInner with oneOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) - elif match == 0: + if error_messages: # no match - raise ValueError("No match found when deserializing the JSON string into GetActiveCampaigns200ResponseInner with oneOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when deserializing the JSON string into GetActiveCampaigns200ResponseInner with anyOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) else: return instance @@ -127,7 +125,6 @@ def to_dict(self) -> Optional[Union[Dict[str, Any], Campaign, SlimCampaign]]: if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: - # primitive type return self.actual_instance def to_str(self) -> str: diff --git a/sailpoint/v2024/models/slim_campaign.py b/sailpoint/v2024/models/slim_campaign.py index 40566030..746b2610 100644 --- a/sailpoint/v2024/models/slim_campaign.py +++ b/sailpoint/v2024/models/slim_campaign.py @@ -30,7 +30,7 @@ class SlimCampaign(BaseModel): """ # noqa: E501 id: Optional[StrictStr] = Field(default=None, description="Id of the campaign") name: StrictStr = Field(description="The campaign name. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") - description: StrictStr = Field(description="The campaign description. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") + description: Optional[StrictStr] = Field(description="The campaign description. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") deadline: Optional[datetime] = Field(default=None, description="The campaign's completion deadline. This date must be in the future in order to activate the campaign. If you try to activate a campaign with a deadline of today or in the past, you will receive a 400 error response.") type: StrictStr = Field(description="The type of campaign. Could be extended in the future.") email_notification_enabled: Optional[StrictBool] = Field(default=False, description="Enables email notification for this campaign", alias="emailNotificationEnabled") @@ -129,6 +129,11 @@ def to_dict(self) -> Dict[str, Any]: if _item_alerts: _items.append(_item_alerts.to_dict()) _dict['alerts'] = _items + # set to None if description (nullable) is None + # and model_fields_set contains the field + if self.description is None and "description" in self.model_fields_set: + _dict['description'] = None + return _dict @classmethod diff --git a/sailpoint/v3/models/campaign.py b/sailpoint/v3/models/campaign.py index 3ce3ddc2..e8da76d0 100644 --- a/sailpoint/v3/models/campaign.py +++ b/sailpoint/v3/models/campaign.py @@ -36,7 +36,7 @@ class Campaign(BaseModel): """ # noqa: E501 id: Optional[StrictStr] = Field(default=None, description="Id of the campaign") name: StrictStr = Field(description="The campaign name. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") - description: StrictStr = Field(description="The campaign description. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") + description: Optional[StrictStr] = Field(description="The campaign description. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") deadline: Optional[datetime] = Field(default=None, description="The campaign's completion deadline. This date must be in the future in order to activate the campaign. If you try to activate a campaign with a deadline of today or in the past, you will receive a 400 error response.") type: StrictStr = Field(description="The type of campaign. Could be extended in the future.") email_notification_enabled: Optional[StrictBool] = Field(default=False, description="Enables email notification for this campaign", alias="emailNotificationEnabled") @@ -180,6 +180,11 @@ def to_dict(self) -> Dict[str, Any]: if _item_sources_with_orphan_entitlements: _items.append(_item_sources_with_orphan_entitlements.to_dict()) _dict['sourcesWithOrphanEntitlements'] = _items + # set to None if description (nullable) is None + # and model_fields_set contains the field + if self.description is None and "description" in self.model_fields_set: + _dict['description'] = None + return _dict @classmethod diff --git a/sailpoint/v3/models/get_active_campaigns200_response_inner.py b/sailpoint/v3/models/get_active_campaigns200_response_inner.py index 00a2c240..7d9e384a 100644 --- a/sailpoint/v3/models/get_active_campaigns200_response_inner.py +++ b/sailpoint/v3/models/get_active_campaigns200_response_inner.py @@ -13,34 +13,39 @@ from __future__ import annotations +from inspect import getfullargspec import json import pprint +import re # noqa: F401 from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator -from typing import Any, List, Optional +from typing import Optional from sailpoint.v3.models.campaign import Campaign from sailpoint.v3.models.slim_campaign import SlimCampaign -from pydantic import StrictStr, Field -from typing import Union, List, Set, Optional, Dict +from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict from typing_extensions import Literal, Self +from pydantic import Field -GETACTIVECAMPAIGNS200RESPONSEINNER_ONE_OF_SCHEMAS = ["Campaign", "SlimCampaign"] +GETACTIVECAMPAIGNS200RESPONSEINNER_ANY_OF_SCHEMAS = ["Campaign", "SlimCampaign"] class GetActiveCampaigns200ResponseInner(BaseModel): """ GetActiveCampaigns200ResponseInner """ + # data type: SlimCampaign - oneof_schema_1_validator: Optional[SlimCampaign] = None + anyof_schema_1_validator: Optional[SlimCampaign] = None # data type: Campaign - oneof_schema_2_validator: Optional[Campaign] = None - actual_instance: Optional[Union[Campaign, SlimCampaign]] = None - one_of_schemas: Set[str] = { "Campaign", "SlimCampaign" } - - model_config = ConfigDict( - validate_assignment=True, - protected_namespaces=(), - ) - + anyof_schema_2_validator: Optional[Campaign] = None + if TYPE_CHECKING: + actual_instance: Optional[Union[Campaign, SlimCampaign]] = None + else: + actual_instance: Any = None + any_of_schemas: Set[str] = { "Campaign", "SlimCampaign" } + + model_config = { + "validate_assignment": True, + "protected_namespaces": (), + } def __init__(self, *args, **kwargs) -> None: if args: @@ -53,31 +58,29 @@ def __init__(self, *args, **kwargs) -> None: super().__init__(**kwargs) @field_validator('actual_instance') - def actual_instance_must_validate_oneof(cls, v): + def actual_instance_must_validate_anyof(cls, v): instance = GetActiveCampaigns200ResponseInner.model_construct() error_messages = [] - match = 0 # validate data type: SlimCampaign if not isinstance(v, SlimCampaign): error_messages.append(f"Error! Input type `{type(v)}` is not `SlimCampaign`") else: - match += 1 + return v + # validate data type: Campaign if not isinstance(v, Campaign): error_messages.append(f"Error! Input type `{type(v)}` is not `Campaign`") else: - match += 1 - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when setting `actual_instance` in GetActiveCampaigns200ResponseInner with oneOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) - elif match == 0: + return v + + if error_messages: # no match - raise ValueError("No match found when setting `actual_instance` in GetActiveCampaigns200ResponseInner with oneOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when setting the actual_instance in GetActiveCampaigns200ResponseInner with anyOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) else: return v @classmethod - def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self: + def from_dict(cls, obj: Dict[str, Any]) -> Self: return cls.from_json(json.dumps(obj)) @classmethod @@ -85,27 +88,22 @@ def from_json(cls, json_str: str) -> Self: """Returns the object represented by the json string""" instance = cls.model_construct() error_messages = [] - match = 0 - - # deserialize data into SlimCampaign + # anyof_schema_1_validator: Optional[SlimCampaign] = None try: instance.actual_instance = SlimCampaign.from_json(json_str) - match += 1 + return instance except (ValidationError, ValueError) as e: - error_messages.append(str(e)) - # deserialize data into Campaign + error_messages.append(str(e)) + # anyof_schema_2_validator: Optional[Campaign] = None try: instance.actual_instance = Campaign.from_json(json_str) - match += 1 + return instance except (ValidationError, ValueError) as e: - error_messages.append(str(e)) + error_messages.append(str(e)) - if match > 1: - # more than 1 match - raise ValueError("Multiple matches found when deserializing the JSON string into GetActiveCampaigns200ResponseInner with oneOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) - elif match == 0: + if error_messages: # no match - raise ValueError("No match found when deserializing the JSON string into GetActiveCampaigns200ResponseInner with oneOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) + raise ValueError("No match found when deserializing the JSON string into GetActiveCampaigns200ResponseInner with anyOf schemas: Campaign, SlimCampaign. Details: " + ", ".join(error_messages)) else: return instance @@ -127,7 +125,6 @@ def to_dict(self) -> Optional[Union[Dict[str, Any], Campaign, SlimCampaign]]: if hasattr(self.actual_instance, "to_dict") and callable(self.actual_instance.to_dict): return self.actual_instance.to_dict() else: - # primitive type return self.actual_instance def to_str(self) -> str: diff --git a/sailpoint/v3/models/slim_campaign.py b/sailpoint/v3/models/slim_campaign.py index 1929e965..9f6f2cb0 100644 --- a/sailpoint/v3/models/slim_campaign.py +++ b/sailpoint/v3/models/slim_campaign.py @@ -30,7 +30,7 @@ class SlimCampaign(BaseModel): """ # noqa: E501 id: Optional[StrictStr] = Field(default=None, description="Id of the campaign") name: StrictStr = Field(description="The campaign name. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") - description: StrictStr = Field(description="The campaign description. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") + description: Optional[StrictStr] = Field(description="The campaign description. If this object is part of a template, special formatting applies; see the `/campaign-templates/{id}/generate` endpoint documentation for details.") deadline: Optional[datetime] = Field(default=None, description="The campaign's completion deadline. This date must be in the future in order to activate the campaign. If you try to activate a campaign with a deadline of today or in the past, you will receive a 400 error response.") type: StrictStr = Field(description="The type of campaign. Could be extended in the future.") email_notification_enabled: Optional[StrictBool] = Field(default=False, description="Enables email notification for this campaign", alias="emailNotificationEnabled") @@ -129,6 +129,11 @@ def to_dict(self) -> Dict[str, Any]: if _item_alerts: _items.append(_item_alerts.to_dict()) _dict['alerts'] = _items + # set to None if description (nullable) is None + # and model_fields_set contains the field + if self.description is None and "description" in self.model_fields_set: + _dict['description'] = None + return _dict @classmethod