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
395 changes: 291 additions & 104 deletions openapi/schemas/campaign.openapi.json

Large diffs are not rendered by default.

392 changes: 287 additions & 105 deletions openapi/schemas/rapidata.filtered.openapi.json

Large diffs are not rendered by default.

395 changes: 291 additions & 104 deletions openapi/schemas/rapidata.openapi.json

Large diffs are not rendered by default.

15 changes: 9 additions & 6 deletions src/rapidata/api_client/api/campaign_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
from rapidata.api_client.models.create_program_campaign_endpoint_output import CreateProgramCampaignEndpointOutput
from rapidata.api_client.models.get_boost_insights_endpoint_output import GetBoostInsightsEndpointOutput
from rapidata.api_client.models.get_boost_status_endpoint_output import GetBoostStatusEndpointOutput
from rapidata.api_client.models.get_campaign_by_id_endpoint_output import GetCampaignByIdEndpointOutput
from rapidata.api_client.models.get_fast_bid_multiplier_endpoint_output import GetFastBidMultiplierEndpointOutput
from rapidata.api_client.models.i_campaign_details import ICampaignDetails
from rapidata.api_client.models.query_campaigns_endpoint_paged_result_of_output import QueryCampaignsEndpointPagedResultOfOutput
from rapidata.api_client.models.set_fast_bid_multiplier_endpoint_input import SetFastBidMultiplierEndpointInput
from rapidata.api_client.models.set_fast_bid_multiplier_endpoint_output import SetFastBidMultiplierEndpointOutput
Expand Down Expand Up @@ -1670,9 +1670,10 @@ def campaign_campaign_id_get(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> GetCampaignByIdEndpointOutput:
) -> ICampaignDetails:
"""Retrieves the details of a specific campaign.

The response is discriminated by campaign kind: a program campaign includes its stream program, a routed campaign includes its selections.

:param campaign_id: The ID of the campaign. (required)
:type campaign_id: str
Expand Down Expand Up @@ -1707,7 +1708,7 @@ def campaign_campaign_id_get(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "GetCampaignByIdEndpointOutput",
'200': "ICampaignDetails",
'400': "ValidationProblemDetails",
'401': None,
'403': None,
Expand Down Expand Up @@ -1739,9 +1740,10 @@ def campaign_campaign_id_get_with_http_info(
_content_type: Optional[StrictStr] = None,
_headers: Optional[Dict[StrictStr, Any]] = None,
_host_index: Annotated[StrictInt, Field(ge=0, le=0)] = 0,
) -> ApiResponse[GetCampaignByIdEndpointOutput]:
) -> ApiResponse[ICampaignDetails]:
"""Retrieves the details of a specific campaign.

The response is discriminated by campaign kind: a program campaign includes its stream program, a routed campaign includes its selections.

