Skip to content

Commit

Permalink
Minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
sidpan1 committed May 23, 2024
1 parent 1ea2f4b commit c312a5a
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 9 deletions.
5 changes: 3 additions & 2 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ docs/ResourceCatalogResponse.md
docs/ResourceCatalogServiceApi.md
docs/ResourceHierarchyMappingRequest.md
docs/ResourceMappingServiceApi.md
docs/ResourceTypes.md
docs/ResourceType.md
docs/ResponseActivatePolicyTemplateResponse.md
docs/ResponseAddTenantPolicyExclusionsResponse.md
docs/ResponseCreateDefaultHierarchyResponse.md
Expand Down Expand Up @@ -471,7 +471,7 @@ onelens_backend_client/models/relationship_config_item.py
onelens_backend_client/models/resource_catalog_request.py
onelens_backend_client/models/resource_catalog_response.py
onelens_backend_client/models/resource_hierarchy_mapping_request.py
onelens_backend_client/models/resource_types.py
onelens_backend_client/models/resource_type.py
onelens_backend_client/models/response_activate_policy_template_response.py
onelens_backend_client/models/response_add_tenant_policy_exclusions_response.py
onelens_backend_client/models/response_create_default_hierarchy_response.py
Expand Down Expand Up @@ -585,4 +585,5 @@ setup.cfg
setup.py
test-requirements.txt
test/__init__.py
test/test_resource_type.py
tox.ini
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ Class | Method | Description
- [ResourceCatalogRequest](docs/ResourceCatalogRequest.md)
- [ResourceCatalogResponse](docs/ResourceCatalogResponse.md)
- [ResourceHierarchyMappingRequest](docs/ResourceHierarchyMappingRequest.md)
- [ResourceTypes](docs/ResourceTypes.md)
- [ResourceType](docs/ResourceType.md)
- [ResponseActivatePolicyTemplateResponse](docs/ResponseActivatePolicyTemplateResponse.md)
- [ResponseAddTenantPolicyExclusionsResponse](docs/ResponseAddTenantPolicyExclusionsResponse.md)
- [ResponseCreateDefaultHierarchyResponse](docs/ResponseCreateDefaultHierarchyResponse.md)
Expand Down
33 changes: 33 additions & 0 deletions docs/ResourceType.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# ResourceType


## Properties

Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**resource_type** | **str** | |
**resource_table** | **str** | |
**select_columns** | **List[str]** | |
**resource_url_template** | **str** | |
**relationship_config** | [**List[RelationshipConfigItem]**](RelationshipConfigItem.md) | |

## Example

