Skip to content

Commit

Permalink
feat: add support for modular models metadata (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims authored Apr 2, 2024
2 parents 0fcb92c + f9f499d commit ea6aea7
Show file tree
Hide file tree
Showing 14 changed files with 470 additions and 11 deletions.
4 changes: 4 additions & 0 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ docs/CheckRequestTupleKey.md
docs/CheckResponse.md
docs/Computed.md
docs/Condition.md
docs/ConditionMetadata.md
docs/ConditionParamTypeRef.md
docs/ContextualTupleKeys.md
docs/CreateStoreRequest.md
Expand Down Expand Up @@ -58,6 +59,7 @@ docs/ReadResponse.md
docs/RelationMetadata.md
docs/RelationReference.md
docs/RelationshipCondition.md
docs/SourceInfo.md
docs/Status.md
docs/Store.md
docs/Tuple.md
Expand Down Expand Up @@ -123,6 +125,7 @@ openfga_sdk/models/check_request_tuple_key.py
openfga_sdk/models/check_response.py
openfga_sdk/models/computed.py
openfga_sdk/models/condition.py
openfga_sdk/models/condition_metadata.py
openfga_sdk/models/condition_param_type_ref.py
openfga_sdk/models/contextual_tuple_keys.py
openfga_sdk/models/create_store_request.py
Expand Down Expand Up @@ -156,6 +159,7 @@ openfga_sdk/models/read_response.py
openfga_sdk/models/relation_metadata.py
openfga_sdk/models/relation_reference.py
openfga_sdk/models/relationship_condition.py
openfga_sdk/models/source_info.py
openfga_sdk/models/status.py
openfga_sdk/models/store.py
openfga_sdk/models/tuple.py
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,7 @@ Class | Method | HTTP request | Description
- [CheckResponse](https://github.com/openfga/python-sdk/blob/main/docs/CheckResponse.md)
- [Computed](https://github.com/openfga/python-sdk/blob/main/docs/Computed.md)
- [Condition](https://github.com/openfga/python-sdk/blob/main/docs/Condition.md)
- [ConditionMetadata](https://github.com/openfga/python-sdk/blob/main/docs/ConditionMetadata.md)
- [ConditionParamTypeRef](https://github.com/openfga/python-sdk/blob/main/docs/ConditionParamTypeRef.md)
- [ContextualTupleKeys](https://github.com/openfga/python-sdk/blob/main/docs/ContextualTupleKeys.md)
- [CreateStoreRequest](https://github.com/openfga/python-sdk/blob/main/docs/CreateStoreRequest.md)
Expand Down Expand Up @@ -1025,6 +1026,7 @@ Class | Method | HTTP request | Description
- [RelationMetadata](https://github.com/openfga/python-sdk/blob/main/docs/RelationMetadata.md)
- [RelationReference](https://github.com/openfga/python-sdk/blob/main/docs/RelationReference.md)
- [RelationshipCondition](https://github.com/openfga/python-sdk/blob/main/docs/RelationshipCondition.md)
- [SourceInfo](https://github.com/openfga/python-sdk/blob/main/docs/SourceInfo.md)
- [Status](https://github.com/openfga/python-sdk/blob/main/docs/Status.md)
- [Store](https://github.com/openfga/python-sdk/blob/main/docs/Store.md)
- [Tuple](https://github.com/openfga/python-sdk/blob/main/docs/Tuple.md)
Expand Down
1 change: 1 addition & 0 deletions docs/Condition.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Name | Type | Description | Notes
**name** | **str** | |
**expression** | **str** | A Google CEL expression, expressed as a string. |
**parameters** | [**dict[str, ConditionParamTypeRef]**](ConditionParamTypeRef.md) | A map of parameter names to the parameter's defined type reference. | [optional]
**metadata** | [**ConditionMetadata**](ConditionMetadata.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
12 changes: 12 additions & 0 deletions docs/ConditionMetadata.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ConditionMetadata


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**module** | **str** | | [optional]
**source_info** | [**SourceInfo**](SourceInfo.md) | | [optional]

[[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: 2 additions & 0 deletions docs/Metadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**relations** | [**dict[str, RelationMetadata]**](RelationMetadata.md) | | [optional]
**module** | **str** | | [optional]
**source_info** | [**SourceInfo**](SourceInfo.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
2 changes: 2 additions & 0 deletions docs/RelationMetadata.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**directly_related_user_types** | [**list[RelationReference]**](RelationReference.md) | | [optional]
**module** | **str** | | [optional]
**source_info** | [**SourceInfo**](SourceInfo.md) | | [optional]

[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md)

Expand Down
11 changes: 11 additions & 0 deletions docs/SourceInfo.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# SourceInfo


## Properties
Name | Type | Description | Notes
------------ | ------------- | ------------- | -------------
**file** | **str** | | [optional]

[[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: 2 additions & 0 deletions openfga_sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from openfga_sdk.models.check_response import CheckResponse
from openfga_sdk.models.computed import Computed
from openfga_sdk.models.condition import Condition
from openfga_sdk.models.condition_metadata import ConditionMetadata
from openfga_sdk.models.condition_param_type_ref import ConditionParamTypeRef
from openfga_sdk.models.contextual_tuple_keys import ContextualTupleKeys
from openfga_sdk.models.create_store_request import CreateStoreRequest
Expand Down Expand Up @@ -76,6 +77,7 @@
from openfga_sdk.models.relation_metadata import RelationMetadata
from openfga_sdk.models.relation_reference import RelationReference
from openfga_sdk.models.relationship_condition import RelationshipCondition
from openfga_sdk.models.source_info import SourceInfo
from openfga_sdk.models.status import Status
from openfga_sdk.models.store import Store
from openfga_sdk.models.tuple import Tuple
Expand Down
2 changes: 2 additions & 0 deletions openfga_sdk/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from openfga_sdk.models.check_response import CheckResponse
from openfga_sdk.models.computed import Computed
from openfga_sdk.models.condition import Condition
from openfga_sdk.models.condition_metadata import ConditionMetadata
from openfga_sdk.models.condition_param_type_ref import ConditionParamTypeRef
from openfga_sdk.models.contextual_tuple_keys import ContextualTupleKeys
from openfga_sdk.models.create_store_request import CreateStoreRequest
Expand Down Expand Up @@ -61,6 +62,7 @@
from openfga_sdk.models.relation_metadata import RelationMetadata
from openfga_sdk.models.relation_reference import RelationReference
from openfga_sdk.models.relationship_condition import RelationshipCondition
from openfga_sdk.models.source_info import SourceInfo
from openfga_sdk.models.status import Status
from openfga_sdk.models.store import Store
from openfga_sdk.models.tuple import Tuple
Expand Down
33 changes: 32 additions & 1 deletion openfga_sdk/models/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,23 @@ class Condition:
"name": "str",
"expression": "str",
"parameters": "dict[str, ConditionParamTypeRef]",
"metadata": "ConditionMetadata",
}

attribute_map = {
"name": "name",
"expression": "expression",
"parameters": "parameters",
"metadata": "metadata",
}

def __init__(
self, name=None, expression=None, parameters=None, local_vars_configuration=None
self,
name=None,
expression=None,
parameters=None,
metadata=None,
local_vars_configuration=None,
):
"""Condition - a model defined in OpenAPI"""
if local_vars_configuration is None:
Expand All @@ -56,12 +63,15 @@ def __init__(
self._name = None
self._expression = None
self._parameters = None
self._metadata = None
self.discriminator = None

self.name = name
self.expression = expression
if parameters is not None:
self.parameters = parameters
if metadata is not None:
self.metadata = metadata

@property
def name(self):
Expand Down Expand Up @@ -134,6 +144,27 @@ def parameters(self, parameters):

self._parameters = parameters

@property
def metadata(self):
"""Gets the metadata of this Condition.
:return: The metadata of this Condition.
:rtype: ConditionMetadata
"""
return self._metadata

@metadata.setter
def metadata(self, metadata):
"""Sets the metadata of this Condition.
:param metadata: The metadata of this Condition.
:type metadata: ConditionMetadata
"""

self._metadata = metadata

def to_dict(self, serialize=False):
"""Returns the model properties as a dict"""
result = {}
Expand Down
145 changes: 145 additions & 0 deletions openfga_sdk/models/condition_metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
"""
Python SDK for OpenFGA
API version: 0.1
Website: https://openfga.dev
Documentation: https://openfga.dev/docs
Support: https://openfga.dev/community
License: [Apache-2.0](https://github.com/openfga/python-sdk/blob/main/LICENSE)
NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT.
"""

try:
from inspect import getfullargspec
except ImportError:
from inspect import getargspec as getfullargspec
import pprint

from openfga_sdk.configuration import Configuration


class ConditionMetadata:
"""NOTE: This class is auto generated by OpenAPI Generator.
Ref: https://openapi-generator.tech
Do not edit the class manually.
"""

"""
Attributes:
openapi_types (dict): The key is attribute name
and the value is attribute type.
attribute_map (dict): The key is attribute name
and the value is json key in definition.
"""
openapi_types = {"module": "str", "source_info": "SourceInfo"}

attribute_map = {"module": "module", "source_info": "source_info"}

def __init__(self, module=None, source_info=None, local_vars_configuration=None):
"""ConditionMetadata - a model defined in OpenAPI"""
if local_vars_configuration is None:
local_vars_configuration = Configuration.get_default_copy()
self.local_vars_configuration = local_vars_configuration

self._module = None
self._source_info = None
self.discriminator = None

if module is not None:
self.module = module
if source_info is not None:
self.source_info = source_info

@property
def module(self):
"""Gets the module of this ConditionMetadata.
:return: The module of this ConditionMetadata.
:rtype: str
"""
return self._module

@module.setter
def module(self, module):
"""Sets the module of this ConditionMetadata.
:param module: The module of this ConditionMetadata.
:type module: str
"""

self._module = module

@property
def source_info(self):
"""Gets the source_info of this ConditionMetadata.
:return: The source_info of this ConditionMetadata.
:rtype: SourceInfo
"""
return self._source_info

@source_info.setter
def source_info(self, source_info):
"""Sets the source_info of this ConditionMetadata.
:param source_info: The source_info of this ConditionMetadata.
:type source_info: SourceInfo
"""

self._source_info = source_info

def to_dict(self, serialize=False):
"""Returns the model properties as a dict"""
result = {}

def convert(x):
if hasattr(x, "to_dict"):
args = getfullargspec(x.to_dict).args
if len(args) == 1:
return x.to_dict()
else:
return x.to_dict(serialize)
else:
return x

for attr, _ in self.openapi_types.items():
value = getattr(self, attr)
attr = self.attribute_map.get(attr, attr) if serialize else attr
if isinstance(value, list):
result[attr] = list(map(lambda x: convert(x), value))
elif isinstance(value, dict):
result[attr] = dict(
map(lambda item: (item[0], convert(item[1])), value.items())
)
else:
result[attr] = convert(value)

return result

def to_str(self):
"""Returns the string representation of the model"""
return pprint.pformat(self.to_dict())

def __repr__(self):
"""For `print` and `pprint`"""
return self.to_str()

def __eq__(self, other):
"""Returns true if both objects are equal"""
if not isinstance(other, ConditionMetadata):
return False

return self.to_dict() == other.to_dict()

def __ne__(self, other):
"""Returns true if both objects are not equal"""
if not isinstance(other, ConditionMetadata):
return True

return self.to_dict() != other.to_dict()
Loading

0 comments on commit ea6aea7

Please sign in to comment.