Skip to content

Commit

Permalink
Added monthly unblended cost to ticket
Browse files Browse the repository at this point in the history
  • Loading branch information
khannakshat7 committed Jun 17, 2024
1 parent d342b02 commit b008bc2
Show file tree
Hide file tree
Showing 20 changed files with 520 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,8 @@ docs/MetricsQuery.md
docs/MetricsServiceApi.md
docs/MetricsThreshold.md
docs/MetricsValueUnit.md
docs/MonthlyUnblendedCost.md
docs/MonthlyUnblendedCost1.md
docs/NewCost.md
docs/OnelensDomainUtilitiesRepositoriesDynamicFiltersFilterCriteria.md
docs/OnelensDomainUtilitiesRepositoriesDynamicFiltersOperator.md
Expand Down Expand Up @@ -626,6 +628,8 @@ onelens_backend_client/models/metrics_look_back_period.py
onelens_backend_client/models/metrics_query.py
onelens_backend_client/models/metrics_threshold.py
onelens_backend_client/models/metrics_value_unit.py
onelens_backend_client/models/monthly_unblended_cost.py
onelens_backend_client/models/monthly_unblended_cost1.py
onelens_backend_client/models/new_cost.py
onelens_backend_client/models/onelens_domain_utilities_repositories_dynamic_filters_filter_criteria.py
onelens_backend_client/models/onelens_domain_utilities_repositories_dynamic_filters_operator.py
Expand Down Expand Up @@ -827,4 +831,6 @@ setup.cfg
setup.py
test-requirements.txt
test/__init__.py
test/test_monthly_unblended_cost.py
test/test_monthly_unblended_cost1.py
tox.ini
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,8 @@ Class | Method | Description
- [MetricsQuery](docs/MetricsQuery.md)
- [MetricsThreshold](docs/MetricsThreshold.md)
- [MetricsValueUnit](docs/MetricsValueUnit.md)
- [MonthlyUnblendedCost](docs/MonthlyUnblendedCost.md)
- [MonthlyUnblendedCost1](docs/MonthlyUnblendedCost1.md)
- [NewCost](docs/NewCost.md)
- [OnelensDomainUtilitiesRepositoriesDynamicFiltersFilterCriteria](docs/OnelensDomainUtilitiesRepositoriesDynamicFiltersFilterCriteria.md)
- [OnelensDomainUtilitiesRepositoriesDynamicFiltersOperator](docs/OnelensDomainUtilitiesRepositoriesDynamicFiltersOperator.md)
Expand Down
1 change: 1 addition & 0 deletions docs/CreateTenantTicketRequestMixin.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Name | Type | Description | Notes
**entity_id** | **str** | The id of the resource experiencing policy violation. |
**entity_type** | **str** | The type of the resource experiencing policy violation. |
**entity_attributes** | **object** | | [optional]
**monthly_unblended_cost** | [**MonthlyUnblendedCost**](MonthlyUnblendedCost.md) | | [optional]
**assignment** | [**TicketAssignment**](TicketAssignment.md) | Assignment state of the ticket |
**assigned_to** | **str** | | [optional]
**last_run_id** | **str** | Id of the last policy violation/anomaly run |
Expand Down
29 changes: 29 additions & 0 deletions docs/MonthlyUnblendedCost.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# MonthlyUnblendedCost

The monthly unblended cost of the resource experiencing policy violation.

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------

## Example

```python
from onelens_backend_client.models.monthly_unblended_cost import MonthlyUnblendedCost

# TODO update the JSON string below
json = "{}"
# create an instance of MonthlyUnblendedCost from a JSON string
monthly_unblended_cost_instance = MonthlyUnblendedCost.from_json(json)
# print the JSON string representation of the object
print(MonthlyUnblendedCost.to_json())

# convert the object into a dict
monthly_unblended_cost_dict = monthly_unblended_cost_instance.to_dict()
# create an instance of MonthlyUnblendedCost from a dict
monthly_unblended_cost_form_dict = monthly_unblended_cost.from_dict(monthly_unblended_cost_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


29 changes: 29 additions & 0 deletions docs/MonthlyUnblendedCost1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# MonthlyUnblendedCost1

Monthly unblended cost of the resource experiencing policy violation

## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------

## Example

```python
from onelens_backend_client.models.monthly_unblended_cost1 import MonthlyUnblendedCost1

# TODO update the JSON string below
json = "{}"
# create an instance of MonthlyUnblendedCost1 from a JSON string
monthly_unblended_cost1_instance = MonthlyUnblendedCost1.from_json(json)
# print the JSON string representation of the object
print(MonthlyUnblendedCost1.to_json())