```python
from onelens_backend_client.models.resource_type import ResourceType

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

# convert the object into a dict
resource_type_dict = resource_type_instance.to_dict()
# create an instance of ResourceType from a dict
resource_type_form_dict = resource_type.from_dict(resource_type_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)


2 changes: 1 addition & 1 deletion docs/ServiceCatalog.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Name | Type | Description | Notes
**product_code** | **str** | |
**display_name** | **str** | |
**description** | **str** | |
**resource_types** | [**List[ResourceTypes]**](ResourceTypes.md) | |
**resource_types** | [**List[ResourceType]**](ResourceType.md) | |
**features** | [**Features**](Features.md) | |

## Example
Expand Down
2 changes: 1 addition & 1 deletion onelens_backend_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
from onelens_backend_client.models.resource_catalog_request import ResourceCatalogRequest
from onelens_backend_client.models.resource_catalog_response import ResourceCatalogResponse
from onelens_backend_client.models.resource_hierarchy_mapping_request import ResourceHierarchyMappingRequest
from onelens_backend_client.models.resource_types import ResourceTypes
from onelens_backend_client.models.resource_type import ResourceType
from onelens_backend_client.models.response_activate_policy_template_response import ResponseActivatePolicyTemplateResponse
from onelens_backend_client.models.response_add_tenant_policy_exclusions_response import ResponseAddTenantPolicyExclusionsResponse
from onelens_backend_client.models.response_create_default_hierarchy_response import ResponseCreateDefaultHierarchyResponse
Expand Down
2 changes: 1 addition & 1 deletion onelens_backend_client/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
from onelens_backend_client.models.resource_catalog_request import ResourceCatalogRequest
from onelens_backend_client.models.resource_catalog_response import ResourceCatalogResponse
from onelens_backend_client.models.resource_hierarchy_mapping_request import ResourceHierarchyMappingRequest
from onelens_backend_client.models.resource_types import ResourceTypes
from onelens_backend_client.models.resource_type import ResourceType
from onelens_backend_client.models.response_activate_policy_template_response import ResponseActivatePolicyTemplateResponse
from onelens_backend_client.models.response_add_tenant_policy_exclusions_response import ResponseAddTenantPolicyExclusionsResponse
from onelens_backend_client.models.response_create_default_hierarchy_response import ResponseCreateDefaultHierarchyResponse
Expand Down
103 changes: 103 additions & 0 deletions onelens_backend_client/models/resource_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# coding: utf-8

"""
onelens-backend
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
The version of the OpenAPI document: 1.0.0
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 pydantic import BaseModel, ConfigDict, StrictStr
from typing import Any, ClassVar, Dict, List
from onelens_backend_client.models.relationship_config_item import RelationshipConfigItem
from typing import Optional, Set
from typing_extensions import Self

class ResourceType(BaseModel):
"""
ResourceType
""" # noqa: E501
resource_type: StrictStr
resource_table: StrictStr
select_columns: List[StrictStr]
resource_url_template: StrictStr
relationship_config: List[RelationshipConfigItem]
__properties: ClassVar[List[str]] = ["resource_type", "resource_table", "select_columns", "resource_url_template", "relationship_config"]

model_config = ConfigDict(
populate_by_name=True,
validate_assignment=True,
protected_namespaces=(),
)


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 ResourceType 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 each item in relationship_config (list)
_items = []
if self.relationship_config:
for _item in self.relationship_config:
if _item:
_items.append(_item.to_dict())
_dict['relationship_config'] = _items
return _dict

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

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

_obj = cls.model_validate({
"resource_type": obj.get("resource_type"),
"resource_table": obj.get("resource_table"),
"select_columns": obj.get("select_columns"),
"resource_url_template": obj.get("resource_url_template"),
"relationship_config": [RelationshipConfigItem.from_dict(_item) for _item in obj["relationship_config"]] if obj.get("relationship_config") is not None else None
})
return _obj


6 changes: 3 additions & 3 deletions onelens_backend_client/models/service_catalog.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from pydantic import BaseModel, ConfigDict, StrictStr
from typing import Any, ClassVar, Dict, List
from onelens_backend_client.models.features import Features
from onelens_backend_client.models.resource_types import ResourceTypes
from onelens_backend_client.models.resource_type import ResourceType
from typing import Optional, Set
from typing_extensions import Self

Expand All @@ -33,7 +33,7 @@ class ServiceCatalog(BaseModel):
product_code: StrictStr
display_name: StrictStr
description: StrictStr
resource_types: List[ResourceTypes]
resource_types: List[ResourceType]
features: Features
__properties: ClassVar[List[str]] = ["id", "name", "product_code", "display_name", "description", "resource_types", "features"]

Expand Down Expand Up @@ -103,7 +103,7 @@ def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
"product_code": obj.get("product_code"),
"display_name": obj.get("display_name"),
"description": obj.get("description"),
"resource_types": [ResourceTypes.from_dict(_item) for _item in obj["resource_types"]] if obj.get("resource_types") is not None else None,
"resource_types": [ResourceType.from_dict(_item) for _item in obj["resource_types"]] if obj.get("resource_types") is not None else None,
"features": Features.from_dict(obj["features"]) if obj.get("features") is not None else None
})
return _obj
Expand Down
78 changes: 78 additions & 0 deletions test/test_resource_type.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# coding: utf-8

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


import unittest

from onelens_backend_client.models.resource_type import ResourceType

class TestResourceType(unittest.TestCase):
"""ResourceType unit test stubs"""

def setUp(self):
pass

def tearDown(self):
pass

def make_instance(self, include_optional) -> ResourceType:
"""Test ResourceType
include_option is a boolean, when False only required
params are included, when True both required and
optional params are included """
# uncomment below to create an instance of `ResourceType`
"""
model = ResourceType()
if include_optional:
return ResourceType(
resource_type = '',
resource_table = '',
select_columns = [
''
],
resource_url_template = '',
relationship_config = [
onelens_backend_client.models.relationship_config_item.RelationshipConfigItem(
relationship_type = '',
join = onelens_backend_client.models.join.Join(
current_table_column = '',
join_table = '',
join_table_column = '', ), )
]
)
else:
return ResourceType(
resource_type = '',
resource_table = '',
select_columns = [
''
],
resource_url_template = '',
relationship_config = [
onelens_backend_client.models.relationship_config_item.RelationshipConfigItem(
relationship_type = '',
join = onelens_backend_client.models.join.Join(
current_table_column = '',
join_table = '',
join_table_column = '', ), )
],
)
"""

def testResourceType(self):
"""Test ResourceType"""
# inst_req_only = self.make_instance(include_optional=False)
# inst_req_and_optional = self.make_instance(include_optional=True)

if __name__ == '__main__':
unittest.main()

0 comments on commit c312a5a

Please sign in to comment.