:param campaign_id: The ID of the campaign. (required)
:type campaign_id: str
Expand Down Expand Up @@ -1776,7 +1778,7 @@ def campaign_campaign_id_get_with_http_info(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "GetCampaignByIdEndpointOutput",
'200': "ICampaignDetails",
'400': "ValidationProblemDetails",
'401': None,
'403': None,
Expand Down Expand Up @@ -1811,6 +1813,7 @@ def campaign_campaign_id_get_without_preload_content(
) -> RESTResponseType:
"""Retrieves the details of a specific campaign.

The response is discriminated by campaign kind: a program campaign includes its stream program, a routed campaign includes its selections.

:param campaign_id: The ID of the campaign. (required)
:type campaign_id: str
Expand Down Expand Up @@ -1845,7 +1848,7 @@ def campaign_campaign_id_get_without_preload_content(
)

_response_types_map: Dict[str, Optional[str]] = {
'200': "GetCampaignByIdEndpointOutput",
'200': "ICampaignDetails",
'400': "ValidationProblemDetails",
'401': None,
'403': None,
Expand Down
137 changes: 137 additions & 0 deletions src/rapidata/api_client/models/i_campaign_details.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# coding: utf-8

"""
Rapidata Asset API

The API for the Rapidata Asset service

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

Do not edit the class manually.
""" # noqa: E501

from __future__ import annotations
import json
import pprint
from pydantic import BaseModel, ConfigDict, Field, StrictStr, ValidationError, field_validator
from typing import Any, List, Optional
from rapidata.api_client.models.i_campaign_details_program_campaign_details import ICampaignDetailsProgramCampaignDetails
from rapidata.api_client.models.i_campaign_details_routed_campaign_details import ICampaignDetailsRoutedCampaignDetails
from pydantic import StrictStr, Field
from rapidata.api_client.lazy_model import LazyValidatedModel
from typing import Union, List, Set, Optional, Dict
from typing_extensions import Literal, Self

ICAMPAIGNDETAILS_ONE_OF_SCHEMAS = ["ICampaignDetailsProgramCampaignDetails", "ICampaignDetailsRoutedCampaignDetails"]

class ICampaignDetails(LazyValidatedModel):
"""
A campaign's details, identified by a discriminator. Implementations describe the type-specific configuration: a routed campaign's selections or a program campaign's stream program.
"""
# data type: ICampaignDetailsProgramCampaignDetails
oneof_schema_1_validator: Optional[ICampaignDetailsProgramCampaignDetails] = None
# data type: ICampaignDetailsRoutedCampaignDetails
oneof_schema_2_validator: Optional[ICampaignDetailsRoutedCampaignDetails] = None
actual_instance: Optional[Union[ICampaignDetailsProgramCampaignDetails, ICampaignDetailsRoutedCampaignDetails]] = None
one_of_schemas: Set[str] = { "ICampaignDetailsProgramCampaignDetails", "ICampaignDetailsRoutedCampaignDetails" }

# model_config is inherited from LazyValidatedModel


discriminator_value_class_map: Dict[str, str] = {
}

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

@field_validator('actual_instance')
def actual_instance_must_validate_oneof(cls, v):
instance = ICampaignDetails.model_construct()
error_messages = []
match = 0
# validate data type: ICampaignDetailsProgramCampaignDetails
if not isinstance(v, ICampaignDetailsProgramCampaignDetails):
error_messages.append(f"Error! Input type `{type(v)}` is not `ICampaignDetailsProgramCampaignDetails`")
else:
match += 1
# validate data type: ICampaignDetailsRoutedCampaignDetails
if not isinstance(v, ICampaignDetailsRoutedCampaignDetails):
error_messages.append(f"Error! Input type `{type(v)}` is not `ICampaignDetailsRoutedCampaignDetails`")
else:
match += 1
if match > 1:
# more than 1 match
raise ValueError("Multiple matches found when setting `actual_instance` in ICampaignDetails with oneOf schemas: ICampaignDetailsProgramCampaignDetails, ICampaignDetailsRoutedCampaignDetails. Details: " + ", ".join(error_messages))
elif match == 0:
# no match
raise ValueError("No match found when setting `actual_instance` in ICampaignDetails with oneOf schemas: ICampaignDetailsProgramCampaignDetails, ICampaignDetailsRoutedCampaignDetails. Details: " + ", ".join(error_messages))
else:
return v

@classmethod
def from_dict(cls, obj: Union[str, Dict[str, Any]]) -> Self:
return cls.from_json(json.dumps(obj))

@classmethod
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 ICampaignDetailsProgramCampaignDetails
try:
instance.actual_instance = ICampaignDetailsProgramCampaignDetails.from_json(json_str)
match += 1
except (ValidationError, ValueError) as e:
error_messages.append(str(e))
# deserialize data into ICampaignDetailsRoutedCampaignDetails
try:
instance.actual_instance = ICampaignDetailsRoutedCampaignDetails.from_json(json_str)
match += 1
except (ValidationError, ValueError) as e:
error_messages.append(str(e))

if match > 1:
# more than 1 match
raise ValueError("Multiple matches found when deserializing the JSON string into ICampaignDetails with oneOf schemas: ICampaignDetailsProgramCampaignDetails, ICampaignDetailsRoutedCampaignDetails. Details: " + ", ".join(error_messages))
elif match == 0:
# no match
raise ValueError("No match found when deserializing the JSON string into ICampaignDetails with oneOf schemas: ICampaignDetailsProgramCampaignDetails, ICampaignDetailsRoutedCampaignDetails. Details: " + ", ".join(error_messages))
else:
return instance

def to_json(self) -> str:
"""Returns the JSON representation of the actual instance"""
if self.actual_instance is None:
return "null"

if hasattr(self.actual_instance, "to_json") and callable(self.actual_instance.to_json):
return self.actual_instance.to_json()
else:
return json.dumps(self.actual_instance)

def to_dict(self) -> Optional[Union[Dict[str, Any], ICampaignDetailsProgramCampaignDetails, ICampaignDetailsRoutedCampaignDetails]]:
"""Returns the dict representation of the actual instance"""
if self.actual_instance is None:
return None

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:
"""Returns the string representation of the actual instance"""
return pprint.pformat(self.model_dump())


Original file line number Diff line number Diff line change
@@ -0,0 +1,178 @@
# coding: utf-8

"""
Rapidata Asset API

The API for the Rapidata Asset service

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

Do not edit the class manually.
""" # noqa: E501

from __future__ import annotations
import pprint
import re # noqa: F401
import json

from datetime import datetime
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, ClassVar, Dict, List, Optional
from rapidata.api_client.models.boosting_control_mode import BoostingControlMode
from rapidata.api_client.models.boosting_profile import BoostingProfile
from rapidata.api_client.models.campaign_status import CampaignStatus
from rapidata.api_client.models.feature_flag import FeatureFlag
from rapidata.api_client.models.i_campaign_filter import ICampaignFilter
from rapidata.api_client.models.i_program_node import IProgramNode
from rapidata.api_client.models.sticky_config import StickyConfig
from pydantic import ValidationError
from rapidata.api_client.lazy_model import LazyValidatedModel
from typing import Optional, Set
from typing_extensions import Self

class ICampaignDetailsProgramCampaignDetails(LazyValidatedModel):
"""
A program campaign: its sessions stream their rapids, driven by a stream program.
""" # noqa: E501
t: StrictStr = Field(alias="_t")
id: StrictStr = Field(description="The unique identifier of the campaign.")
name: StrictStr = Field(description="The name of the campaign.")
status: CampaignStatus = Field(description="The current status of the campaign.")
priority: StrictInt = Field(description="The priority level of the campaign.")
boosting_profile: BoostingProfile = Field(description="The boosting profile configuration.", alias="boostingProfile")
boosting_control_mode: BoostingControlMode = Field(description="The boosting control mode.", alias="boostingControlMode")
has_booster: StrictBool = Field(description="Whether the campaign has a booster.", alias="hasBooster")
boost_level: StrictInt = Field(description="The campaign's effective boost level (0-10). 0 when no boost is active. Lets clients render and edit the level without unpacking the boosting profile.", alias="boostLevel")
sticky_config: StickyConfig = Field(description="The sticky behavior configuration.", alias="stickyConfig")
filters: List[ICampaignFilter]
feature_flags: List[FeatureFlag] = Field(alias="featureFlags")
owner_mail: StrictStr = Field(description="The email of the campaign owner.", alias="ownerMail")
organization_id: Optional[StrictStr] = Field(default=None, description="The id of the organization that owns the campaign.", alias="organizationId")
created_at: datetime = Field(description="The timestamp when the campaign was created.", alias="createdAt")
version: StrictInt = Field(description="The program's current version, for optimistic concurrency on save.")
root_node_id: StrictStr = Field(description="The node the program's evaluation enters at.", alias="rootNodeId")
nodes: Dict[str, IProgramNode] = Field(description="The program's decision graph, keyed by node id.")
max_rapids: StrictInt = Field(description="The session ends after this many counted responses.", alias="maxRapids")
max_duration_seconds: StrictInt = Field(description="The session ends after this many seconds.", alias="maxDurationSeconds")
__properties: ClassVar[List[str]] = ["_t", "id", "name", "status", "priority", "boostingProfile", "boostingControlMode", "hasBooster", "boostLevel", "stickyConfig", "filters", "featureFlags", "ownerMail", "organizationId", "createdAt", "version", "rootNodeId", "nodes", "maxRapids", "maxDurationSeconds"]

@field_validator('t')
def t_validate_enum(cls, value):
"""Validates the enum"""
if value not in set(['ProgramCampaign']):
raise ValueError("must be one of enum values ('ProgramCampaign')")
return value

# model_config is inherited from LazyValidatedModel


def to_str(self) -> str:
"""Returns the string representation of the model using alias"""
return pprint.pformat(self.model_dump(by_alias=True))

def to_json(self) -> str:
"""Returns the JSON representation of the model using alias"""
# TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
return json.dumps(self.to_dict())

@classmethod
def from_json(cls, json_str: str) -> Optional[Self]:
"""Create an instance of ICampaignDetailsProgramCampaignDetails from a JSON string"""
return cls.from_dict(json.loads(json_str))

def to_dict(self) -> Dict[str, Any]:
"""Return the dictionary representation of the model using alias.

This has the following differences from calling pydantic's
`self.model_dump(by_alias=True)`:

* `None` is only added to the output dict for nullable fields that
were set at model initialization. Other fields with value `None`
are ignored.
"""
excluded_fields: Set[str] = set([
])

_dict = self.model_dump(
by_alias=True,
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of boosting_profile
if self.boosting_profile:
_dict['boostingProfile'] = self.boosting_profile.to_dict()
# override the default output from pydantic by calling `to_dict()` of sticky_config
if self.sticky_config:
_dict['stickyConfig'] = self.sticky_config.to_dict()
# override the default output from pydantic by calling `to_dict()` of each item in filters (list)
_items = []
if self.filters:
for _item_filters in self.filters:
if _item_filters:
_items.append(_item_filters.to_dict())
_dict['filters'] = _items
# override the default output from pydantic by calling `to_dict()` of each item in feature_flags (list)
_items = []
if self.feature_flags:
for _item_feature_flags in self.feature_flags:
if _item_feature_flags:
_items.append(_item_feature_flags.to_dict())
_dict['featureFlags'] = _items
# override the default output from pydantic by calling `to_dict()` of each value in nodes (dict)
_field_dict = {}
if self.nodes:
for _key_nodes in self.nodes:
if self.nodes[_key_nodes]:
_field_dict[_key_nodes] = self.nodes[_key_nodes].to_dict()
_dict['nodes'] = _field_dict
# set to None if organization_id (nullable) is None
# and model_fields_set contains the field
if self.organization_id is None and "organization_id" in self.model_fields_set:
_dict['organizationId'] = None

return _dict

@classmethod
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"""Create an instance of ICampaignDetailsProgramCampaignDetails from a dict"""
if obj is None:
return None

if not isinstance(obj, dict):
return cls.model_validate(obj)

_data = {
"_t": obj.get("_t"),
"id": obj.get("id"),
"name": obj.get("name"),
"status": obj.get("status"),
"priority": obj.get("priority"),
"boostingProfile": BoostingProfile.from_dict(obj["boostingProfile"]) if obj.get("boostingProfile") is not None else None,
"boostingControlMode": obj.get("boostingControlMode"),
"hasBooster": obj.get("hasBooster"),
"boostLevel": obj.get("boostLevel"),
"stickyConfig": StickyConfig.from_dict(obj["stickyConfig"]) if obj.get("stickyConfig") is not None else None,
"filters": [ICampaignFilter.from_dict(_item) for _item in obj["filters"]] if obj.get("filters") is not None else None,
"featureFlags": [FeatureFlag.from_dict(_item) for _item in obj["featureFlags"]] if obj.get("featureFlags") is not None else None,
"ownerMail": obj.get("ownerMail"),
"organizationId": obj.get("organizationId"),
"createdAt": obj.get("createdAt"),
"version": obj.get("version"),
"rootNodeId": obj.get("rootNodeId"),
"nodes": dict(
(_k, IProgramNode.from_dict(_v))
for _k, _v in obj["nodes"].items()
)
if obj.get("nodes") is not None
else None,
"maxRapids": obj.get("maxRapids"),
"maxDurationSeconds": obj.get("maxDurationSeconds")
}
try:
_obj = cls.model_validate(_data)
except ValidationError as _val_error:
_obj = cls._lazy_construct(_data, _val_error)
return _obj


Loading
Loading