-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathwrite_request_writes.py
More file actions
164 lines (127 loc) · 5.23 KB
/
write_request_writes.py
File metadata and controls
164 lines (127 loc) · 5.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
"""
Python SDK for OpenFGA
API version: 1.x
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.
"""
import pprint
from inspect import getfullargspec
from openfga_sdk.configuration import Configuration
class WriteRequestWrites:
"""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: dict[str, str] = {
"tuple_keys": "list[TupleKey]",
"on_duplicate": "str",
}
attribute_map: dict[str, str] = {
"tuple_keys": "tuple_keys",
"on_duplicate": "on_duplicate",
}
def __init__(
self, tuple_keys=None, on_duplicate="error", local_vars_configuration=None
):
"""WriteRequestWrites - 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._tuple_keys = None
self._on_duplicate = None
self.discriminator = None
self.tuple_keys = tuple_keys
if on_duplicate is not None:
self.on_duplicate = on_duplicate
@property
def tuple_keys(self):
"""Gets the tuple_keys of this WriteRequestWrites.
:return: The tuple_keys of this WriteRequestWrites.
:rtype: list[TupleKey]
"""
return self._tuple_keys
@tuple_keys.setter
def tuple_keys(self, tuple_keys):
"""Sets the tuple_keys of this WriteRequestWrites.
:param tuple_keys: The tuple_keys of this WriteRequestWrites.
:type tuple_keys: list[TupleKey]
"""
if self.local_vars_configuration.client_side_validation and tuple_keys is None:
raise ValueError("Invalid value for `tuple_keys`, must not be `None`")
self._tuple_keys = tuple_keys
@property
def on_duplicate(self):
"""Gets the on_duplicate of this WriteRequestWrites.
On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition).
:return: The on_duplicate of this WriteRequestWrites.
:rtype: str
"""
return self._on_duplicate
@on_duplicate.setter
def on_duplicate(self, on_duplicate):
"""Sets the on_duplicate of this WriteRequestWrites.
On 'error' ( or unspecified ), the API returns an error if an identical tuple already exists. On 'ignore', identical writes are treated as no-ops (matching on user, relation, object, and RelationshipCondition).
:param on_duplicate: The on_duplicate of this WriteRequestWrites.
:type on_duplicate: str
"""
allowed_values = ["error", "ignore"]
if (
self.local_vars_configuration.client_side_validation
and on_duplicate not in allowed_values
):
raise ValueError(
"Invalid value for `on_duplicate` ({0}), must be one of {1}".format(
on_duplicate, allowed_values
)
)
self._on_duplicate = on_duplicate
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, WriteRequestWrites):
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, WriteRequestWrites):
return True
return self.to_dict() != other.to_dict()