# convert the object into a dict
monthly_unblended_cost1_dict = monthly_unblended_cost1_instance.to_dict()
# create an instance of MonthlyUnblendedCost1 from a dict
monthly_unblended_cost1_form_dict = monthly_unblended_cost1.from_dict(monthly_unblended_cost1_dict)
```
[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)


1 change: 1 addition & 0 deletions docs/TenantTicket.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Name | Type | Description | Notes
**entity_id** | **str** | The id of the resource experiencing policy violation. |
**entity_type** | **str** | The type of the resource experiencing policy violation. |
**entity_attributes** | **object** | | [optional]
**monthly_unblended_cost** | **str** | | [optional]
**assignment** | [**TicketAssignment**](TicketAssignment.md) | Assignment state of the ticket |
**assigned_to** | **str** | | [optional]
**last_run_id** | **str** | Id of the last policy violation/anomaly run |
Expand Down
1 change: 1 addition & 0 deletions docs/UpdateTenantTicketAPIRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Name | Type | Description | Notes
**assignment** | [**TicketAssignment**](TicketAssignment.md) | | [optional]
**details** | [**Details2**](Details2.md) | | [optional]
**entity_attributes** | **object** | | [optional]
**monthly_unblended_cost** | [**MonthlyUnblendedCost1**](MonthlyUnblendedCost1.md) | | [optional]

## Example

Expand Down
1 change: 1 addition & 0 deletions docs/UpdateTenantTicketRequest.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Name | Type | Description | Notes
**assignment** | [**TicketAssignment**](TicketAssignment.md) | | [optional]
**details** | [**Details2**](Details2.md) | | [optional]
**entity_attributes** | **object** | | [optional]
**monthly_unblended_cost** | [**MonthlyUnblendedCost1**](MonthlyUnblendedCost1.md) | | [optional]
**ticket_id** | **str** | The unique identifier of the ticket |
**tenant_id** | **str** | The unique identifier of the tenant |

Expand Down
1 change: 1 addition & 0 deletions docs/UpdateTenantTicketRequestMixin.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Name | Type | Description | Notes
**status** | [**Status1**](Status1.md) | | [optional]
**details** | [**Details2**](Details2.md) | | [optional]
**entity_attributes** | **object** | | [optional]
**monthly_unblended_cost** | [**MonthlyUnblendedCost1**](MonthlyUnblendedCost1.md) | | [optional]
**cost_impact** | **float** | | [optional]
**last_run_id** | **str** | | [optional]
**last_run_at** | **datetime** | | [optional]
Expand Down
2 changes: 2 additions & 0 deletions onelens_backend_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,8 @@
from onelens_backend_client.models.metrics_query import MetricsQuery
from onelens_backend_client.models.metrics_threshold import MetricsThreshold
from onelens_backend_client.models.metrics_value_unit import MetricsValueUnit
from onelens_backend_client.models.monthly_unblended_cost import MonthlyUnblendedCost
from onelens_backend_client.models.monthly_unblended_cost1 import MonthlyUnblendedCost1
from onelens_backend_client.models.new_cost import NewCost
from onelens_backend_client.models.onelens_domain_utilities_repositories_dynamic_filters_filter_criteria import OnelensDomainUtilitiesRepositoriesDynamicFiltersFilterCriteria
from onelens_backend_client.models.onelens_domain_utilities_repositories_dynamic_filters_operator import OnelensDomainUtilitiesRepositoriesDynamicFiltersOperator
Expand Down
2 changes: 2 additions & 0 deletions onelens_backend_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
from onelens_backend_client.models.metrics_query import MetricsQuery
from onelens_backend_client.models.metrics_threshold import MetricsThreshold
from onelens_backend_client.models.metrics_value_unit import MetricsValueUnit
from onelens_backend_client.models.monthly_unblended_cost import MonthlyUnblendedCost
from onelens_backend_client.models.monthly_unblended_cost1 import MonthlyUnblendedCost1
from onelens_backend_client.models.new_cost import NewCost
from onelens_backend_client.models.onelens_domain_utilities_repositories_dynamic_filters_filter_criteria import OnelensDomainUtilitiesRepositoriesDynamicFiltersFilterCriteria
from onelens_backend_client.models.onelens_domain_utilities_repositories_dynamic_filters_operator import OnelensDomainUtilitiesRepositoriesDynamicFiltersOperator
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from pydantic import BaseModel, ConfigDict, Field, StrictStr
from typing import Any, ClassVar, Dict, List, Optional
from onelens_backend_client.models.details import Details
from onelens_backend_client.models.monthly_unblended_cost import MonthlyUnblendedCost
from onelens_backend_client.models.status import Status
from onelens_backend_client.models.ticket_assignment import TicketAssignment
from onelens_backend_client.models.ticket_category import TicketCategory
Expand All @@ -38,14 +39,15 @@ class CreateTenantTicketRequestMixin(BaseModel):
entity_id: StrictStr = Field(description="The id of the resource experiencing policy violation.")
entity_type: StrictStr = Field(description="The type of the resource experiencing policy violation.")
entity_attributes: Optional[Dict[str, Any]] = None
monthly_unblended_cost: Optional[MonthlyUnblendedCost] = None
assignment: TicketAssignment = Field(description="Assignment state of the ticket")
assigned_to: Optional[StrictStr] = None
last_run_id: StrictStr = Field(description="Id of the last policy violation/anomaly run")
last_run_at: datetime = Field(description="Datetime of the last policy violation/anomaly run")
first_run_at: datetime = Field(description="Datetime of the first policy violation/anomaly run")
status: Status
details: Details
__properties: ClassVar[List[str]] = ["monitor_id", "ticket_category", "state", "entity_id", "entity_type", "entity_attributes", "assignment", "assigned_to", "last_run_id", "last_run_at", "first_run_at", "status", "details"]
__properties: ClassVar[List[str]] = ["monitor_id", "ticket_category", "state", "entity_id", "entity_type", "entity_attributes", "monthly_unblended_cost", "assignment", "assigned_to", "last_run_id", "last_run_at", "first_run_at", "status", "details"]

model_config = ConfigDict(
populate_by_name=True,
Expand Down Expand Up @@ -86,6 +88,9 @@ def to_dict(self) -> Dict[str, Any]:
exclude=excluded_fields,
exclude_none=True,
)
# override the default output from pydantic by calling `to_dict()` of monthly_unblended_cost
if self.monthly_unblended_cost:
_dict['monthly_unblended_cost'] = self.monthly_unblended_cost.to_dict()
# override the default output from pydantic by calling `to_dict()` of status
if self.status:
_dict['status'] = self.status.to_dict()
Expand All @@ -102,6 +107,11 @@ def to_dict(self) -> Dict[str, Any]:
if self.entity_attributes is None and "entity_attributes" in self.model_fields_set:
_dict['entity_attributes'] = None

# set to None if monthly_unblended_cost (nullable) is None
# and model_fields_set contains the field
if self.monthly_unblended_cost is None and "monthly_unblended_cost" in self.model_fields_set:
_dict['monthly_unblended_cost'] = None

# set to None if assigned_to (nullable) is None
# and model_fields_set contains the field
if self.assigned_to is None and "assigned_to" in self.model_fields_set:
Expand All @@ -125,6 +135,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"entity_id": obj.get("entity_id"),
"entity_type": obj.get("entity_type"),
"entity_attributes": obj.get("entity_attributes"),
"monthly_unblended_cost": MonthlyUnblendedCost.from_dict(obj["monthly_unblended_cost"]) if obj.get("monthly_unblended_cost") is not None else None,
"assignment": obj.get("assignment"),
"assigned_to": obj.get("assigned_to"),
"last_run_id": obj.get("last_run_id"),
Expand Down
144 changes: 144 additions & 0 deletions onelens_backend_client/models/monthly_unblended_cost.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
# coding: utf-8

"""
onelens-backend
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 0.1.0
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501


from __future__ import annotations
from inspect import getfullargspec
import json
import pprint
import re # noqa: F401
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr, ValidationError, field_validator
from typing import Optional, Union
from typing import Union, Any, List, Set, TYPE_CHECKING, Optional, Dict
from typing_extensions import Literal, Self
from pydantic import Field

MONTHLYUNBLENDEDCOST_ANY_OF_SCHEMAS = ["float", "str"]

class MonthlyUnblendedCost(BaseModel):
"""
The monthly unblended cost of the resource experiencing policy violation.
"""

# data type: float
anyof_schema_1_validator: Optional[Union[StrictFloat, StrictInt]] = None
# data type: str
anyof_schema_2_validator: Optional[StrictStr] = None
if TYPE_CHECKING:
actual_instance: Optional[Union[float, str]] = None
else:
actual_instance: Any = None
any_of_schemas: Set[str] = { "float", "str" }

model_config = {
"validate_assignment": True,
"protected_namespaces": (),
}

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_anyof(cls, v):
if v is None:
return v

instance = MonthlyUnblendedCost.model_construct()
error_messages = []
# validate data type: float
try:
instance.anyof_schema_1_validator = v
return v
except (ValidationError, ValueError) as e:
error_messages.append(str(e))
# validate data type: str
try:
instance.anyof_schema_2_validator = v
return v
except (ValidationError, ValueError) as e:
error_messages.append(str(e))
if error_messages:
# no match
raise ValueError("No match found when setting the actual_instance in MonthlyUnblendedCost with anyOf schemas: float, str. Details: " + ", ".join(error_messages))
else:
return v

@classmethod
def from_dict(cls, obj: 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()
if json_str is None:
return instance

error_messages = []
# deserialize data into float
try:
# validation
instance.anyof_schema_1_validator = json.loads(json_str)
# assign value to actual_instance
instance.actual_instance = instance.anyof_schema_1_validator
return instance
except (ValidationError, ValueError) as e:
error_messages.append(str(e))
# deserialize data into str
try:
# validation
instance.anyof_schema_2_validator = json.loads(json_str)
# assign value to actual_instance
instance.actual_instance = instance.anyof_schema_2_validator
return instance
except (ValidationError, ValueError) as e:
error_messages.append(str(e))

if error_messages:
# no match
raise ValueError("No match found when deserializing the JSON string into MonthlyUnblendedCost with anyOf schemas: float, str. 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], float, str]]:
"""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:
return self.actual_instance

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


Loading

0 comments on commit b008bc2

Please sign in to comment.