diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 01685399..976edbae 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -13,18 +13,24 @@ LICENSE NOTICE.txt README.md VERSION.txt +docs/AbortedMessageResponse.md docs/Any.md docs/Assertion.md +docs/AssertionTupleKey.md docs/AuthorizationModel.md docs/CheckRequest.md +docs/CheckRequestTupleKey.md docs/CheckResponse.md docs/Computed.md +docs/Condition.md +docs/ConditionParamTypeRef.md docs/ContextualTupleKeys.md docs/CreateStoreRequest.md docs/CreateStoreResponse.md docs/Difference.md docs/ErrorCode.md docs/ExpandRequest.md +docs/ExpandRequestTupleKey.md docs/ExpandResponse.md docs/GetStoreResponse.md docs/InternalErrorCode.md @@ -37,6 +43,7 @@ docs/Metadata.md docs/Node.md docs/Nodes.md docs/NotFoundErrorCode.md +docs/NullValue.md docs/ObjectRelation.md docs/OpenFgaApi.md docs/PathUnknownErrorMessageResponse.md @@ -45,18 +52,21 @@ docs/ReadAuthorizationModelResponse.md docs/ReadAuthorizationModelsResponse.md docs/ReadChangesResponse.md docs/ReadRequest.md +docs/ReadRequestTupleKey.md docs/ReadResponse.md docs/RelationMetadata.md docs/RelationReference.md +docs/RelationshipCondition.md docs/Status.md docs/Store.md docs/Tuple.md docs/TupleChange.md docs/TupleKey.md -docs/TupleKeys.md +docs/TupleKeyWithoutCondition.md docs/TupleOperation.md docs/TupleToUserset.md docs/TypeDefinition.md +docs/TypeName.md docs/Users.md docs/Userset.md docs/UsersetTree.md @@ -68,6 +78,8 @@ docs/WriteAssertionsRequest.md docs/WriteAuthorizationModelRequest.md docs/WriteAuthorizationModelResponse.md docs/WriteRequest.md +docs/WriteRequestDeletes.md +docs/WriteRequestWrites.md example/Makefile example/README.md example/example1/auth-model.json @@ -101,18 +113,24 @@ openfga_sdk/credentials.py openfga_sdk/exceptions.py openfga_sdk/help.py openfga_sdk/models/__init__.py +openfga_sdk/models/aborted_message_response.py openfga_sdk/models/any.py openfga_sdk/models/assertion.py +openfga_sdk/models/assertion_tuple_key.py openfga_sdk/models/authorization_model.py openfga_sdk/models/check_request.py +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_param_type_ref.py openfga_sdk/models/contextual_tuple_keys.py openfga_sdk/models/create_store_request.py openfga_sdk/models/create_store_response.py openfga_sdk/models/difference.py openfga_sdk/models/error_code.py openfga_sdk/models/expand_request.py +openfga_sdk/models/expand_request_tuple_key.py openfga_sdk/models/expand_response.py openfga_sdk/models/get_store_response.py openfga_sdk/models/internal_error_code.py @@ -125,6 +143,7 @@ openfga_sdk/models/metadata.py openfga_sdk/models/node.py openfga_sdk/models/nodes.py openfga_sdk/models/not_found_error_code.py +openfga_sdk/models/null_value.py openfga_sdk/models/object_relation.py openfga_sdk/models/path_unknown_error_message_response.py openfga_sdk/models/read_assertions_response.py @@ -132,18 +151,21 @@ openfga_sdk/models/read_authorization_model_response.py openfga_sdk/models/read_authorization_models_response.py openfga_sdk/models/read_changes_response.py openfga_sdk/models/read_request.py +openfga_sdk/models/read_request_tuple_key.py 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/status.py openfga_sdk/models/store.py openfga_sdk/models/tuple.py openfga_sdk/models/tuple_change.py openfga_sdk/models/tuple_key.py -openfga_sdk/models/tuple_keys.py +openfga_sdk/models/tuple_key_without_condition.py openfga_sdk/models/tuple_operation.py openfga_sdk/models/tuple_to_userset.py openfga_sdk/models/type_definition.py +openfga_sdk/models/type_name.py openfga_sdk/models/users.py openfga_sdk/models/userset.py openfga_sdk/models/userset_tree.py @@ -155,6 +177,8 @@ openfga_sdk/models/write_assertions_request.py openfga_sdk/models/write_authorization_model_request.py openfga_sdk/models/write_authorization_model_response.py openfga_sdk/models/write_request.py +openfga_sdk/models/write_request_deletes.py +openfga_sdk/models/write_request_writes.py openfga_sdk/oauth2.py openfga_sdk/rest.py openfga_sdk/sync/__init__.py diff --git a/README.md b/README.md index 2147293d..ffc6b30e 100644 --- a/README.md +++ b/README.md @@ -320,10 +320,10 @@ Create a new authorization model. ```python body = WriteAuthorizationModelRequest( - schema_version = "1.1", + schema_version="1.1", type_definitions=[ TypeDefinition( - type="user", + type="user" ), TypeDefinition( type="document", @@ -342,9 +342,41 @@ body = WriteAuthorizationModelRequest( ], ), ), + ), + metadata=Metadata( + relations=dict( + writer=RelationMetadata( + directly_related_user_types=[ + RelationReference(type="user"), + RelationReference(type="user", condition="ViewCountLessThan200"), + ] + ), + viewer=RelationMetadata( + directly_related_user_types=[ + RelationReference(type="user"), + ] + ) + ) ) - ), + ) ], + conditions=dict( + ViewCountLessThan200=Condition( + name="ViewCountLessThan200", + expression="ViewCount < 200", + parameters=dict( + ViewCount=ConditionParamTypeRef( + type_name="TYPE_NAME_INT" + ), + Type=ConditionParamTypeRef( + type_name="TYPE_NAME_STRING" + ), + Name=ConditionParamTypeRef( + type_name="TYPE_NAME_STRING" + ), + ) + ) + ) ) response = await fga_client.write_authorization_model(body) @@ -364,7 +396,10 @@ options = { "authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1" } -response = await fga_client.read_authorization_model(id) +response = await fga_client.read_authorization_model({ + # You can rely on the model id set in the configuration or override it for this specific request + "authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1" +}) # response.authorization_model = AuthorizationModel(id='01GXSA8YR785C4FYS3C0RTG7B1', schema_version = '1.1', type_definitions=type_definitions[...]) ``` @@ -394,7 +429,7 @@ options = { "page_size": "25", "continuation_token": "eyJwayI6IkxBVEVTVF9OU0NPTkZJR19hdXRoMHN0b3JlIiwic2siOiIxem1qbXF3MWZLZExTcUoyN01MdTdqTjh0cWgifQ==" } -body = ClientReadChangesRequest("document") +body = ClientReadChangesRequest(type='document') response = await fga_client.read_changes(body, options) # response.continuation_token = ... @@ -409,7 +444,7 @@ Reads the relationship tuples stored in the database. It does not evaluate nor e ```python # Find if a relationship tuple stating that a certain user is a viewer of certain document -body = TupleKey( +body = ReadRequestTupleKey( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="viewer", object="document:roadmap", @@ -421,7 +456,7 @@ response = await fga_client.read(body) ```python # Find all relationship tuples where a certain user has a relationship as any relation to a certain document -body = TupleKey( +body = ReadRequestTupleKey( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", object="document:roadmap", ) @@ -433,7 +468,7 @@ response = await fga_client.read(body) ```python # Find all relationship tuples where a certain user is a viewer of any document -body = TupleKey( +body = ReadRequestTupleKey( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="viewer", object="document:", @@ -445,7 +480,7 @@ response = await fga_client.read(body) ```python # Find all relationship tuples where any user has a relationship as any relation with a particular document -body = TupleKey( +body = ReadRequestTupleKey( object="document:roadmap", ) @@ -455,7 +490,7 @@ response = await fga_client.read(body) ```python # Read all stored relationship tuples -body = TupleKey() +body = ReadRequestTupleKey() response = await api_instance.read(body) # response = ReadResponse({"tuples": [Tuple({"key": TupleKey({"user":"...","relation":"...","object":"..."}), "timestamp": datetime.fromisoformat("...") })]}) @@ -482,6 +517,13 @@ body = ClientWriteRequest( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="viewer", object="document:roadmap", + condition=RelationshipCondition( + name='ViewCountLessThan200', + context=dict( + Name='Roadmap', + Type='Document', + ), + ), ), ClientTuple( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -523,6 +565,13 @@ body = ClientWriteRequest( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="viewer", object="document:roadmap", + condition=RelationshipCondition( + name='ViewCountLessThan200', + context=dict( + Name='Roadmap', + Type='Document', + ), + ), ), ClientTuple( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -559,6 +608,9 @@ body = ClientCheckRequest( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="writer", object="document:roadmap", + context=dict( + ViewCount=100 + ), ) response = await fga_client.check(body, options) @@ -586,7 +638,10 @@ body = [ClientCheckRequest( relation="editor", object="document:roadmap", ), - ] + ], + context=dict( + ViewCount=100 + ), ), ClientCheckRequest( user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="admin", @@ -619,7 +674,10 @@ response = await fga_client.batch_check(body, options) # user: "user:81684243-9356-4421-8fbf-a4f8d36aa31b", # relation: "editor", # object: "document:roadmap" -# }] +# }], +# context=dict( +# ViewCount=100 +# ), # } # }, { # allowed: false, @@ -693,7 +751,10 @@ body = ClientListObjectsRequest( relation="writer", object="document:budget", ), - ] + ], + context=dict( + ViewCount=100 + ) ) response = await fga_client.list_objects(body) @@ -719,7 +780,10 @@ body = ClientListRelationsRequest( relation="writer", object="document:budget", ), - ] + ], + context=dict( + ViewCount=100 + ) ) var response = await fga_client.list_relations(body, options); @@ -788,18 +852,24 @@ Class | Method | HTTP request | Description ## Documentation For Models + - [AbortedMessageResponse](https://github.com/openfga/python-sdk/blob/main/docs/AbortedMessageResponse.md) - [Any](https://github.com/openfga/python-sdk/blob/main/docs/Any.md) - [Assertion](https://github.com/openfga/python-sdk/blob/main/docs/Assertion.md) + - [AssertionTupleKey](https://github.com/openfga/python-sdk/blob/main/docs/AssertionTupleKey.md) - [AuthorizationModel](https://github.com/openfga/python-sdk/blob/main/docs/AuthorizationModel.md) - [CheckRequest](https://github.com/openfga/python-sdk/blob/main/docs/CheckRequest.md) + - [CheckRequestTupleKey](https://github.com/openfga/python-sdk/blob/main/docs/CheckRequestTupleKey.md) - [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) + - [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) - [CreateStoreResponse](https://github.com/openfga/python-sdk/blob/main/docs/CreateStoreResponse.md) - [Difference](https://github.com/openfga/python-sdk/blob/main/docs/Difference.md) - [ErrorCode](https://github.com/openfga/python-sdk/blob/main/docs/ErrorCode.md) - [ExpandRequest](https://github.com/openfga/python-sdk/blob/main/docs/ExpandRequest.md) + - [ExpandRequestTupleKey](https://github.com/openfga/python-sdk/blob/main/docs/ExpandRequestTupleKey.md) - [ExpandResponse](https://github.com/openfga/python-sdk/blob/main/docs/ExpandResponse.md) - [GetStoreResponse](https://github.com/openfga/python-sdk/blob/main/docs/GetStoreResponse.md) - [InternalErrorCode](https://github.com/openfga/python-sdk/blob/main/docs/InternalErrorCode.md) @@ -812,6 +882,7 @@ Class | Method | HTTP request | Description - [Node](https://github.com/openfga/python-sdk/blob/main/docs/Node.md) - [Nodes](https://github.com/openfga/python-sdk/blob/main/docs/Nodes.md) - [NotFoundErrorCode](https://github.com/openfga/python-sdk/blob/main/docs/NotFoundErrorCode.md) + - [NullValue](https://github.com/openfga/python-sdk/blob/main/docs/NullValue.md) - [ObjectRelation](https://github.com/openfga/python-sdk/blob/main/docs/ObjectRelation.md) - [PathUnknownErrorMessageResponse](https://github.com/openfga/python-sdk/blob/main/docs/PathUnknownErrorMessageResponse.md) - [ReadAssertionsResponse](https://github.com/openfga/python-sdk/blob/main/docs/ReadAssertionsResponse.md) @@ -819,18 +890,21 @@ Class | Method | HTTP request | Description - [ReadAuthorizationModelsResponse](https://github.com/openfga/python-sdk/blob/main/docs/ReadAuthorizationModelsResponse.md) - [ReadChangesResponse](https://github.com/openfga/python-sdk/blob/main/docs/ReadChangesResponse.md) - [ReadRequest](https://github.com/openfga/python-sdk/blob/main/docs/ReadRequest.md) + - [ReadRequestTupleKey](https://github.com/openfga/python-sdk/blob/main/docs/ReadRequestTupleKey.md) - [ReadResponse](https://github.com/openfga/python-sdk/blob/main/docs/ReadResponse.md) - [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) - [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) - [TupleChange](https://github.com/openfga/python-sdk/blob/main/docs/TupleChange.md) - [TupleKey](https://github.com/openfga/python-sdk/blob/main/docs/TupleKey.md) - - [TupleKeys](https://github.com/openfga/python-sdk/blob/main/docs/TupleKeys.md) + - [TupleKeyWithoutCondition](https://github.com/openfga/python-sdk/blob/main/docs/TupleKeyWithoutCondition.md) - [TupleOperation](https://github.com/openfga/python-sdk/blob/main/docs/TupleOperation.md) - [TupleToUserset](https://github.com/openfga/python-sdk/blob/main/docs/TupleToUserset.md) - [TypeDefinition](https://github.com/openfga/python-sdk/blob/main/docs/TypeDefinition.md) + - [TypeName](https://github.com/openfga/python-sdk/blob/main/docs/TypeName.md) - [Users](https://github.com/openfga/python-sdk/blob/main/docs/Users.md) - [Userset](https://github.com/openfga/python-sdk/blob/main/docs/Userset.md) - [UsersetTree](https://github.com/openfga/python-sdk/blob/main/docs/UsersetTree.md) @@ -842,6 +916,8 @@ Class | Method | HTTP request | Description - [WriteAuthorizationModelRequest](https://github.com/openfga/python-sdk/blob/main/docs/WriteAuthorizationModelRequest.md) - [WriteAuthorizationModelResponse](https://github.com/openfga/python-sdk/blob/main/docs/WriteAuthorizationModelResponse.md) - [WriteRequest](https://github.com/openfga/python-sdk/blob/main/docs/WriteRequest.md) + - [WriteRequestDeletes](https://github.com/openfga/python-sdk/blob/main/docs/WriteRequestDeletes.md) + - [WriteRequestWrites](https://github.com/openfga/python-sdk/blob/main/docs/WriteRequestWrites.md) diff --git a/docs/AbortedMessageResponse.md b/docs/AbortedMessageResponse.md new file mode 100644 index 00000000..bfa92683 --- /dev/null +++ b/docs/AbortedMessageResponse.md @@ -0,0 +1,12 @@ +# AbortedMessageResponse + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**code** | **str** | | [optional] +**message** | **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) + + diff --git a/docs/Assertion.md b/docs/Assertion.md index 78964134..036ab9a1 100644 --- a/docs/Assertion.md +++ b/docs/Assertion.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**tuple_key** | [**TupleKey**](TupleKey.md) | | +**tuple_key** | [**AssertionTupleKey**](AssertionTupleKey.md) | | **expectation** | **bool** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/AssertionTupleKey.md b/docs/AssertionTupleKey.md new file mode 100644 index 00000000..d44bded2 --- /dev/null +++ b/docs/AssertionTupleKey.md @@ -0,0 +1,13 @@ +# AssertionTupleKey + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**object** | **str** | | +**relation** | **str** | | +**user** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/AuthorizationModel.md b/docs/AuthorizationModel.md index ccb71bf8..752c587a 100644 --- a/docs/AuthorizationModel.md +++ b/docs/AuthorizationModel.md @@ -4,9 +4,10 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **str** | | [optional] +**id** | **str** | | **schema_version** | **str** | | -**type_definitions** | [**list[TypeDefinition]**](TypeDefinition.md) | | [optional] +**type_definitions** | [**list[TypeDefinition]**](TypeDefinition.md) | | +**conditions** | [**dict[str, Condition]**](Condition.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) diff --git a/docs/CheckRequest.md b/docs/CheckRequest.md index 4457e854..cba772d8 100644 --- a/docs/CheckRequest.md +++ b/docs/CheckRequest.md @@ -4,10 +4,11 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**tuple_key** | [**TupleKey**](TupleKey.md) | | +**tuple_key** | [**CheckRequestTupleKey**](CheckRequestTupleKey.md) | | **contextual_tuples** | [**ContextualTupleKeys**](ContextualTupleKeys.md) | | [optional] **authorization_model_id** | **str** | | [optional] **trace** | **bool** | Defaults to false. Making it true has performance implications. | [optional] [readonly] +**context** | **object** | Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation. | [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) diff --git a/docs/CheckRequestTupleKey.md b/docs/CheckRequestTupleKey.md new file mode 100644 index 00000000..7ceea6eb --- /dev/null +++ b/docs/CheckRequestTupleKey.md @@ -0,0 +1,13 @@ +# CheckRequestTupleKey + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**user** | **str** | | +**relation** | **str** | | +**object** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Computed.md b/docs/Computed.md index 350bd746..d45561c8 100644 --- a/docs/Computed.md +++ b/docs/Computed.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**userset** | **str** | | [optional] +**userset** | **str** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/Condition.md b/docs/Condition.md new file mode 100644 index 00000000..a61db887 --- /dev/null +++ b/docs/Condition.md @@ -0,0 +1,13 @@ +# Condition + + +## Properties +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] + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/ConditionParamTypeRef.md b/docs/ConditionParamTypeRef.md new file mode 100644 index 00000000..d45831c5 --- /dev/null +++ b/docs/ConditionParamTypeRef.md @@ -0,0 +1,12 @@ +# ConditionParamTypeRef + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**type_name** | [**TypeName**](TypeName.md) | | +**generic_types** | [**list[ConditionParamTypeRef]**](ConditionParamTypeRef.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) + + diff --git a/docs/CreateStoreResponse.md b/docs/CreateStoreResponse.md index 5a956879..1febe9de 100644 --- a/docs/CreateStoreResponse.md +++ b/docs/CreateStoreResponse.md @@ -4,10 +4,10 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **str** | | [optional] -**name** | **str** | | [optional] -**created_at** | **datetime** | | [optional] -**updated_at** | **datetime** | | [optional] +**id** | **str** | | +**name** | **str** | | +**created_at** | **datetime** | | +**updated_at** | **datetime** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/ExpandRequest.md b/docs/ExpandRequest.md index ac726aca..662d3b3a 100644 --- a/docs/ExpandRequest.md +++ b/docs/ExpandRequest.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**tuple_key** | [**TupleKey**](TupleKey.md) | | +**tuple_key** | [**ExpandRequestTupleKey**](ExpandRequestTupleKey.md) | | **authorization_model_id** | **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) diff --git a/docs/ExpandRequestTupleKey.md b/docs/ExpandRequestTupleKey.md new file mode 100644 index 00000000..db086c87 --- /dev/null +++ b/docs/ExpandRequestTupleKey.md @@ -0,0 +1,12 @@ +# ExpandRequestTupleKey + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**relation** | **str** | | +**object** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/GetStoreResponse.md b/docs/GetStoreResponse.md index 5cd2ec3f..07904258 100644 --- a/docs/GetStoreResponse.md +++ b/docs/GetStoreResponse.md @@ -4,10 +4,11 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **str** | | [optional] -**name** | **str** | | [optional] -**created_at** | **datetime** | | [optional] -**updated_at** | **datetime** | | [optional] +**id** | **str** | | +**name** | **str** | | +**created_at** | **datetime** | | +**updated_at** | **datetime** | | +**deleted_at** | **datetime** | | [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) diff --git a/docs/ListObjectsRequest.md b/docs/ListObjectsRequest.md index a37edd53..b55c1e92 100644 --- a/docs/ListObjectsRequest.md +++ b/docs/ListObjectsRequest.md @@ -9,6 +9,7 @@ Name | Type | Description | Notes **relation** | **str** | | **user** | **str** | | **contextual_tuples** | [**ContextualTupleKeys**](ContextualTupleKeys.md) | | [optional] +**context** | **object** | Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation. | [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) diff --git a/docs/ListObjectsResponse.md b/docs/ListObjectsResponse.md index b45dbf4f..3f2a1771 100644 --- a/docs/ListObjectsResponse.md +++ b/docs/ListObjectsResponse.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**objects** | **list[str]** | | [optional] +**objects** | **list[str]** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/ListStoresResponse.md b/docs/ListStoresResponse.md index 415e8444..5736be5a 100644 --- a/docs/ListStoresResponse.md +++ b/docs/ListStoresResponse.md @@ -4,8 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**stores** | [**list[Store]**](Store.md) | | [optional] -**continuation_token** | **str** | The continuation token will be empty if there are no more stores. | [optional] +**stores** | [**list[Store]**](Store.md) | | +**continuation_token** | **str** | The continuation token will be empty if there are no more stores. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/Node.md b/docs/Node.md index 789b0dc7..7734591f 100644 --- a/docs/Node.md +++ b/docs/Node.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**name** | **str** | | [optional] +**name** | **str** | | **leaf** | [**Leaf**](Leaf.md) | | [optional] **difference** | [**UsersetTreeDifference**](UsersetTreeDifference.md) | | [optional] **union** | [**Nodes**](Nodes.md) | | [optional] diff --git a/docs/Nodes.md b/docs/Nodes.md index 1bc99a01..995ec4c8 100644 --- a/docs/Nodes.md +++ b/docs/Nodes.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**nodes** | [**list[Node]**](Node.md) | | [optional] +**nodes** | [**list[Node]**](Node.md) | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/NullValue.md b/docs/NullValue.md new file mode 100644 index 00000000..894061ce --- /dev/null +++ b/docs/NullValue.md @@ -0,0 +1,11 @@ +# NullValue + +`NullValue` is a singleton enumeration to represent the null value for the `Value` type union. The JSON representation for `NullValue` is JSON `null`. - NULL_VALUE: Null value. + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/OpenFgaApi.md b/docs/OpenFgaApi.md index ed840e5b..8bd6f211 100644 --- a/docs/OpenFgaApi.md +++ b/docs/OpenFgaApi.md @@ -26,7 +26,7 @@ Method | HTTP request | Description Check whether a user is authorized to access an object -The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. +The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. Each of these tuples may have an associated `condition`. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. ### Example @@ -97,6 +97,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -175,6 +176,7 @@ No authorization required **201** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -252,6 +254,7 @@ No authorization required **204** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -332,6 +335,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -410,6 +414,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -419,7 +424,7 @@ No authorization required List all objects of the given type that the user has a relation with -The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. +The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. Each of these tuples may have an associated `condition`. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. ### Example @@ -490,6 +495,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -569,6 +575,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -649,6 +656,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -729,6 +737,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -809,6 +818,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -891,6 +901,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -900,7 +911,7 @@ No authorization required Return a list of all the tuple changes -The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. +The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. When reading a write tuple change, if it was conditioned, the condition will be returned. When reading a delete tuple change, the condition will NOT be returned regardless of whether it was originally conditioned or not. ### Example @@ -975,6 +986,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -984,7 +996,7 @@ No authorization required Add or delete tuples from the store -The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples while `deletes` removes existing tuples. The API is not idempotent: if, later on, you try to add the same tuple, or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` +The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` ### Example @@ -1055,6 +1067,7 @@ No authorization required **200** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -1136,6 +1149,7 @@ No authorization required **204** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) @@ -1216,6 +1230,7 @@ No authorization required **201** | A successful response. | - | **400** | Request failed due to invalid input. | - | **404** | Request failed due to incorrect path. | - | +**409** | Request was aborted due a transaction conflict. | - | **500** | Request failed due to internal server error. | - | [[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to Model list]](../README.md#documentation-for-models) [[Back to README]](../README.md) diff --git a/docs/ReadAssertionsResponse.md b/docs/ReadAssertionsResponse.md index dcc1e560..0045bb80 100644 --- a/docs/ReadAssertionsResponse.md +++ b/docs/ReadAssertionsResponse.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**authorization_model_id** | **str** | | [optional] +**authorization_model_id** | **str** | | **assertions** | [**list[Assertion]**](Assertion.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) diff --git a/docs/ReadAuthorizationModelsResponse.md b/docs/ReadAuthorizationModelsResponse.md index 60454ba4..9c09beb3 100644 --- a/docs/ReadAuthorizationModelsResponse.md +++ b/docs/ReadAuthorizationModelsResponse.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**authorization_models** | [**list[AuthorizationModel]**](AuthorizationModel.md) | | [optional] +**authorization_models** | [**list[AuthorizationModel]**](AuthorizationModel.md) | | **continuation_token** | **str** | The continuation token will be empty if there are no more models. | [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) diff --git a/docs/ReadChangesResponse.md b/docs/ReadChangesResponse.md index f9dcab41..9c646a87 100644 --- a/docs/ReadChangesResponse.md +++ b/docs/ReadChangesResponse.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**changes** | [**list[TupleChange]**](TupleChange.md) | | [optional] +**changes** | [**list[TupleChange]**](TupleChange.md) | | **continuation_token** | **str** | The continuation token will be identical if there are no new changes. | [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) diff --git a/docs/ReadRequest.md b/docs/ReadRequest.md index 2a0d953d..31ceeaa5 100644 --- a/docs/ReadRequest.md +++ b/docs/ReadRequest.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**tuple_key** | [**TupleKey**](TupleKey.md) | | [optional] +**tuple_key** | [**ReadRequestTupleKey**](ReadRequestTupleKey.md) | | [optional] **page_size** | **int** | | [optional] **continuation_token** | **str** | | [optional] diff --git a/docs/ReadRequestTupleKey.md b/docs/ReadRequestTupleKey.md new file mode 100644 index 00000000..051ebb12 --- /dev/null +++ b/docs/ReadRequestTupleKey.md @@ -0,0 +1,13 @@ +# ReadRequestTupleKey + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**user** | **str** | | [optional] +**relation** | **str** | | [optional] +**object** | **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) + + diff --git a/docs/ReadResponse.md b/docs/ReadResponse.md index cc06ed99..334006d1 100644 --- a/docs/ReadResponse.md +++ b/docs/ReadResponse.md @@ -4,8 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**tuples** | [**list[Tuple]**](Tuple.md) | | [optional] -**continuation_token** | **str** | The continuation token will be empty if there are no more tuples. | [optional] +**tuples** | [**list[Tuple]**](Tuple.md) | | +**continuation_token** | **str** | The continuation token will be empty if there are no more tuples. | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/RelationReference.md b/docs/RelationReference.md index 0e49727d..e04a2101 100644 --- a/docs/RelationReference.md +++ b/docs/RelationReference.md @@ -8,6 +8,7 @@ Name | Type | Description | Notes **type** | **str** | | **relation** | **str** | | [optional] **wildcard** | **object** | | [optional] +**condition** | **str** | The name of a condition that is enforced over the allowed relation. | [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) diff --git a/docs/RelationshipCondition.md b/docs/RelationshipCondition.md new file mode 100644 index 00000000..c94f4770 --- /dev/null +++ b/docs/RelationshipCondition.md @@ -0,0 +1,12 @@ +# RelationshipCondition + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**name** | **str** | A reference (by name) of the relationship condition defined in the authorization model. | +**context** | **object** | Additional context/data to persist along with the condition. The keys must match the parameters defined by the condition, and the value types must match the parameter type definitions. | [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) + + diff --git a/docs/Store.md b/docs/Store.md index f6b12406..088b3504 100644 --- a/docs/Store.md +++ b/docs/Store.md @@ -4,10 +4,10 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**id** | **str** | | [optional] -**name** | **str** | | [optional] -**created_at** | **datetime** | | [optional] -**updated_at** | **datetime** | | [optional] +**id** | **str** | | +**name** | **str** | | +**created_at** | **datetime** | | +**updated_at** | **datetime** | | **deleted_at** | **datetime** | | [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) diff --git a/docs/Tuple.md b/docs/Tuple.md index f6c82ba6..9e057e93 100644 --- a/docs/Tuple.md +++ b/docs/Tuple.md @@ -4,8 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**key** | [**TupleKey**](TupleKey.md) | | [optional] -**timestamp** | **datetime** | | [optional] +**key** | [**TupleKey**](TupleKey.md) | | +**timestamp** | **datetime** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/TupleChange.md b/docs/TupleChange.md index fecebc1b..d7e6fdd8 100644 --- a/docs/TupleChange.md +++ b/docs/TupleChange.md @@ -4,9 +4,9 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**tuple_key** | [**TupleKey**](TupleKey.md) | | [optional] -**operation** | [**TupleOperation**](TupleOperation.md) | | [optional] -**timestamp** | **datetime** | | [optional] +**tuple_key** | [**TupleKey**](TupleKey.md) | | +**operation** | [**TupleOperation**](TupleOperation.md) | | +**timestamp** | **datetime** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/TupleKey.md b/docs/TupleKey.md index 45edd944..509f1070 100644 --- a/docs/TupleKey.md +++ b/docs/TupleKey.md @@ -4,9 +4,10 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**object** | **str** | | [optional] -**relation** | **str** | | [optional] -**user** | **str** | | [optional] +**user** | **str** | | +**relation** | **str** | | +**object** | **str** | | +**condition** | [**RelationshipCondition**](RelationshipCondition.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) diff --git a/docs/TupleKeyWithoutCondition.md b/docs/TupleKeyWithoutCondition.md new file mode 100644 index 00000000..5c45055c --- /dev/null +++ b/docs/TupleKeyWithoutCondition.md @@ -0,0 +1,13 @@ +# TupleKeyWithoutCondition + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**user** | **str** | | +**relation** | **str** | | +**object** | **str** | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/TupleToUserset.md b/docs/TupleToUserset.md index 8b197a85..42f8019b 100644 --- a/docs/TupleToUserset.md +++ b/docs/TupleToUserset.md @@ -4,8 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**tupleset** | [**ObjectRelation**](ObjectRelation.md) | | [optional] -**computed_userset** | [**ObjectRelation**](ObjectRelation.md) | | [optional] +**tupleset** | [**ObjectRelation**](ObjectRelation.md) | | +**computed_userset** | [**ObjectRelation**](ObjectRelation.md) | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/TypeName.md b/docs/TypeName.md new file mode 100644 index 00000000..bcb331f9 --- /dev/null +++ b/docs/TypeName.md @@ -0,0 +1,10 @@ +# TypeName + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/Users.md b/docs/Users.md index a8323d02..e17f61dd 100644 --- a/docs/Users.md +++ b/docs/Users.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**users** | **list[str]** | | [optional] +**users** | **list[str]** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/UsersetTreeDifference.md b/docs/UsersetTreeDifference.md index 6cf24ce1..cebff78b 100644 --- a/docs/UsersetTreeDifference.md +++ b/docs/UsersetTreeDifference.md @@ -4,8 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**base** | [**Node**](Node.md) | | [optional] -**subtract** | [**Node**](Node.md) | | [optional] +**base** | [**Node**](Node.md) | | +**subtract** | [**Node**](Node.md) | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/UsersetTreeTupleToUserset.md b/docs/UsersetTreeTupleToUserset.md index fe4a423b..1fe86476 100644 --- a/docs/UsersetTreeTupleToUserset.md +++ b/docs/UsersetTreeTupleToUserset.md @@ -4,8 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**tupleset** | **str** | | [optional] -**computed** | [**list[Computed]**](Computed.md) | | [optional] +**tupleset** | **str** | | +**computed** | [**list[Computed]**](Computed.md) | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/Usersets.md b/docs/Usersets.md index 21e9e190..e598d17d 100644 --- a/docs/Usersets.md +++ b/docs/Usersets.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**child** | [**list[Userset]**](Userset.md) | | [optional] +**child** | [**list[Userset]**](Userset.md) | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/WriteAuthorizationModelRequest.md b/docs/WriteAuthorizationModelRequest.md index a82159a6..41f8947a 100644 --- a/docs/WriteAuthorizationModelRequest.md +++ b/docs/WriteAuthorizationModelRequest.md @@ -5,7 +5,8 @@ Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- **type_definitions** | [**list[TypeDefinition]**](TypeDefinition.md) | | -**schema_version** | **str** | | [optional] +**schema_version** | **str** | | +**conditions** | [**dict[str, Condition]**](Condition.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) diff --git a/docs/WriteAuthorizationModelResponse.md b/docs/WriteAuthorizationModelResponse.md index ba829e05..9f9f428e 100644 --- a/docs/WriteAuthorizationModelResponse.md +++ b/docs/WriteAuthorizationModelResponse.md @@ -4,7 +4,7 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**authorization_model_id** | **str** | | [optional] +**authorization_model_id** | **str** | | [[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) diff --git a/docs/WriteRequest.md b/docs/WriteRequest.md index 659504ac..3ec76a53 100644 --- a/docs/WriteRequest.md +++ b/docs/WriteRequest.md @@ -4,8 +4,8 @@ ## Properties Name | Type | Description | Notes ------------ | ------------- | ------------- | ------------- -**writes** | [**TupleKeys**](TupleKeys.md) | | [optional] -**deletes** | [**TupleKeys**](TupleKeys.md) | | [optional] +**writes** | [**WriteRequestWrites**](WriteRequestWrites.md) | | [optional] +**deletes** | [**WriteRequestDeletes**](WriteRequestDeletes.md) | | [optional] **authorization_model_id** | **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) diff --git a/docs/WriteRequestDeletes.md b/docs/WriteRequestDeletes.md new file mode 100644 index 00000000..d0aa46bf --- /dev/null +++ b/docs/WriteRequestDeletes.md @@ -0,0 +1,11 @@ +# WriteRequestDeletes + + +## Properties +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**tuple_keys** | [**list[TupleKeyWithoutCondition]**](TupleKeyWithoutCondition.md) | | + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/docs/TupleKeys.md b/docs/WriteRequestWrites.md similarity index 94% rename from docs/TupleKeys.md rename to docs/WriteRequestWrites.md index f4aa024a..4cfff854 100644 --- a/docs/TupleKeys.md +++ b/docs/WriteRequestWrites.md @@ -1,4 +1,4 @@ -# TupleKeys +# WriteRequestWrites ## Properties diff --git a/example/example1/auth-model.json b/example/example1/auth-model.json deleted file mode 100644 index e1361656..00000000 --- a/example/example1/auth-model.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "schema_version": "1.1", - "type_definitions": [ - { - "type": "user" - }, - { - "type": "document", - "relations": { - "reader": { - "this": {} - }, - "writer": { - "this": {} - }, - "owner": { - "this": {} - } - }, - "metadata": { - "relations": { - "reader": { - "directly_related_user_types": [ - { - "type": "user" - } - ] - }, - "writer": { - "directly_related_user_types": [ - { - "type": "user" - } - ] - }, - "owner": { - "directly_related_user_types": [ - { - "type": "user" - } - ] - }, - "conditional_reader": { - "directly_related_user_types": [ - { - "condition": "name_starts_with_a", - "type": "user" - } - ] - } - } - } - } - ], - "conditions": { - "ViewCountLessThan200": { - "name": "ViewCountLessThan200", - "expression": "ViewCount < 200", - "parameters": { - "ViewCount": { - "type_name": "TYPE_NAME_INT" - }, - "Type": { - "type_name": "TYPE_NAME_STRING" - }, - "Name": { - "type_name": "TYPE_NAME_STRING" - } - } - } - } - } - \ No newline at end of file diff --git a/example/example1/example1.py b/example/example1/example1.py index 3687c806..c06f3c5e 100644 --- a/example/example1/example1.py +++ b/example/example1/example1.py @@ -1,10 +1,10 @@ import asyncio -import json -import openfga_sdk -from openfga_sdk.client.models import ClientAssertion, ClientCheckRequest, ClientReadChangesRequest, ClientTuple, ClientWriteRequest -from openfga_sdk.models import CreateStoreRequest, Metadata, ObjectRelation, RelationMetadata, TupleKey, TypeDefinition, Userset, Usersets, WriteAuthorizationModelRequest -from openfga_sdk import ClientConfiguration, OpenFgaClient +from openfga_sdk.client.models import ClientAssertion, ClientCheckRequest, ClientReadChangesRequest, ClientTuple, \ + ClientWriteRequest, ClientListRelationsRequest, ClientListObjectsRequest, WriteTransactionOpts +from openfga_sdk import ClientConfiguration, OpenFgaClient, RelationReference, RelationshipCondition, \ + ConditionParamTypeRef, Condition, ReadRequestTupleKey, CreateStoreRequest, Metadata, ObjectRelation, \ + RelationMetadata, TypeDefinition, Userset, Usersets, WriteAuthorizationModelRequest from openfga_sdk.credentials import CredentialConfiguration, Credentials import os @@ -76,9 +76,65 @@ async def main(): # WriteAuthorizationModel print('Writing an Authorization Model') - with open(os.path.join(os.path.dirname(__file__), 'auth-model.json')) as f: - auth_model_request = json.load(f) - response = await fga_client.write_authorization_model(auth_model_request) + response = await fga_client.write_authorization_model(WriteAuthorizationModelRequest( + schema_version="1.1", + type_definitions=[ + TypeDefinition( + type="user" + ), + TypeDefinition( + type="document", + relations=dict( + writer=Userset( + this=dict(), + ), + viewer=Userset( + union=Usersets( + child=[ + Userset(this=dict()), + Userset(computed_userset=ObjectRelation( + object="", + relation="writer", + )), + ], + ), + ), + ), + metadata=Metadata( + relations=dict( + writer=RelationMetadata( + directly_related_user_types=[ + RelationReference(type="user"), + RelationReference(type="user", condition="ViewCountLessThan200"), + ] + ), + viewer=RelationMetadata( + directly_related_user_types=[ + RelationReference(type="user"), + ] + ) + ) + ) + ) + ], + conditions=dict( + ViewCountLessThan200=Condition( + name="ViewCountLessThan200", + expression="ViewCount < 200", + parameters=dict( + ViewCount=ConditionParamTypeRef( + type_name="TYPE_NAME_INT" + ), + Type=ConditionParamTypeRef( + type_name="TYPE_NAME_STRING" + ), + Name=ConditionParamTypeRef( + type_name="TYPE_NAME_STRING" + ), + ) + ) + ) + )) print(f"Authorization Model ID: {response.authorization_model_id}") # ReadAuthorizationModels (after write) @@ -101,13 +157,13 @@ async def main(): user='user:anne', relation='writer', object='document:roadmap', - # condition=RelationshipCondition( - # name='ViewCountLessThan200', - # context=dict( - # Name='Roadmap', - # Type='Document', - # ), - # ), + condition=RelationshipCondition( + name='ViewCountLessThan200', + context=dict( + Name='Roadmap', + Type='Document', + ), + ), ), ], ) @@ -118,31 +174,113 @@ async def main(): await fga_client.write(body, options) print('Done Writing Tuples') + # Write + print('Writing Tuples - non txn') + body = ClientWriteRequest( + writes=[ + ClientTuple( + user='user:beth', + relation='writer', + object='document:1', + condition=RelationshipCondition( + name='ViewCountLessThan200', + context=dict( + Name='Roadmap', + Type='Document', + ), + ), + ), + ClientTuple( + user='user:beth', + relation='viewer', + object='document:2' + ), + ], + ) + options = { + # You can rely on the model id set in the configuration or override it for this specific request + "authorization_model_id": auth_model_id, + "transaction": WriteTransactionOpts( + max_per_chunk=1 + ) + } + await fga_client.write(body, options) + print('Done Writing Tuples') + # Set the model ID fga_client.set_authorization_model_id(auth_model_id) # Read print('Reading Tuples') - response = await fga_client.read(TupleKey(user='user:anne', object='document:')) + response = await fga_client.read(ReadRequestTupleKey(user='user:anne', object='document:')) print(f"Read Tuples: {response.tuples}") # ReadChanges print('Reading Tuple Changes') - body = ClientReadChangesRequest('document') + body = ClientReadChangesRequest(type='document') response = await fga_client.read_changes(body) print(f"Read Changes Tuples: {response.changes}") # Check - print('Checking for access') + print('Checking for access w/o context') + try: + response = await fga_client.check(ClientCheckRequest( + user='user:anne', + relation='viewer', + object='document:roadmap' + )) + print(f"Allowed: {response.allowed}") + except Exception as err: + print(f"Failed due to: {err}") + + # Checking for access with context + print('Checking for access with context') + response = await fga_client.check(ClientCheckRequest( user='user:anne', - relation='reader', + relation='viewer', object='document:roadmap', + context=dict( + ViewCount=100 + ) )) print(f"Allowed: {response.allowed}") - # Checking for access with context - # TODO + # List objects with context + print('Listing objects for access with context') + + response = await fga_client.list_objects(ClientListObjectsRequest( + user='user:anne', + relation='viewer', + type='document', + context=dict( + ViewCount=100 + ) + )) + print(f"Objects: {response.objects}") + + # List relations w/o context + print('Listing relations for access w/o context') + + response = await fga_client.list_relations(ClientListRelationsRequest( + user='user:anne', + relations=['viewer', 'writer'], + object='document:roadmap' + )) + print(f"Relations: {response}") + + # List relations with context + print('Listing relations for access with context') + + response = await fga_client.list_relations(ClientListRelationsRequest( + user='user:anne', + relations=['viewer', 'writer'], + object='document:roadmap', + context=dict( + ViewCount=100 + ) + )) + print(f"Relations: {response}") # WriteAssertions await fga_client.write_assertions([ @@ -154,7 +292,7 @@ async def main(): ), ClientAssertion( user='user:anne', - relation='reader', + relation='viewer', object='document:roadmap', expectation=False, ), diff --git a/openfga_sdk/__init__.py b/openfga_sdk/__init__.py index 5a9de766..554a52df 100644 --- a/openfga_sdk/__init__.py +++ b/openfga_sdk/__init__.py @@ -32,18 +32,24 @@ from openfga_sdk.exceptions import ApiAttributeError from openfga_sdk.exceptions import ApiException # import models into sdk package +from openfga_sdk.models.aborted_message_response import AbortedMessageResponse from openfga_sdk.models.any import Any from openfga_sdk.models.assertion import Assertion +from openfga_sdk.models.assertion_tuple_key import AssertionTupleKey from openfga_sdk.models.authorization_model import AuthorizationModel from openfga_sdk.models.check_request import CheckRequest +from openfga_sdk.models.check_request_tuple_key import CheckRequestTupleKey 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_param_type_ref import ConditionParamTypeRef from openfga_sdk.models.contextual_tuple_keys import ContextualTupleKeys from openfga_sdk.models.create_store_request import CreateStoreRequest from openfga_sdk.models.create_store_response import CreateStoreResponse from openfga_sdk.models.difference import Difference from openfga_sdk.models.error_code import ErrorCode from openfga_sdk.models.expand_request import ExpandRequest +from openfga_sdk.models.expand_request_tuple_key import ExpandRequestTupleKey from openfga_sdk.models.expand_response import ExpandResponse from openfga_sdk.models.get_store_response import GetStoreResponse from openfga_sdk.models.internal_error_code import InternalErrorCode @@ -56,6 +62,7 @@ from openfga_sdk.models.node import Node from openfga_sdk.models.nodes import Nodes from openfga_sdk.models.not_found_error_code import NotFoundErrorCode +from openfga_sdk.models.null_value import NullValue from openfga_sdk.models.object_relation import ObjectRelation from openfga_sdk.models.path_unknown_error_message_response import PathUnknownErrorMessageResponse from openfga_sdk.models.read_assertions_response import ReadAssertionsResponse @@ -63,18 +70,21 @@ from openfga_sdk.models.read_authorization_models_response import ReadAuthorizationModelsResponse from openfga_sdk.models.read_changes_response import ReadChangesResponse from openfga_sdk.models.read_request import ReadRequest +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.read_response import ReadResponse 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.status import Status from openfga_sdk.models.store import Store from openfga_sdk.models.tuple import Tuple from openfga_sdk.models.tuple_change import TupleChange from openfga_sdk.models.tuple_key import TupleKey -from openfga_sdk.models.tuple_keys import TupleKeys +from openfga_sdk.models.tuple_key_without_condition import TupleKeyWithoutCondition from openfga_sdk.models.tuple_operation import TupleOperation from openfga_sdk.models.tuple_to_userset import TupleToUserset from openfga_sdk.models.type_definition import TypeDefinition +from openfga_sdk.models.type_name import TypeName from openfga_sdk.models.users import Users from openfga_sdk.models.userset import Userset from openfga_sdk.models.userset_tree import UsersetTree @@ -86,3 +96,5 @@ from openfga_sdk.models.write_authorization_model_request import WriteAuthorizationModelRequest from openfga_sdk.models.write_authorization_model_response import WriteAuthorizationModelResponse from openfga_sdk.models.write_request import WriteRequest +from openfga_sdk.models.write_request_deletes import WriteRequestDeletes +from openfga_sdk.models.write_request_writes import WriteRequestWrites diff --git a/openfga_sdk/api/open_fga_api.py b/openfga_sdk/api/open_fga_api.py index 4c1d42df..ba10f6a2 100644 --- a/openfga_sdk/api/open_fga_api.py +++ b/openfga_sdk/api/open_fga_api.py @@ -56,7 +56,7 @@ async def close(self): async def check(self, body, **kwargs): # noqa: E501 """Check whether a user is authorized to access an object # noqa: E501 - The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. # noqa: E501 + The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. Each of these tuples may have an associated `condition`. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. # noqa: E501 >>> thread = await api.check(body) @@ -83,7 +83,7 @@ async def check(self, body, **kwargs): # noqa: E501 async def check_with_http_info(self, body, **kwargs): # noqa: E501 """Check whether a user is authorized to access an object # noqa: E501 - The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. # noqa: E501 + The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. Each of these tuples may have an associated `condition`. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. # noqa: E501 >>> thread = api.check_with_http_info(body) @@ -180,6 +180,7 @@ async def check_with_http_info(self, body, **kwargs): # noqa: E501 200: "CheckResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -322,6 +323,7 @@ async def create_store_with_http_info(self, body, **kwargs): # noqa: E501 201: "CreateStoreResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -599,6 +601,7 @@ async def expand_with_http_info(self, body, **kwargs): # noqa: E501 200: "ExpandResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -732,6 +735,7 @@ async def get_store_with_http_info(self, **kwargs): # noqa: E501 200: "GetStoreResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -757,7 +761,7 @@ async def get_store_with_http_info(self, **kwargs): # noqa: E501 async def list_objects(self, body, **kwargs): # noqa: E501 """List all objects of the given type that the user has a relation with # noqa: E501 - The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501 + The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. Each of these tuples may have an associated `condition`. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501 >>> thread = await api.list_objects(body) @@ -784,7 +788,7 @@ async def list_objects(self, body, **kwargs): # noqa: E501 async def list_objects_with_http_info(self, body, **kwargs): # noqa: E501 """List all objects of the given type that the user has a relation with # noqa: E501 - The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501 + The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. Each of these tuples may have an associated `condition`. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501 >>> thread = api.list_objects_with_http_info(body) @@ -881,6 +885,7 @@ async def list_objects_with_http_info(self, body, **kwargs): # noqa: E501 200: "ListObjectsResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1024,6 +1029,7 @@ async def list_stores_with_http_info(self, **kwargs): # noqa: E501 200: "ListStoresResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1173,6 +1179,7 @@ async def read_with_http_info(self, body, **kwargs): # noqa: E501 200: "ReadResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1318,6 +1325,7 @@ async def read_assertions_with_http_info(self, authorization_model_id, **kwargs) 200: "ReadAssertionsResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1464,6 +1472,7 @@ async def read_authorization_model_with_http_info(self, id, **kwargs): # noqa: 200: "ReadAuthorizationModelResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1611,6 +1620,7 @@ async def read_authorization_models_with_http_info(self, **kwargs): # noqa: E50 200: "ReadAuthorizationModelsResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1636,7 +1646,7 @@ async def read_authorization_models_with_http_info(self, **kwargs): # noqa: E50 async def read_changes(self, **kwargs): # noqa: E501 """Return a list of all the tuple changes # noqa: E501 - The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. # noqa: E501 + The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. When reading a write tuple change, if it was conditioned, the condition will be returned. When reading a delete tuple change, the condition will NOT be returned regardless of whether it was originally conditioned or not. # noqa: E501 >>> thread = await api.read_changes() @@ -1667,7 +1677,7 @@ async def read_changes(self, **kwargs): # noqa: E501 async def read_changes_with_http_info(self, **kwargs): # noqa: E501 """Return a list of all the tuple changes # noqa: E501 - The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. # noqa: E501 + The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. When reading a write tuple change, if it was conditioned, the condition will be returned. When reading a delete tuple change, the condition will NOT be returned regardless of whether it was originally conditioned or not. # noqa: E501 >>> thread = api.read_changes_with_http_info() @@ -1765,6 +1775,7 @@ async def read_changes_with_http_info(self, **kwargs): # noqa: E501 200: "ReadChangesResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1790,7 +1801,7 @@ async def read_changes_with_http_info(self, **kwargs): # noqa: E501 async def write(self, body, **kwargs): # noqa: E501 """Add or delete tuples from the store # noqa: E501 - The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples while `deletes` removes existing tuples. The API is not idempotent: if, later on, you try to add the same tuple, or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` # noqa: E501 + The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` # noqa: E501 >>> thread = await api.write(body) @@ -1817,7 +1828,7 @@ async def write(self, body, **kwargs): # noqa: E501 async def write_with_http_info(self, body, **kwargs): # noqa: E501 """Add or delete tuples from the store # noqa: E501 - The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples while `deletes` removes existing tuples. The API is not idempotent: if, later on, you try to add the same tuple, or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` # noqa: E501 + The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` # noqa: E501 >>> thread = api.write_with_http_info(body) @@ -1914,6 +1925,7 @@ async def write_with_http_info(self, body, **kwargs): # noqa: E501 200: "object", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -2220,6 +2232,7 @@ async def write_authorization_model_with_http_info(self, body, **kwargs): # noq 201: "WriteAuthorizationModelResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } diff --git a/openfga_sdk/client/client.py b/openfga_sdk/client/client.py index 4521b401..450f31ab 100644 --- a/openfga_sdk/client/client.py +++ b/openfga_sdk/client/client.py @@ -36,9 +36,11 @@ from openfga_sdk.models.contextual_tuple_keys import ContextualTupleKeys from openfga_sdk.models.create_store_request import CreateStoreRequest from openfga_sdk.models.expand_request import ExpandRequest +from openfga_sdk.models.expand_request_tuple_key import ExpandRequestTupleKey from openfga_sdk.models.list_objects_request import ListObjectsRequest from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_request import ReadRequest +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.tuple_key import TupleKey from openfga_sdk.models.write_assertions_request import WriteAssertionsRequest from openfga_sdk.models.write_authorization_model_request import WriteAuthorizationModelRequest @@ -73,7 +75,7 @@ def set_heading_if_not_set(options: dict[str, int | str], name: str, value: str) def options_to_kwargs(options: dict[str, int | str] = None): """ - Return kargs with continuation_token and page_size + Return kwargs with continuation_token and page_size """ kwargs = {} if options is not None: @@ -126,7 +128,7 @@ async def close(self): def _get_authorization_model_id(self, options: object) -> str | None: """ Return the authorization model ID if specified in the options. - Otherwise return the authorization model ID stored in the client's configuration + Otherwise, return the authorization model ID stored in the client's configuration """ authorization_model_id = self._client_configuration.authorization_model_id if options is not None and "authorization_model_id" in options: @@ -152,13 +154,13 @@ def get_store_id(self): def set_authorization_model_id(self, value): """ - Update the authorizaiton model id in the configuration + Update the authorization model id in the configuration """ self._client_configuration.authorization_model_id = value def get_authorization_model_id(self): """ - Return the authorizaiton model id + Return the authorization model id """ return self._client_configuration.authorization_model_id @@ -186,7 +188,7 @@ async def list_stores(self, options: dict[str, int | str] = None): :param retryParams.maxRetry(options) - Override the max number of retries on each API request :param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated """ - # convert options to kargs + # convert options to kwargs options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ListStores") kwargs = options_to_kwargs(options) api_response = await self._api.list_stores( @@ -295,7 +297,7 @@ async def read_authorization_model(self, options: dict[str, int | str] = None): async def read_latest_authorization_model(self, options: dict[str, int | str] = None): """ - Convenient method of reading the latest authorizaiton model + Convenient method of reading the latest authorization model :param header(options) - Custom headers to send alongside the request :param retryParams(options) - Override the retry parameters for this request :param retryParams.maxRetry(options) - Override the max number of retries on each API request @@ -330,7 +332,7 @@ async def read_changes(self, body: ClientReadChangesRequest, options: dict[str, ) return api_response - async def read(self, body: TupleKey, options: dict[str, str] = None): + async def read(self, body: ReadRequestTupleKey, options: dict[str, str] = None): """ Read changes for specified type :param body - the tuples we want to read @@ -505,6 +507,7 @@ async def check(self, body: ClientCheckRequest, options: dict[str, str] = None): relation=body.relation, object=body.object, ), + context=body.context, authorization_model_id=self._get_authorization_model_id(options), ) if body.contextual_tuples: @@ -573,7 +576,7 @@ async def expand(self, body: ClientExpandRequest, options: dict[str, str] = None kwargs = options_to_kwargs(options) req_body = ExpandRequest( - tuple_key=TupleKey( + tuple_key=ExpandRequestTupleKey( relation=body.relation, object=body.object, ), @@ -603,6 +606,7 @@ async def list_objects(self, body: ClientListObjectsRequest, options: dict[str, user=body.user, relation=body.relation, type=body.type, + context=body.context, ) if body.contextual_tuples: req_body.contextual_tuples = ContextualTupleKeys( @@ -628,7 +632,7 @@ async def list_relations(self, body: ClientListRelationsRequest, options: dict[s options = set_heading_if_not_set(options, CLIENT_BULK_REQUEST_ID_HEADER, str(uuid.uuid4())) request_body = [construct_check_request( - user=body.user, relation=i, object=body.object, contextual_tuples=body.contextual_tuples) for i in body.relations] + user=body.user, relation=i, object=body.object, contextual_tuples=body.contextual_tuples, context=body.context) for i in body.relations] result = await self.batch_check(request_body, options) # need to filter with the allowed response result_iterator = filter(_check_allowed, result) diff --git a/openfga_sdk/client/models/check_request.py b/openfga_sdk/client/models/check_request.py index 9a578999..b717e81a 100644 --- a/openfga_sdk/client/models/check_request.py +++ b/openfga_sdk/client/models/check_request.py @@ -16,11 +16,11 @@ from typing import List -def construct_check_request(user: str, relation: str, object: str, contextual_tuples: List[ClientTuple] = None): +def construct_check_request(user: str, relation: str, object: str, contextual_tuples: List[ClientTuple] = None, context: object = None): """ helper function to construct the check request body """ - return ClientCheckRequest(user, relation, object, contextual_tuples) + return ClientCheckRequest(user, relation, object, contextual_tuples, context) class ClientCheckRequest(): @@ -28,13 +28,14 @@ class ClientCheckRequest(): ClientCheckRequest encapsulates the parameters for check request """ - def __init__(self, user: str, relation: str, object: str, contextual_tuples: List[ClientTuple] = None): + def __init__(self, user: str, relation: str, object: str, contextual_tuples: List[ClientTuple] = None, context: object = None): self._user = user self._relation = relation self._object = object self._contextual_tuples = None if contextual_tuples: self._contextual_tuples = contextual_tuples + self._context = context @property def user(self): @@ -64,6 +65,13 @@ def contextual_tuples(self): """ return self._contextual_tuples + @property + def context(self): + """ + Return context + """ + return self._context + @user.setter def user(self, value): """ @@ -91,3 +99,10 @@ def contextual_tuples(self, value): Set contextual tuples """ self._contextual_tuples = value + + @context.setter + def context(self, value): + """ + Set context + """ + self._context = value diff --git a/openfga_sdk/client/models/list_objects_request.py b/openfga_sdk/client/models/list_objects_request.py index bd8b73f1..90fb1d32 100644 --- a/openfga_sdk/client/models/list_objects_request.py +++ b/openfga_sdk/client/models/list_objects_request.py @@ -21,11 +21,12 @@ class ClientListObjectsRequest(): ClientListObjectsRequest encapsulates the parameters required for list objects """ - def __init__(self, user: str, relation: str, type: str, contextual_tuples: List[ClientTuple] = None): + def __init__(self, user: str, relation: str, type: str, contextual_tuples: List[ClientTuple] = None, context: object = None): self._user = user self._relation = relation self._type = type self._contextual_tuples = contextual_tuples + self._context = context @property def user(self): @@ -55,6 +56,13 @@ def contextual_tuples(self): """ return self._contextual_tuples + @property + def context(self): + """ + Return context + """ + return self._context + @user.setter def user(self, value): """ @@ -82,3 +90,10 @@ def contextual_tuples(self, value): Set contextual tuples """ self._contextual_tuples = value + + @context.setter + def context(self, value): + """ + Set context + """ + self._context = value diff --git a/openfga_sdk/client/models/list_relations_request.py b/openfga_sdk/client/models/list_relations_request.py index 8e86671a..1372f8c5 100644 --- a/openfga_sdk/client/models/list_relations_request.py +++ b/openfga_sdk/client/models/list_relations_request.py @@ -10,7 +10,6 @@ NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. """ - from openfga_sdk.client.models.tuple import ClientTuple from typing import List @@ -21,11 +20,12 @@ class ClientListRelationsRequest(): ClientListRelationsRequest encapsulates the parameters required for list all relations user have with object """ - def __init__(self, user: str, relations: List[str], object: str, contextual_tuples: List[ClientTuple] = None): + def __init__(self, user: str, relations: List[str], object: str, contextual_tuples: List[ClientTuple] = None, context: object = None): self._user = user self._relations = relations self._object = object self._contextual_tuples = contextual_tuples + self._context = context @property def user(self): @@ -55,6 +55,13 @@ def contextual_tuples(self): """ return self._contextual_tuples + @property + def context(self): + """ + Return context + """ + return self._context + @user.setter def user(self, value): """ @@ -82,3 +89,10 @@ def contextual_tuples(self, value): Set contextual tuples """ self._contextual_tuples = value + + @context.setter + def context(self, value): + """ + Set context + """ + self._context = value diff --git a/openfga_sdk/client/models/tuple.py b/openfga_sdk/client/models/tuple.py index 5f465a5a..507d1eb4 100644 --- a/openfga_sdk/client/models/tuple.py +++ b/openfga_sdk/client/models/tuple.py @@ -11,6 +11,7 @@ NOTE: This file was auto generated by OpenAPI Generator (https://openapi-generator.tech). DO NOT EDIT. """ +from openfga_sdk.models.relationship_condition import RelationshipCondition from openfga_sdk.models.tuple_key import TupleKey from typing import List @@ -21,10 +22,11 @@ class ClientTuple(): ClientTuple encapsulates the client tuple """ - def __init__(self, user: str, relation: str, object: str): + def __init__(self, user: str, relation: str, object: str, condition: RelationshipCondition = None): self._user = user self._relation = relation self._object = object + self._condition = condition def __eq__(self, other): return self.user == other.user and self.relation == other.relation and self.object == other.object @@ -50,6 +52,13 @@ def object(self): """ return self._object + @property + def condition(self): + """ + Return condition + """ + return self._condition + @user.setter def user(self, value): """ @@ -71,6 +80,13 @@ def object(self, value): """ self._object = value + @condition.setter + def condition(self, value): + """ + Set condition + """ + self._condition = value + @property def tuple_key(self): """ @@ -80,6 +96,7 @@ def tuple_key(self): object=self.object, relation=self.relation, user=self.user, + condition=self.condition ) diff --git a/openfga_sdk/client/models/write_request.py b/openfga_sdk/client/models/write_request.py index 33ee7254..3b5f5e48 100644 --- a/openfga_sdk/client/models/write_request.py +++ b/openfga_sdk/client/models/write_request.py @@ -12,7 +12,8 @@ """ from openfga_sdk.client.models.tuple import ClientTuple, convert_tuple_keys -from openfga_sdk.models.tuple_keys import TupleKeys +from openfga_sdk.models.write_request_writes import WriteRequestWrites +from openfga_sdk.models.write_request_deletes import WriteRequestDeletes from typing import List @@ -62,7 +63,7 @@ def writes_tuple_keys(self): keys = convert_tuple_keys(self.writes) if keys is None: return None - return TupleKeys(tuple_keys=keys) + return WriteRequestWrites(tuple_keys=keys) @property def deletes_tuple_keys(self): @@ -72,4 +73,4 @@ def deletes_tuple_keys(self): keys = convert_tuple_keys(self.deletes) if keys is None: return None - return TupleKeys(tuple_keys=keys) + return WriteRequestDeletes(tuple_keys=keys) diff --git a/openfga_sdk/models/__init__.py b/openfga_sdk/models/__init__.py index a66778d4..84b4d2f0 100644 --- a/openfga_sdk/models/__init__.py +++ b/openfga_sdk/models/__init__.py @@ -14,18 +14,24 @@ """ # import models into model package +from openfga_sdk.models.aborted_message_response import AbortedMessageResponse from openfga_sdk.models.any import Any from openfga_sdk.models.assertion import Assertion +from openfga_sdk.models.assertion_tuple_key import AssertionTupleKey from openfga_sdk.models.authorization_model import AuthorizationModel from openfga_sdk.models.check_request import CheckRequest +from openfga_sdk.models.check_request_tuple_key import CheckRequestTupleKey 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_param_type_ref import ConditionParamTypeRef from openfga_sdk.models.contextual_tuple_keys import ContextualTupleKeys from openfga_sdk.models.create_store_request import CreateStoreRequest from openfga_sdk.models.create_store_response import CreateStoreResponse from openfga_sdk.models.difference import Difference from openfga_sdk.models.error_code import ErrorCode from openfga_sdk.models.expand_request import ExpandRequest +from openfga_sdk.models.expand_request_tuple_key import ExpandRequestTupleKey from openfga_sdk.models.expand_response import ExpandResponse from openfga_sdk.models.get_store_response import GetStoreResponse from openfga_sdk.models.internal_error_code import InternalErrorCode @@ -38,6 +44,7 @@ from openfga_sdk.models.node import Node from openfga_sdk.models.nodes import Nodes from openfga_sdk.models.not_found_error_code import NotFoundErrorCode +from openfga_sdk.models.null_value import NullValue from openfga_sdk.models.object_relation import ObjectRelation from openfga_sdk.models.path_unknown_error_message_response import PathUnknownErrorMessageResponse from openfga_sdk.models.read_assertions_response import ReadAssertionsResponse @@ -45,18 +52,21 @@ from openfga_sdk.models.read_authorization_models_response import ReadAuthorizationModelsResponse from openfga_sdk.models.read_changes_response import ReadChangesResponse from openfga_sdk.models.read_request import ReadRequest +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.read_response import ReadResponse 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.status import Status from openfga_sdk.models.store import Store from openfga_sdk.models.tuple import Tuple from openfga_sdk.models.tuple_change import TupleChange from openfga_sdk.models.tuple_key import TupleKey -from openfga_sdk.models.tuple_keys import TupleKeys +from openfga_sdk.models.tuple_key_without_condition import TupleKeyWithoutCondition from openfga_sdk.models.tuple_operation import TupleOperation from openfga_sdk.models.tuple_to_userset import TupleToUserset from openfga_sdk.models.type_definition import TypeDefinition +from openfga_sdk.models.type_name import TypeName from openfga_sdk.models.users import Users from openfga_sdk.models.userset import Userset from openfga_sdk.models.userset_tree import UsersetTree @@ -68,3 +78,5 @@ from openfga_sdk.models.write_authorization_model_request import WriteAuthorizationModelRequest from openfga_sdk.models.write_authorization_model_response import WriteAuthorizationModelResponse from openfga_sdk.models.write_request import WriteRequest +from openfga_sdk.models.write_request_deletes import WriteRequestDeletes +from openfga_sdk.models.write_request_writes import WriteRequestWrites diff --git a/openfga_sdk/models/aborted_message_response.py b/openfga_sdk/models/aborted_message_response.py new file mode 100644 index 00000000..6fbb5fae --- /dev/null +++ b/openfga_sdk/models/aborted_message_response.py @@ -0,0 +1,159 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class AbortedMessageResponse(object): + """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 = { + 'code': 'str', + 'message': 'str' + } + + attribute_map = { + 'code': 'code', + 'message': 'message' + } + + def __init__(self, code=None, message=None, local_vars_configuration=None): # noqa: E501 + """AbortedMessageResponse - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._code = None + self._message = None + self.discriminator = None + + if code is not None: + self.code = code + if message is not None: + self.message = message + + @property + def code(self): + """Gets the code of this AbortedMessageResponse. # noqa: E501 + + + :return: The code of this AbortedMessageResponse. # noqa: E501 + :rtype: str + """ + return self._code + + @code.setter + def code(self, code): + """Sets the code of this AbortedMessageResponse. + + + :param code: The code of this AbortedMessageResponse. # noqa: E501 + :type code: str + """ + + self._code = code + + @property + def message(self): + """Gets the message of this AbortedMessageResponse. # noqa: E501 + + + :return: The message of this AbortedMessageResponse. # noqa: E501 + :rtype: str + """ + return self._message + + @message.setter + def message(self, message): + """Sets the message of this AbortedMessageResponse. + + + :param message: The message of this AbortedMessageResponse. # noqa: E501 + :type message: str + """ + + self._message = message + + 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 six.iteritems(self.openapi_types): + 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, AbortedMessageResponse): + 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, AbortedMessageResponse): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/assertion.py b/openfga_sdk/models/assertion.py index ef001237..c5be11e4 100644 --- a/openfga_sdk/models/assertion.py +++ b/openfga_sdk/models/assertion.py @@ -38,7 +38,7 @@ class Assertion(object): and the value is json key in definition. """ openapi_types = { - 'tuple_key': 'TupleKey', + 'tuple_key': 'AssertionTupleKey', 'expectation': 'bool' } @@ -66,7 +66,7 @@ def tuple_key(self): :return: The tuple_key of this Assertion. # noqa: E501 - :rtype: TupleKey + :rtype: AssertionTupleKey """ return self._tuple_key @@ -76,7 +76,7 @@ def tuple_key(self, tuple_key): :param tuple_key: The tuple_key of this Assertion. # noqa: E501 - :type tuple_key: TupleKey + :type tuple_key: AssertionTupleKey """ if self.local_vars_configuration.client_side_validation and tuple_key is None: # noqa: E501 raise ValueError("Invalid value for `tuple_key`, must not be `None`") # noqa: E501 diff --git a/openfga_sdk/models/assertion_tuple_key.py b/openfga_sdk/models/assertion_tuple_key.py new file mode 100644 index 00000000..f9f05656 --- /dev/null +++ b/openfga_sdk/models/assertion_tuple_key.py @@ -0,0 +1,197 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class AssertionTupleKey(object): + """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 = { + 'object': 'str', + 'relation': 'str', + 'user': 'str' + } + + attribute_map = { + 'object': 'object', + 'relation': 'relation', + 'user': 'user' + } + + def __init__(self, object=None, relation=None, user=None, local_vars_configuration=None): # noqa: E501 + """AssertionTupleKey - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._object = None + self._relation = None + self._user = None + self.discriminator = None + + self.object = object + self.relation = relation + self.user = user + + @property + def object(self): + """Gets the object of this AssertionTupleKey. # noqa: E501 + + + :return: The object of this AssertionTupleKey. # noqa: E501 + :rtype: str + """ + return self._object + + @object.setter + def object(self, object): + """Sets the object of this AssertionTupleKey. + + + :param object: The object of this AssertionTupleKey. # noqa: E501 + :type object: str + """ + if self.local_vars_configuration.client_side_validation and object is None: # noqa: E501 + raise ValueError("Invalid value for `object`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + object is not None and len(object) > 256): + raise ValueError("Invalid value for `object`, length must be less than or equal to `256`") # noqa: E501 + + self._object = object + + @property + def relation(self): + """Gets the relation of this AssertionTupleKey. # noqa: E501 + + + :return: The relation of this AssertionTupleKey. # noqa: E501 + :rtype: str + """ + return self._relation + + @relation.setter + def relation(self, relation): + """Sets the relation of this AssertionTupleKey. + + + :param relation: The relation of this AssertionTupleKey. # noqa: E501 + :type relation: str + """ + if self.local_vars_configuration.client_side_validation and relation is None: # noqa: E501 + raise ValueError("Invalid value for `relation`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + relation is not None and len(relation) > 50): + raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501 + + self._relation = relation + + @property + def user(self): + """Gets the user of this AssertionTupleKey. # noqa: E501 + + + :return: The user of this AssertionTupleKey. # noqa: E501 + :rtype: str + """ + return self._user + + @user.setter + def user(self, user): + """Sets the user of this AssertionTupleKey. + + + :param user: The user of this AssertionTupleKey. # noqa: E501 + :type user: str + """ + if self.local_vars_configuration.client_side_validation and user is None: # noqa: E501 + raise ValueError("Invalid value for `user`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + user is not None and len(user) > 512): + raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501 + + self._user = user + + 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 six.iteritems(self.openapi_types): + 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, AssertionTupleKey): + 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, AssertionTupleKey): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/authorization_model.py b/openfga_sdk/models/authorization_model.py index 542e57aa..abc8804d 100644 --- a/openfga_sdk/models/authorization_model.py +++ b/openfga_sdk/models/authorization_model.py @@ -40,16 +40,18 @@ class AuthorizationModel(object): openapi_types = { 'id': 'str', 'schema_version': 'str', - 'type_definitions': 'list[TypeDefinition]' + 'type_definitions': 'list[TypeDefinition]', + 'conditions': 'dict[str, Condition]' } attribute_map = { 'id': 'id', 'schema_version': 'schema_version', - 'type_definitions': 'type_definitions' + 'type_definitions': 'type_definitions', + 'conditions': 'conditions' } - def __init__(self, id=None, schema_version=None, type_definitions=None, local_vars_configuration=None): # noqa: E501 + def __init__(self, id=None, schema_version=None, type_definitions=None, conditions=None, local_vars_configuration=None): # noqa: E501 """AuthorizationModel - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration.get_default_copy() @@ -58,13 +60,14 @@ def __init__(self, id=None, schema_version=None, type_definitions=None, local_va self._id = None self._schema_version = None self._type_definitions = None + self._conditions = None self.discriminator = None - if id is not None: - self.id = id + self.id = id self.schema_version = schema_version - if type_definitions is not None: - self.type_definitions = type_definitions + self.type_definitions = type_definitions + if conditions is not None: + self.conditions = conditions @property def id(self): @@ -84,6 +87,8 @@ def id(self, id): :param id: The id of this AuthorizationModel. # noqa: E501 :type id: str """ + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -128,9 +133,32 @@ def type_definitions(self, type_definitions): :param type_definitions: The type_definitions of this AuthorizationModel. # noqa: E501 :type type_definitions: list[TypeDefinition] """ + if self.local_vars_configuration.client_side_validation and type_definitions is None: # noqa: E501 + raise ValueError("Invalid value for `type_definitions`, must not be `None`") # noqa: E501 self._type_definitions = type_definitions + @property + def conditions(self): + """Gets the conditions of this AuthorizationModel. # noqa: E501 + + + :return: The conditions of this AuthorizationModel. # noqa: E501 + :rtype: dict[str, Condition] + """ + return self._conditions + + @conditions.setter + def conditions(self, conditions): + """Sets the conditions of this AuthorizationModel. + + + :param conditions: The conditions of this AuthorizationModel. # noqa: E501 + :type conditions: dict[str, Condition] + """ + + self._conditions = conditions + def to_dict(self, serialize=False): """Returns the model properties as a dict""" result = {} diff --git a/openfga_sdk/models/check_request.py b/openfga_sdk/models/check_request.py index 603a08b1..61c4fb4e 100644 --- a/openfga_sdk/models/check_request.py +++ b/openfga_sdk/models/check_request.py @@ -38,20 +38,22 @@ class CheckRequest(object): and the value is json key in definition. """ openapi_types = { - 'tuple_key': 'TupleKey', + 'tuple_key': 'CheckRequestTupleKey', 'contextual_tuples': 'ContextualTupleKeys', 'authorization_model_id': 'str', - 'trace': 'bool' + 'trace': 'bool', + 'context': 'object' } attribute_map = { 'tuple_key': 'tuple_key', 'contextual_tuples': 'contextual_tuples', 'authorization_model_id': 'authorization_model_id', - 'trace': 'trace' + 'trace': 'trace', + 'context': 'context' } - def __init__(self, tuple_key=None, contextual_tuples=None, authorization_model_id=None, trace=None, local_vars_configuration=None): # noqa: E501 + def __init__(self, tuple_key=None, contextual_tuples=None, authorization_model_id=None, trace=None, context=None, local_vars_configuration=None): # noqa: E501 """CheckRequest - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration.get_default_copy() @@ -61,6 +63,7 @@ def __init__(self, tuple_key=None, contextual_tuples=None, authorization_model_i self._contextual_tuples = None self._authorization_model_id = None self._trace = None + self._context = None self.discriminator = None self.tuple_key = tuple_key @@ -70,6 +73,8 @@ def __init__(self, tuple_key=None, contextual_tuples=None, authorization_model_i self.authorization_model_id = authorization_model_id if trace is not None: self.trace = trace + if context is not None: + self.context = context @property def tuple_key(self): @@ -77,7 +82,7 @@ def tuple_key(self): :return: The tuple_key of this CheckRequest. # noqa: E501 - :rtype: TupleKey + :rtype: CheckRequestTupleKey """ return self._tuple_key @@ -87,7 +92,7 @@ def tuple_key(self, tuple_key): :param tuple_key: The tuple_key of this CheckRequest. # noqa: E501 - :type tuple_key: TupleKey + :type tuple_key: CheckRequestTupleKey """ if self.local_vars_configuration.client_side_validation and tuple_key is None: # noqa: E501 raise ValueError("Invalid value for `tuple_key`, must not be `None`") # noqa: E501 @@ -159,6 +164,29 @@ def trace(self, trace): self._trace = trace + @property + def context(self): + """Gets the context of this CheckRequest. # noqa: E501 + + Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation. # noqa: E501 + + :return: The context of this CheckRequest. # noqa: E501 + :rtype: object + """ + return self._context + + @context.setter + def context(self, context): + """Sets the context of this CheckRequest. + + Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation. # noqa: E501 + + :param context: The context of this CheckRequest. # noqa: E501 + :type context: object + """ + + self._context = context + def to_dict(self, serialize=False): """Returns the model properties as a dict""" result = {} diff --git a/openfga_sdk/models/check_request_tuple_key.py b/openfga_sdk/models/check_request_tuple_key.py new file mode 100644 index 00000000..35d27128 --- /dev/null +++ b/openfga_sdk/models/check_request_tuple_key.py @@ -0,0 +1,197 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class CheckRequestTupleKey(object): + """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 = { + 'user': 'str', + 'relation': 'str', + 'object': 'str' + } + + attribute_map = { + 'user': 'user', + 'relation': 'relation', + 'object': 'object' + } + + def __init__(self, user=None, relation=None, object=None, local_vars_configuration=None): # noqa: E501 + """CheckRequestTupleKey - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._user = None + self._relation = None + self._object = None + self.discriminator = None + + self.user = user + self.relation = relation + self.object = object + + @property + def user(self): + """Gets the user of this CheckRequestTupleKey. # noqa: E501 + + + :return: The user of this CheckRequestTupleKey. # noqa: E501 + :rtype: str + """ + return self._user + + @user.setter + def user(self, user): + """Sets the user of this CheckRequestTupleKey. + + + :param user: The user of this CheckRequestTupleKey. # noqa: E501 + :type user: str + """ + if self.local_vars_configuration.client_side_validation and user is None: # noqa: E501 + raise ValueError("Invalid value for `user`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + user is not None and len(user) > 512): + raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501 + + self._user = user + + @property + def relation(self): + """Gets the relation of this CheckRequestTupleKey. # noqa: E501 + + + :return: The relation of this CheckRequestTupleKey. # noqa: E501 + :rtype: str + """ + return self._relation + + @relation.setter + def relation(self, relation): + """Sets the relation of this CheckRequestTupleKey. + + + :param relation: The relation of this CheckRequestTupleKey. # noqa: E501 + :type relation: str + """ + if self.local_vars_configuration.client_side_validation and relation is None: # noqa: E501 + raise ValueError("Invalid value for `relation`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + relation is not None and len(relation) > 50): + raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501 + + self._relation = relation + + @property + def object(self): + """Gets the object of this CheckRequestTupleKey. # noqa: E501 + + + :return: The object of this CheckRequestTupleKey. # noqa: E501 + :rtype: str + """ + return self._object + + @object.setter + def object(self, object): + """Sets the object of this CheckRequestTupleKey. + + + :param object: The object of this CheckRequestTupleKey. # noqa: E501 + :type object: str + """ + if self.local_vars_configuration.client_side_validation and object is None: # noqa: E501 + raise ValueError("Invalid value for `object`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + object is not None and len(object) > 256): + raise ValueError("Invalid value for `object`, length must be less than or equal to `256`") # noqa: E501 + + self._object = object + + 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 six.iteritems(self.openapi_types): + 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, CheckRequestTupleKey): + 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, CheckRequestTupleKey): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/computed.py b/openfga_sdk/models/computed.py index 6be75953..b7ae4448 100644 --- a/openfga_sdk/models/computed.py +++ b/openfga_sdk/models/computed.py @@ -54,8 +54,7 @@ def __init__(self, userset=None, local_vars_configuration=None): # noqa: E501 self._userset = None self.discriminator = None - if userset is not None: - self.userset = userset + self.userset = userset @property def userset(self): @@ -75,6 +74,8 @@ def userset(self, userset): :param userset: The userset of this Computed. # noqa: E501 :type userset: str """ + if self.local_vars_configuration.client_side_validation and userset is None: # noqa: E501 + raise ValueError("Invalid value for `userset`, must not be `None`") # noqa: E501 self._userset = userset diff --git a/openfga_sdk/models/condition.py b/openfga_sdk/models/condition.py new file mode 100644 index 00000000..156f373b --- /dev/null +++ b/openfga_sdk/models/condition.py @@ -0,0 +1,191 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class Condition(object): + """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 = { + 'name': 'str', + 'expression': 'str', + 'parameters': 'dict[str, ConditionParamTypeRef]' + } + + attribute_map = { + 'name': 'name', + 'expression': 'expression', + 'parameters': 'parameters' + } + + def __init__(self, name=None, expression=None, parameters=None, local_vars_configuration=None): # noqa: E501 + """Condition - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._name = None + self._expression = None + self._parameters = None + self.discriminator = None + + self.name = name + self.expression = expression + if parameters is not None: + self.parameters = parameters + + @property + def name(self): + """Gets the name of this Condition. # noqa: E501 + + + :return: The name of this Condition. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this Condition. + + + :param name: The name of this Condition. # noqa: E501 + :type name: str + """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + + self._name = name + + @property + def expression(self): + """Gets the expression of this Condition. # noqa: E501 + + A Google CEL expression, expressed as a string. # noqa: E501 + + :return: The expression of this Condition. # noqa: E501 + :rtype: str + """ + return self._expression + + @expression.setter + def expression(self, expression): + """Sets the expression of this Condition. + + A Google CEL expression, expressed as a string. # noqa: E501 + + :param expression: The expression of this Condition. # noqa: E501 + :type expression: str + """ + if self.local_vars_configuration.client_side_validation and expression is None: # noqa: E501 + raise ValueError("Invalid value for `expression`, must not be `None`") # noqa: E501 + + self._expression = expression + + @property + def parameters(self): + """Gets the parameters of this Condition. # noqa: E501 + + A map of parameter names to the parameter's defined type reference. # noqa: E501 + + :return: The parameters of this Condition. # noqa: E501 + :rtype: dict[str, ConditionParamTypeRef] + """ + return self._parameters + + @parameters.setter + def parameters(self, parameters): + """Sets the parameters of this Condition. + + A map of parameter names to the parameter's defined type reference. # noqa: E501 + + :param parameters: The parameters of this Condition. # noqa: E501 + :type parameters: dict[str, ConditionParamTypeRef] + """ + + self._parameters = parameters + + 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 six.iteritems(self.openapi_types): + 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, Condition): + 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, Condition): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/condition_param_type_ref.py b/openfga_sdk/models/condition_param_type_ref.py new file mode 100644 index 00000000..c589fd67 --- /dev/null +++ b/openfga_sdk/models/condition_param_type_ref.py @@ -0,0 +1,160 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class ConditionParamTypeRef(object): + """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 = { + 'type_name': 'TypeName', + 'generic_types': 'list[ConditionParamTypeRef]' + } + + attribute_map = { + 'type_name': 'type_name', + 'generic_types': 'generic_types' + } + + def __init__(self, type_name=None, generic_types=None, local_vars_configuration=None): # noqa: E501 + """ConditionParamTypeRef - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._type_name = None + self._generic_types = None + self.discriminator = None + + self.type_name = type_name + if generic_types is not None: + self.generic_types = generic_types + + @property + def type_name(self): + """Gets the type_name of this ConditionParamTypeRef. # noqa: E501 + + + :return: The type_name of this ConditionParamTypeRef. # noqa: E501 + :rtype: TypeName + """ + return self._type_name + + @type_name.setter + def type_name(self, type_name): + """Sets the type_name of this ConditionParamTypeRef. + + + :param type_name: The type_name of this ConditionParamTypeRef. # noqa: E501 + :type type_name: TypeName + """ + if self.local_vars_configuration.client_side_validation and type_name is None: # noqa: E501 + raise ValueError("Invalid value for `type_name`, must not be `None`") # noqa: E501 + + self._type_name = type_name + + @property + def generic_types(self): + """Gets the generic_types of this ConditionParamTypeRef. # noqa: E501 + + + :return: The generic_types of this ConditionParamTypeRef. # noqa: E501 + :rtype: list[ConditionParamTypeRef] + """ + return self._generic_types + + @generic_types.setter + def generic_types(self, generic_types): + """Sets the generic_types of this ConditionParamTypeRef. + + + :param generic_types: The generic_types of this ConditionParamTypeRef. # noqa: E501 + :type generic_types: list[ConditionParamTypeRef] + """ + + self._generic_types = generic_types + + 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 six.iteritems(self.openapi_types): + 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, ConditionParamTypeRef): + 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, ConditionParamTypeRef): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/create_store_response.py b/openfga_sdk/models/create_store_response.py index a16544d8..b1dd4e0a 100644 --- a/openfga_sdk/models/create_store_response.py +++ b/openfga_sdk/models/create_store_response.py @@ -63,14 +63,10 @@ def __init__(self, id=None, name=None, created_at=None, updated_at=None, local_v self._updated_at = None self.discriminator = None - if id is not None: - self.id = id - if name is not None: - self.name = name - if created_at is not None: - self.created_at = created_at - if updated_at is not None: - self.updated_at = updated_at + self.id = id + self.name = name + self.created_at = created_at + self.updated_at = updated_at @property def id(self): @@ -90,6 +86,8 @@ def id(self, id): :param id: The id of this CreateStoreResponse. # noqa: E501 :type id: str """ + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -111,6 +109,8 @@ def name(self, name): :param name: The name of this CreateStoreResponse. # noqa: E501 :type name: str """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = name @@ -132,6 +132,8 @@ def created_at(self, created_at): :param created_at: The created_at of this CreateStoreResponse. # noqa: E501 :type created_at: datetime """ + if self.local_vars_configuration.client_side_validation and created_at is None: # noqa: E501 + raise ValueError("Invalid value for `created_at`, must not be `None`") # noqa: E501 self._created_at = created_at @@ -153,6 +155,8 @@ def updated_at(self, updated_at): :param updated_at: The updated_at of this CreateStoreResponse. # noqa: E501 :type updated_at: datetime """ + if self.local_vars_configuration.client_side_validation and updated_at is None: # noqa: E501 + raise ValueError("Invalid value for `updated_at`, must not be `None`") # noqa: E501 self._updated_at = updated_at diff --git a/openfga_sdk/models/expand_request.py b/openfga_sdk/models/expand_request.py index 0a871601..58135878 100644 --- a/openfga_sdk/models/expand_request.py +++ b/openfga_sdk/models/expand_request.py @@ -38,7 +38,7 @@ class ExpandRequest(object): and the value is json key in definition. """ openapi_types = { - 'tuple_key': 'TupleKey', + 'tuple_key': 'ExpandRequestTupleKey', 'authorization_model_id': 'str' } @@ -67,7 +67,7 @@ def tuple_key(self): :return: The tuple_key of this ExpandRequest. # noqa: E501 - :rtype: TupleKey + :rtype: ExpandRequestTupleKey """ return self._tuple_key @@ -77,7 +77,7 @@ def tuple_key(self, tuple_key): :param tuple_key: The tuple_key of this ExpandRequest. # noqa: E501 - :type tuple_key: TupleKey + :type tuple_key: ExpandRequestTupleKey """ if self.local_vars_configuration.client_side_validation and tuple_key is None: # noqa: E501 raise ValueError("Invalid value for `tuple_key`, must not be `None`") # noqa: E501 diff --git a/openfga_sdk/models/expand_request_tuple_key.py b/openfga_sdk/models/expand_request_tuple_key.py new file mode 100644 index 00000000..a37227a8 --- /dev/null +++ b/openfga_sdk/models/expand_request_tuple_key.py @@ -0,0 +1,167 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class ExpandRequestTupleKey(object): + """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 = { + 'relation': 'str', + 'object': 'str' + } + + attribute_map = { + 'relation': 'relation', + 'object': 'object' + } + + def __init__(self, relation=None, object=None, local_vars_configuration=None): # noqa: E501 + """ExpandRequestTupleKey - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._relation = None + self._object = None + self.discriminator = None + + self.relation = relation + self.object = object + + @property + def relation(self): + """Gets the relation of this ExpandRequestTupleKey. # noqa: E501 + + + :return: The relation of this ExpandRequestTupleKey. # noqa: E501 + :rtype: str + """ + return self._relation + + @relation.setter + def relation(self, relation): + """Sets the relation of this ExpandRequestTupleKey. + + + :param relation: The relation of this ExpandRequestTupleKey. # noqa: E501 + :type relation: str + """ + if self.local_vars_configuration.client_side_validation and relation is None: # noqa: E501 + raise ValueError("Invalid value for `relation`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + relation is not None and len(relation) > 50): + raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501 + + self._relation = relation + + @property + def object(self): + """Gets the object of this ExpandRequestTupleKey. # noqa: E501 + + + :return: The object of this ExpandRequestTupleKey. # noqa: E501 + :rtype: str + """ + return self._object + + @object.setter + def object(self, object): + """Sets the object of this ExpandRequestTupleKey. + + + :param object: The object of this ExpandRequestTupleKey. # noqa: E501 + :type object: str + """ + if self.local_vars_configuration.client_side_validation and object is None: # noqa: E501 + raise ValueError("Invalid value for `object`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + object is not None and len(object) > 256): + raise ValueError("Invalid value for `object`, length must be less than or equal to `256`") # noqa: E501 + + self._object = object + + 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 six.iteritems(self.openapi_types): + 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, ExpandRequestTupleKey): + 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, ExpandRequestTupleKey): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/get_store_response.py b/openfga_sdk/models/get_store_response.py index fa21498c..b82d2540 100644 --- a/openfga_sdk/models/get_store_response.py +++ b/openfga_sdk/models/get_store_response.py @@ -41,17 +41,19 @@ class GetStoreResponse(object): 'id': 'str', 'name': 'str', 'created_at': 'datetime', - 'updated_at': 'datetime' + 'updated_at': 'datetime', + 'deleted_at': 'datetime' } attribute_map = { 'id': 'id', 'name': 'name', 'created_at': 'created_at', - 'updated_at': 'updated_at' + 'updated_at': 'updated_at', + 'deleted_at': 'deleted_at' } - def __init__(self, id=None, name=None, created_at=None, updated_at=None, local_vars_configuration=None): # noqa: E501 + def __init__(self, id=None, name=None, created_at=None, updated_at=None, deleted_at=None, local_vars_configuration=None): # noqa: E501 """GetStoreResponse - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration.get_default_copy() @@ -61,16 +63,15 @@ def __init__(self, id=None, name=None, created_at=None, updated_at=None, local_v self._name = None self._created_at = None self._updated_at = None + self._deleted_at = None self.discriminator = None - if id is not None: - self.id = id - if name is not None: - self.name = name - if created_at is not None: - self.created_at = created_at - if updated_at is not None: - self.updated_at = updated_at + self.id = id + self.name = name + self.created_at = created_at + self.updated_at = updated_at + if deleted_at is not None: + self.deleted_at = deleted_at @property def id(self): @@ -90,6 +91,8 @@ def id(self, id): :param id: The id of this GetStoreResponse. # noqa: E501 :type id: str """ + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -111,6 +114,8 @@ def name(self, name): :param name: The name of this GetStoreResponse. # noqa: E501 :type name: str """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = name @@ -132,6 +137,8 @@ def created_at(self, created_at): :param created_at: The created_at of this GetStoreResponse. # noqa: E501 :type created_at: datetime """ + if self.local_vars_configuration.client_side_validation and created_at is None: # noqa: E501 + raise ValueError("Invalid value for `created_at`, must not be `None`") # noqa: E501 self._created_at = created_at @@ -153,9 +160,32 @@ def updated_at(self, updated_at): :param updated_at: The updated_at of this GetStoreResponse. # noqa: E501 :type updated_at: datetime """ + if self.local_vars_configuration.client_side_validation and updated_at is None: # noqa: E501 + raise ValueError("Invalid value for `updated_at`, must not be `None`") # noqa: E501 self._updated_at = updated_at + @property + def deleted_at(self): + """Gets the deleted_at of this GetStoreResponse. # noqa: E501 + + + :return: The deleted_at of this GetStoreResponse. # noqa: E501 + :rtype: datetime + """ + return self._deleted_at + + @deleted_at.setter + def deleted_at(self, deleted_at): + """Sets the deleted_at of this GetStoreResponse. + + + :param deleted_at: The deleted_at of this GetStoreResponse. # noqa: E501 + :type deleted_at: datetime + """ + + self._deleted_at = deleted_at + def to_dict(self, serialize=False): """Returns the model properties as a dict""" result = {} diff --git a/openfga_sdk/models/list_objects_request.py b/openfga_sdk/models/list_objects_request.py index ef5ddc4c..8ef3fe91 100644 --- a/openfga_sdk/models/list_objects_request.py +++ b/openfga_sdk/models/list_objects_request.py @@ -42,7 +42,8 @@ class ListObjectsRequest(object): 'type': 'str', 'relation': 'str', 'user': 'str', - 'contextual_tuples': 'ContextualTupleKeys' + 'contextual_tuples': 'ContextualTupleKeys', + 'context': 'object' } attribute_map = { @@ -50,10 +51,11 @@ class ListObjectsRequest(object): 'type': 'type', 'relation': 'relation', 'user': 'user', - 'contextual_tuples': 'contextual_tuples' + 'contextual_tuples': 'contextual_tuples', + 'context': 'context' } - def __init__(self, authorization_model_id=None, type=None, relation=None, user=None, contextual_tuples=None, local_vars_configuration=None): # noqa: E501 + def __init__(self, authorization_model_id=None, type=None, relation=None, user=None, contextual_tuples=None, context=None, local_vars_configuration=None): # noqa: E501 """ListObjectsRequest - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration.get_default_copy() @@ -64,6 +66,7 @@ def __init__(self, authorization_model_id=None, type=None, relation=None, user=N self._relation = None self._user = None self._contextual_tuples = None + self._context = None self.discriminator = None if authorization_model_id is not None: @@ -73,6 +76,8 @@ def __init__(self, authorization_model_id=None, type=None, relation=None, user=N self.user = user if contextual_tuples is not None: self.contextual_tuples = contextual_tuples + if context is not None: + self.context = context @property def authorization_model_id(self): @@ -191,6 +196,29 @@ def contextual_tuples(self, contextual_tuples): self._contextual_tuples = contextual_tuples + @property + def context(self): + """Gets the context of this ListObjectsRequest. # noqa: E501 + + Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation. # noqa: E501 + + :return: The context of this ListObjectsRequest. # noqa: E501 + :rtype: object + """ + return self._context + + @context.setter + def context(self, context): + """Sets the context of this ListObjectsRequest. + + Additional request context that will be used to evaluate any ABAC conditions encountered in the query evaluation. # noqa: E501 + + :param context: The context of this ListObjectsRequest. # noqa: E501 + :type context: object + """ + + self._context = context + def to_dict(self, serialize=False): """Returns the model properties as a dict""" result = {} diff --git a/openfga_sdk/models/list_objects_response.py b/openfga_sdk/models/list_objects_response.py index 36a2a08c..52d55437 100644 --- a/openfga_sdk/models/list_objects_response.py +++ b/openfga_sdk/models/list_objects_response.py @@ -54,8 +54,7 @@ def __init__(self, objects=None, local_vars_configuration=None): # noqa: E501 self._objects = None self.discriminator = None - if objects is not None: - self.objects = objects + self.objects = objects @property def objects(self): @@ -75,6 +74,8 @@ def objects(self, objects): :param objects: The objects of this ListObjectsResponse. # noqa: E501 :type objects: list[str] """ + if self.local_vars_configuration.client_side_validation and objects is None: # noqa: E501 + raise ValueError("Invalid value for `objects`, must not be `None`") # noqa: E501 self._objects = objects diff --git a/openfga_sdk/models/list_stores_response.py b/openfga_sdk/models/list_stores_response.py index fb5c00cf..94814123 100644 --- a/openfga_sdk/models/list_stores_response.py +++ b/openfga_sdk/models/list_stores_response.py @@ -57,10 +57,8 @@ def __init__(self, stores=None, continuation_token=None, local_vars_configuratio self._continuation_token = None self.discriminator = None - if stores is not None: - self.stores = stores - if continuation_token is not None: - self.continuation_token = continuation_token + self.stores = stores + self.continuation_token = continuation_token @property def stores(self): @@ -80,6 +78,8 @@ def stores(self, stores): :param stores: The stores of this ListStoresResponse. # noqa: E501 :type stores: list[Store] """ + if self.local_vars_configuration.client_side_validation and stores is None: # noqa: E501 + raise ValueError("Invalid value for `stores`, must not be `None`") # noqa: E501 self._stores = stores @@ -103,6 +103,8 @@ def continuation_token(self, continuation_token): :param continuation_token: The continuation_token of this ListStoresResponse. # noqa: E501 :type continuation_token: str """ + if self.local_vars_configuration.client_side_validation and continuation_token is None: # noqa: E501 + raise ValueError("Invalid value for `continuation_token`, must not be `None`") # noqa: E501 self._continuation_token = continuation_token diff --git a/openfga_sdk/models/node.py b/openfga_sdk/models/node.py index f43640f5..60cc8740 100644 --- a/openfga_sdk/models/node.py +++ b/openfga_sdk/models/node.py @@ -66,8 +66,7 @@ def __init__(self, name=None, leaf=None, difference=None, union=None, intersecti self._intersection = None self.discriminator = None - if name is not None: - self.name = name + self.name = name if leaf is not None: self.leaf = leaf if difference is not None: @@ -95,6 +94,8 @@ def name(self, name): :param name: The name of this Node. # noqa: E501 :type name: str """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = name diff --git a/openfga_sdk/models/nodes.py b/openfga_sdk/models/nodes.py index 2049eb97..d9d1f408 100644 --- a/openfga_sdk/models/nodes.py +++ b/openfga_sdk/models/nodes.py @@ -54,8 +54,7 @@ def __init__(self, nodes=None, local_vars_configuration=None): # noqa: E501 self._nodes = None self.discriminator = None - if nodes is not None: - self.nodes = nodes + self.nodes = nodes @property def nodes(self): @@ -75,6 +74,8 @@ def nodes(self, nodes): :param nodes: The nodes of this Nodes. # noqa: E501 :type nodes: list[Node] """ + if self.local_vars_configuration.client_side_validation and nodes is None: # noqa: E501 + raise ValueError("Invalid value for `nodes`, must not be `None`") # noqa: E501 self._nodes = nodes diff --git a/openfga_sdk/models/null_value.py b/openfga_sdk/models/null_value.py new file mode 100644 index 00000000..e8e58f5b --- /dev/null +++ b/openfga_sdk/models/null_value.py @@ -0,0 +1,112 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class NullValue(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + allowed enum values + """ + NULL_VALUE = "NULL_VALUE" + + allowable_values = [NULL_VALUE] # noqa: E501 + + """ + 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 = { + } + + attribute_map = { + } + + def __init__(self, local_vars_configuration=None): # noqa: E501 + """NullValue - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + self.discriminator = None + + 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 six.iteritems(self.openapi_types): + 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, NullValue): + 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, NullValue): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/read_assertions_response.py b/openfga_sdk/models/read_assertions_response.py index 005f5dd8..67cf87aa 100644 --- a/openfga_sdk/models/read_assertions_response.py +++ b/openfga_sdk/models/read_assertions_response.py @@ -57,8 +57,7 @@ def __init__(self, authorization_model_id=None, assertions=None, local_vars_conf self._assertions = None self.discriminator = None - if authorization_model_id is not None: - self.authorization_model_id = authorization_model_id + self.authorization_model_id = authorization_model_id if assertions is not None: self.assertions = assertions @@ -80,6 +79,8 @@ def authorization_model_id(self, authorization_model_id): :param authorization_model_id: The authorization_model_id of this ReadAssertionsResponse. # noqa: E501 :type authorization_model_id: str """ + if self.local_vars_configuration.client_side_validation and authorization_model_id is None: # noqa: E501 + raise ValueError("Invalid value for `authorization_model_id`, must not be `None`") # noqa: E501 self._authorization_model_id = authorization_model_id diff --git a/openfga_sdk/models/read_authorization_models_response.py b/openfga_sdk/models/read_authorization_models_response.py index e1914b4e..57bbda5d 100644 --- a/openfga_sdk/models/read_authorization_models_response.py +++ b/openfga_sdk/models/read_authorization_models_response.py @@ -57,8 +57,7 @@ def __init__(self, authorization_models=None, continuation_token=None, local_var self._continuation_token = None self.discriminator = None - if authorization_models is not None: - self.authorization_models = authorization_models + self.authorization_models = authorization_models if continuation_token is not None: self.continuation_token = continuation_token @@ -80,6 +79,8 @@ def authorization_models(self, authorization_models): :param authorization_models: The authorization_models of this ReadAuthorizationModelsResponse. # noqa: E501 :type authorization_models: list[AuthorizationModel] """ + if self.local_vars_configuration.client_side_validation and authorization_models is None: # noqa: E501 + raise ValueError("Invalid value for `authorization_models`, must not be `None`") # noqa: E501 self._authorization_models = authorization_models diff --git a/openfga_sdk/models/read_changes_response.py b/openfga_sdk/models/read_changes_response.py index 5bcfc1ce..03dd42fd 100644 --- a/openfga_sdk/models/read_changes_response.py +++ b/openfga_sdk/models/read_changes_response.py @@ -57,8 +57,7 @@ def __init__(self, changes=None, continuation_token=None, local_vars_configurati self._continuation_token = None self.discriminator = None - if changes is not None: - self.changes = changes + self.changes = changes if continuation_token is not None: self.continuation_token = continuation_token @@ -80,6 +79,8 @@ def changes(self, changes): :param changes: The changes of this ReadChangesResponse. # noqa: E501 :type changes: list[TupleChange] """ + if self.local_vars_configuration.client_side_validation and changes is None: # noqa: E501 + raise ValueError("Invalid value for `changes`, must not be `None`") # noqa: E501 self._changes = changes diff --git a/openfga_sdk/models/read_request.py b/openfga_sdk/models/read_request.py index f5037778..357b76dd 100644 --- a/openfga_sdk/models/read_request.py +++ b/openfga_sdk/models/read_request.py @@ -38,7 +38,7 @@ class ReadRequest(object): and the value is json key in definition. """ openapi_types = { - 'tuple_key': 'TupleKey', + 'tuple_key': 'ReadRequestTupleKey', 'page_size': 'int', 'continuation_token': 'str' } @@ -73,7 +73,7 @@ def tuple_key(self): :return: The tuple_key of this ReadRequest. # noqa: E501 - :rtype: TupleKey + :rtype: ReadRequestTupleKey """ return self._tuple_key @@ -83,7 +83,7 @@ def tuple_key(self, tuple_key): :param tuple_key: The tuple_key of this ReadRequest. # noqa: E501 - :type tuple_key: TupleKey + :type tuple_key: ReadRequestTupleKey """ self._tuple_key = tuple_key diff --git a/openfga_sdk/models/read_request_tuple_key.py b/openfga_sdk/models/read_request_tuple_key.py new file mode 100644 index 00000000..54d3c11d --- /dev/null +++ b/openfga_sdk/models/read_request_tuple_key.py @@ -0,0 +1,194 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class ReadRequestTupleKey(object): + """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 = { + 'user': 'str', + 'relation': 'str', + 'object': 'str' + } + + attribute_map = { + 'user': 'user', + 'relation': 'relation', + 'object': 'object' + } + + def __init__(self, user=None, relation=None, object=None, local_vars_configuration=None): # noqa: E501 + """ReadRequestTupleKey - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._user = None + self._relation = None + self._object = None + self.discriminator = None + + if user is not None: + self.user = user + if relation is not None: + self.relation = relation + if object is not None: + self.object = object + + @property + def user(self): + """Gets the user of this ReadRequestTupleKey. # noqa: E501 + + + :return: The user of this ReadRequestTupleKey. # noqa: E501 + :rtype: str + """ + return self._user + + @user.setter + def user(self, user): + """Sets the user of this ReadRequestTupleKey. + + + :param user: The user of this ReadRequestTupleKey. # noqa: E501 + :type user: str + """ + if (self.local_vars_configuration.client_side_validation and + user is not None and len(user) > 512): + raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501 + + self._user = user + + @property + def relation(self): + """Gets the relation of this ReadRequestTupleKey. # noqa: E501 + + + :return: The relation of this ReadRequestTupleKey. # noqa: E501 + :rtype: str + """ + return self._relation + + @relation.setter + def relation(self, relation): + """Sets the relation of this ReadRequestTupleKey. + + + :param relation: The relation of this ReadRequestTupleKey. # noqa: E501 + :type relation: str + """ + if (self.local_vars_configuration.client_side_validation and + relation is not None and len(relation) > 50): + raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501 + + self._relation = relation + + @property + def object(self): + """Gets the object of this ReadRequestTupleKey. # noqa: E501 + + + :return: The object of this ReadRequestTupleKey. # noqa: E501 + :rtype: str + """ + return self._object + + @object.setter + def object(self, object): + """Sets the object of this ReadRequestTupleKey. + + + :param object: The object of this ReadRequestTupleKey. # noqa: E501 + :type object: str + """ + if (self.local_vars_configuration.client_side_validation and + object is not None and len(object) > 256): + raise ValueError("Invalid value for `object`, length must be less than or equal to `256`") # noqa: E501 + + self._object = object + + 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 six.iteritems(self.openapi_types): + 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, ReadRequestTupleKey): + 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, ReadRequestTupleKey): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/read_response.py b/openfga_sdk/models/read_response.py index 36d0695f..bb3bc81d 100644 --- a/openfga_sdk/models/read_response.py +++ b/openfga_sdk/models/read_response.py @@ -57,10 +57,8 @@ def __init__(self, tuples=None, continuation_token=None, local_vars_configuratio self._continuation_token = None self.discriminator = None - if tuples is not None: - self.tuples = tuples - if continuation_token is not None: - self.continuation_token = continuation_token + self.tuples = tuples + self.continuation_token = continuation_token @property def tuples(self): @@ -80,6 +78,8 @@ def tuples(self, tuples): :param tuples: The tuples of this ReadResponse. # noqa: E501 :type tuples: list[Tuple] """ + if self.local_vars_configuration.client_side_validation and tuples is None: # noqa: E501 + raise ValueError("Invalid value for `tuples`, must not be `None`") # noqa: E501 self._tuples = tuples @@ -103,6 +103,8 @@ def continuation_token(self, continuation_token): :param continuation_token: The continuation_token of this ReadResponse. # noqa: E501 :type continuation_token: str """ + if self.local_vars_configuration.client_side_validation and continuation_token is None: # noqa: E501 + raise ValueError("Invalid value for `continuation_token`, must not be `None`") # noqa: E501 self._continuation_token = continuation_token diff --git a/openfga_sdk/models/relation_reference.py b/openfga_sdk/models/relation_reference.py index 91b8dfda..2bcc4eda 100644 --- a/openfga_sdk/models/relation_reference.py +++ b/openfga_sdk/models/relation_reference.py @@ -40,16 +40,18 @@ class RelationReference(object): openapi_types = { 'type': 'str', 'relation': 'str', - 'wildcard': 'object' + 'wildcard': 'object', + 'condition': 'str' } attribute_map = { 'type': 'type', 'relation': 'relation', - 'wildcard': 'wildcard' + 'wildcard': 'wildcard', + 'condition': 'condition' } - def __init__(self, type=None, relation=None, wildcard=None, local_vars_configuration=None): # noqa: E501 + def __init__(self, type=None, relation=None, wildcard=None, condition=None, local_vars_configuration=None): # noqa: E501 """RelationReference - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration.get_default_copy() @@ -58,6 +60,7 @@ def __init__(self, type=None, relation=None, wildcard=None, local_vars_configura self._type = None self._relation = None self._wildcard = None + self._condition = None self.discriminator = None self.type = type @@ -65,6 +68,8 @@ def __init__(self, type=None, relation=None, wildcard=None, local_vars_configura self.relation = relation if wildcard is not None: self.wildcard = wildcard + if condition is not None: + self.condition = condition @property def type(self): @@ -131,6 +136,29 @@ def wildcard(self, wildcard): self._wildcard = wildcard + @property + def condition(self): + """Gets the condition of this RelationReference. # noqa: E501 + + The name of a condition that is enforced over the allowed relation. # noqa: E501 + + :return: The condition of this RelationReference. # noqa: E501 + :rtype: str + """ + return self._condition + + @condition.setter + def condition(self, condition): + """Sets the condition of this RelationReference. + + The name of a condition that is enforced over the allowed relation. # noqa: E501 + + :param condition: The condition of this RelationReference. # noqa: E501 + :type condition: str + """ + + self._condition = condition + def to_dict(self, serialize=False): """Returns the model properties as a dict""" result = {} diff --git a/openfga_sdk/models/relationship_condition.py b/openfga_sdk/models/relationship_condition.py new file mode 100644 index 00000000..4bbc7794 --- /dev/null +++ b/openfga_sdk/models/relationship_condition.py @@ -0,0 +1,167 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class RelationshipCondition(object): + """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 = { + 'name': 'str', + 'context': 'object' + } + + attribute_map = { + 'name': 'name', + 'context': 'context' + } + + def __init__(self, name=None, context=None, local_vars_configuration=None): # noqa: E501 + """RelationshipCondition - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._name = None + self._context = None + self.discriminator = None + + self.name = name + if context is not None: + self.context = context + + @property + def name(self): + """Gets the name of this RelationshipCondition. # noqa: E501 + + A reference (by name) of the relationship condition defined in the authorization model. # noqa: E501 + + :return: The name of this RelationshipCondition. # noqa: E501 + :rtype: str + """ + return self._name + + @name.setter + def name(self, name): + """Sets the name of this RelationshipCondition. + + A reference (by name) of the relationship condition defined in the authorization model. # noqa: E501 + + :param name: The name of this RelationshipCondition. # noqa: E501 + :type name: str + """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + name is not None and len(name) > 256): + raise ValueError("Invalid value for `name`, length must be less than or equal to `256`") # noqa: E501 + + self._name = name + + @property + def context(self): + """Gets the context of this RelationshipCondition. # noqa: E501 + + Additional context/data to persist along with the condition. The keys must match the parameters defined by the condition, and the value types must match the parameter type definitions. # noqa: E501 + + :return: The context of this RelationshipCondition. # noqa: E501 + :rtype: object + """ + return self._context + + @context.setter + def context(self, context): + """Sets the context of this RelationshipCondition. + + Additional context/data to persist along with the condition. The keys must match the parameters defined by the condition, and the value types must match the parameter type definitions. # noqa: E501 + + :param context: The context of this RelationshipCondition. # noqa: E501 + :type context: object + """ + + self._context = context + + 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 six.iteritems(self.openapi_types): + 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, RelationshipCondition): + 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, RelationshipCondition): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/store.py b/openfga_sdk/models/store.py index 02e6595b..3536f768 100644 --- a/openfga_sdk/models/store.py +++ b/openfga_sdk/models/store.py @@ -66,14 +66,10 @@ def __init__(self, id=None, name=None, created_at=None, updated_at=None, deleted self._deleted_at = None self.discriminator = None - if id is not None: - self.id = id - if name is not None: - self.name = name - if created_at is not None: - self.created_at = created_at - if updated_at is not None: - self.updated_at = updated_at + self.id = id + self.name = name + self.created_at = created_at + self.updated_at = updated_at if deleted_at is not None: self.deleted_at = deleted_at @@ -95,6 +91,8 @@ def id(self, id): :param id: The id of this Store. # noqa: E501 :type id: str """ + if self.local_vars_configuration.client_side_validation and id is None: # noqa: E501 + raise ValueError("Invalid value for `id`, must not be `None`") # noqa: E501 self._id = id @@ -116,6 +114,8 @@ def name(self, name): :param name: The name of this Store. # noqa: E501 :type name: str """ + if self.local_vars_configuration.client_side_validation and name is None: # noqa: E501 + raise ValueError("Invalid value for `name`, must not be `None`") # noqa: E501 self._name = name @@ -137,6 +137,8 @@ def created_at(self, created_at): :param created_at: The created_at of this Store. # noqa: E501 :type created_at: datetime """ + if self.local_vars_configuration.client_side_validation and created_at is None: # noqa: E501 + raise ValueError("Invalid value for `created_at`, must not be `None`") # noqa: E501 self._created_at = created_at @@ -158,6 +160,8 @@ def updated_at(self, updated_at): :param updated_at: The updated_at of this Store. # noqa: E501 :type updated_at: datetime """ + if self.local_vars_configuration.client_side_validation and updated_at is None: # noqa: E501 + raise ValueError("Invalid value for `updated_at`, must not be `None`") # noqa: E501 self._updated_at = updated_at diff --git a/openfga_sdk/models/tuple.py b/openfga_sdk/models/tuple.py index 3bf137d3..90327851 100644 --- a/openfga_sdk/models/tuple.py +++ b/openfga_sdk/models/tuple.py @@ -57,10 +57,8 @@ def __init__(self, key=None, timestamp=None, local_vars_configuration=None): # self._timestamp = None self.discriminator = None - if key is not None: - self.key = key - if timestamp is not None: - self.timestamp = timestamp + self.key = key + self.timestamp = timestamp @property def key(self): @@ -80,6 +78,8 @@ def key(self, key): :param key: The key of this Tuple. # noqa: E501 :type key: TupleKey """ + if self.local_vars_configuration.client_side_validation and key is None: # noqa: E501 + raise ValueError("Invalid value for `key`, must not be `None`") # noqa: E501 self._key = key @@ -101,6 +101,8 @@ def timestamp(self, timestamp): :param timestamp: The timestamp of this Tuple. # noqa: E501 :type timestamp: datetime """ + if self.local_vars_configuration.client_side_validation and timestamp is None: # noqa: E501 + raise ValueError("Invalid value for `timestamp`, must not be `None`") # noqa: E501 self._timestamp = timestamp diff --git a/openfga_sdk/models/tuple_change.py b/openfga_sdk/models/tuple_change.py index 3c3af320..c32919ed 100644 --- a/openfga_sdk/models/tuple_change.py +++ b/openfga_sdk/models/tuple_change.py @@ -60,12 +60,9 @@ def __init__(self, tuple_key=None, operation=None, timestamp=None, local_vars_co self._timestamp = None self.discriminator = None - if tuple_key is not None: - self.tuple_key = tuple_key - if operation is not None: - self.operation = operation - if timestamp is not None: - self.timestamp = timestamp + self.tuple_key = tuple_key + self.operation = operation + self.timestamp = timestamp @property def tuple_key(self): @@ -85,6 +82,8 @@ def tuple_key(self, tuple_key): :param tuple_key: The tuple_key of this TupleChange. # noqa: E501 :type tuple_key: TupleKey """ + if self.local_vars_configuration.client_side_validation and tuple_key is None: # noqa: E501 + raise ValueError("Invalid value for `tuple_key`, must not be `None`") # noqa: E501 self._tuple_key = tuple_key @@ -106,6 +105,8 @@ def operation(self, operation): :param operation: The operation of this TupleChange. # noqa: E501 :type operation: TupleOperation """ + if self.local_vars_configuration.client_side_validation and operation is None: # noqa: E501 + raise ValueError("Invalid value for `operation`, must not be `None`") # noqa: E501 self._operation = operation @@ -127,6 +128,8 @@ def timestamp(self, timestamp): :param timestamp: The timestamp of this TupleChange. # noqa: E501 :type timestamp: datetime """ + if self.local_vars_configuration.client_side_validation and timestamp is None: # noqa: E501 + raise ValueError("Invalid value for `timestamp`, must not be `None`") # noqa: E501 self._timestamp = timestamp diff --git a/openfga_sdk/models/tuple_key.py b/openfga_sdk/models/tuple_key.py index e51937cc..01d51b39 100644 --- a/openfga_sdk/models/tuple_key.py +++ b/openfga_sdk/models/tuple_key.py @@ -38,58 +38,62 @@ class TupleKey(object): and the value is json key in definition. """ openapi_types = { - 'object': 'str', + 'user': 'str', 'relation': 'str', - 'user': 'str' + 'object': 'str', + 'condition': 'RelationshipCondition' } attribute_map = { - 'object': 'object', + 'user': 'user', 'relation': 'relation', - 'user': 'user' + 'object': 'object', + 'condition': 'condition' } - def __init__(self, object=None, relation=None, user=None, local_vars_configuration=None): # noqa: E501 + def __init__(self, user=None, relation=None, object=None, condition=None, local_vars_configuration=None): # noqa: E501 """TupleKey - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration.get_default_copy() self.local_vars_configuration = local_vars_configuration - self._object = None - self._relation = None self._user = None + self._relation = None + self._object = None + self._condition = None self.discriminator = None - if object is not None: - self.object = object - if relation is not None: - self.relation = relation - if user is not None: - self.user = user + self.user = user + self.relation = relation + self.object = object + if condition is not None: + self.condition = condition @property - def object(self): - """Gets the object of this TupleKey. # noqa: E501 + def user(self): + """Gets the user of this TupleKey. # noqa: E501 - :return: The object of this TupleKey. # noqa: E501 + :return: The user of this TupleKey. # noqa: E501 :rtype: str """ - return self._object + return self._user - @object.setter - def object(self, object): - """Sets the object of this TupleKey. + @user.setter + def user(self, user): + """Sets the user of this TupleKey. - :param object: The object of this TupleKey. # noqa: E501 - :type object: str + :param user: The user of this TupleKey. # noqa: E501 + :type user: str """ + if self.local_vars_configuration.client_side_validation and user is None: # noqa: E501 + raise ValueError("Invalid value for `user`, must not be `None`") # noqa: E501 if (self.local_vars_configuration.client_side_validation and - object is not None and len(object) > 256): - raise ValueError("Invalid value for `object`, length must be less than or equal to `256`") # noqa: E501 + user is not None and len(user) > 512): + raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501 - self._object = object + self._user = user @property def relation(self): @@ -109,6 +113,8 @@ def relation(self, relation): :param relation: The relation of this TupleKey. # noqa: E501 :type relation: str """ + if self.local_vars_configuration.client_side_validation and relation is None: # noqa: E501 + raise ValueError("Invalid value for `relation`, must not be `None`") # noqa: E501 if (self.local_vars_configuration.client_side_validation and relation is not None and len(relation) > 50): raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501 @@ -116,28 +122,51 @@ def relation(self, relation): self._relation = relation @property - def user(self): - """Gets the user of this TupleKey. # noqa: E501 + def object(self): + """Gets the object of this TupleKey. # noqa: E501 - :return: The user of this TupleKey. # noqa: E501 + :return: The object of this TupleKey. # noqa: E501 :rtype: str """ - return self._user + return self._object - @user.setter - def user(self, user): - """Sets the user of this TupleKey. + @object.setter + def object(self, object): + """Sets the object of this TupleKey. - :param user: The user of this TupleKey. # noqa: E501 - :type user: str + :param object: The object of this TupleKey. # noqa: E501 + :type object: str """ + if self.local_vars_configuration.client_side_validation and object is None: # noqa: E501 + raise ValueError("Invalid value for `object`, must not be `None`") # noqa: E501 if (self.local_vars_configuration.client_side_validation and - user is not None and len(user) > 512): - raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501 + object is not None and len(object) > 256): + raise ValueError("Invalid value for `object`, length must be less than or equal to `256`") # noqa: E501 - self._user = user + self._object = object + + @property + def condition(self): + """Gets the condition of this TupleKey. # noqa: E501 + + + :return: The condition of this TupleKey. # noqa: E501 + :rtype: RelationshipCondition + """ + return self._condition + + @condition.setter + def condition(self, condition): + """Sets the condition of this TupleKey. + + + :param condition: The condition of this TupleKey. # noqa: E501 + :type condition: RelationshipCondition + """ + + self._condition = condition def to_dict(self, serialize=False): """Returns the model properties as a dict""" diff --git a/openfga_sdk/models/tuple_key_without_condition.py b/openfga_sdk/models/tuple_key_without_condition.py new file mode 100644 index 00000000..5191944c --- /dev/null +++ b/openfga_sdk/models/tuple_key_without_condition.py @@ -0,0 +1,197 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class TupleKeyWithoutCondition(object): + """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 = { + 'user': 'str', + 'relation': 'str', + 'object': 'str' + } + + attribute_map = { + 'user': 'user', + 'relation': 'relation', + 'object': 'object' + } + + def __init__(self, user=None, relation=None, object=None, local_vars_configuration=None): # noqa: E501 + """TupleKeyWithoutCondition - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + + self._user = None + self._relation = None + self._object = None + self.discriminator = None + + self.user = user + self.relation = relation + self.object = object + + @property + def user(self): + """Gets the user of this TupleKeyWithoutCondition. # noqa: E501 + + + :return: The user of this TupleKeyWithoutCondition. # noqa: E501 + :rtype: str + """ + return self._user + + @user.setter + def user(self, user): + """Sets the user of this TupleKeyWithoutCondition. + + + :param user: The user of this TupleKeyWithoutCondition. # noqa: E501 + :type user: str + """ + if self.local_vars_configuration.client_side_validation and user is None: # noqa: E501 + raise ValueError("Invalid value for `user`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + user is not None and len(user) > 512): + raise ValueError("Invalid value for `user`, length must be less than or equal to `512`") # noqa: E501 + + self._user = user + + @property + def relation(self): + """Gets the relation of this TupleKeyWithoutCondition. # noqa: E501 + + + :return: The relation of this TupleKeyWithoutCondition. # noqa: E501 + :rtype: str + """ + return self._relation + + @relation.setter + def relation(self, relation): + """Sets the relation of this TupleKeyWithoutCondition. + + + :param relation: The relation of this TupleKeyWithoutCondition. # noqa: E501 + :type relation: str + """ + if self.local_vars_configuration.client_side_validation and relation is None: # noqa: E501 + raise ValueError("Invalid value for `relation`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + relation is not None and len(relation) > 50): + raise ValueError("Invalid value for `relation`, length must be less than or equal to `50`") # noqa: E501 + + self._relation = relation + + @property + def object(self): + """Gets the object of this TupleKeyWithoutCondition. # noqa: E501 + + + :return: The object of this TupleKeyWithoutCondition. # noqa: E501 + :rtype: str + """ + return self._object + + @object.setter + def object(self, object): + """Sets the object of this TupleKeyWithoutCondition. + + + :param object: The object of this TupleKeyWithoutCondition. # noqa: E501 + :type object: str + """ + if self.local_vars_configuration.client_side_validation and object is None: # noqa: E501 + raise ValueError("Invalid value for `object`, must not be `None`") # noqa: E501 + if (self.local_vars_configuration.client_side_validation and + object is not None and len(object) > 256): + raise ValueError("Invalid value for `object`, length must be less than or equal to `256`") # noqa: E501 + + self._object = object + + 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 six.iteritems(self.openapi_types): + 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, TupleKeyWithoutCondition): + 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, TupleKeyWithoutCondition): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/tuple_to_userset.py b/openfga_sdk/models/tuple_to_userset.py index 0dd83f49..3cbb7d92 100644 --- a/openfga_sdk/models/tuple_to_userset.py +++ b/openfga_sdk/models/tuple_to_userset.py @@ -57,10 +57,8 @@ def __init__(self, tupleset=None, computed_userset=None, local_vars_configuratio self._computed_userset = None self.discriminator = None - if tupleset is not None: - self.tupleset = tupleset - if computed_userset is not None: - self.computed_userset = computed_userset + self.tupleset = tupleset + self.computed_userset = computed_userset @property def tupleset(self): @@ -80,6 +78,8 @@ def tupleset(self, tupleset): :param tupleset: The tupleset of this TupleToUserset. # noqa: E501 :type tupleset: ObjectRelation """ + if self.local_vars_configuration.client_side_validation and tupleset is None: # noqa: E501 + raise ValueError("Invalid value for `tupleset`, must not be `None`") # noqa: E501 self._tupleset = tupleset @@ -101,6 +101,8 @@ def computed_userset(self, computed_userset): :param computed_userset: The computed_userset of this TupleToUserset. # noqa: E501 :type computed_userset: ObjectRelation """ + if self.local_vars_configuration.client_side_validation and computed_userset is None: # noqa: E501 + raise ValueError("Invalid value for `computed_userset`, must not be `None`") # noqa: E501 self._computed_userset = computed_userset diff --git a/openfga_sdk/models/type_name.py b/openfga_sdk/models/type_name.py new file mode 100644 index 00000000..42aeb594 --- /dev/null +++ b/openfga_sdk/models/type_name.py @@ -0,0 +1,123 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class TypeName(object): + """NOTE: This class is auto generated by OpenAPI Generator. + Ref: https://openapi-generator.tech + + Do not edit the class manually. + """ + + """ + allowed enum values + """ + UNSPECIFIED = "TYPE_NAME_UNSPECIFIED" + ANY = "TYPE_NAME_ANY" + BOOL = "TYPE_NAME_BOOL" + STRING = "TYPE_NAME_STRING" + INT = "TYPE_NAME_INT" + UINT = "TYPE_NAME_UINT" + DOUBLE = "TYPE_NAME_DOUBLE" + DURATION = "TYPE_NAME_DURATION" + TIMESTAMP = "TYPE_NAME_TIMESTAMP" + MAP = "TYPE_NAME_MAP" + LIST = "TYPE_NAME_LIST" + IPADDRESS = "TYPE_NAME_IPADDRESS" + + allowable_values = [UNSPECIFIED, ANY, BOOL, STRING, INT, UINT, DOUBLE, DURATION, TIMESTAMP, MAP, LIST, IPADDRESS] # noqa: E501 + + """ + 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 = { + } + + attribute_map = { + } + + def __init__(self, local_vars_configuration=None): # noqa: E501 + """TypeName - a model defined in OpenAPI""" # noqa: E501 + if local_vars_configuration is None: + local_vars_configuration = Configuration.get_default_copy() + self.local_vars_configuration = local_vars_configuration + self.discriminator = None + + 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 six.iteritems(self.openapi_types): + 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, TypeName): + 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, TypeName): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/users.py b/openfga_sdk/models/users.py index 8f3b0abd..9654d739 100644 --- a/openfga_sdk/models/users.py +++ b/openfga_sdk/models/users.py @@ -54,8 +54,7 @@ def __init__(self, users=None, local_vars_configuration=None): # noqa: E501 self._users = None self.discriminator = None - if users is not None: - self.users = users + self.users = users @property def users(self): @@ -75,6 +74,8 @@ def users(self, users): :param users: The users of this Users. # noqa: E501 :type users: list[str] """ + if self.local_vars_configuration.client_side_validation and users is None: # noqa: E501 + raise ValueError("Invalid value for `users`, must not be `None`") # noqa: E501 self._users = users diff --git a/openfga_sdk/models/userset_tree_difference.py b/openfga_sdk/models/userset_tree_difference.py index b1af5e3a..3229fb6f 100644 --- a/openfga_sdk/models/userset_tree_difference.py +++ b/openfga_sdk/models/userset_tree_difference.py @@ -57,10 +57,8 @@ def __init__(self, base=None, subtract=None, local_vars_configuration=None): # self._subtract = None self.discriminator = None - if base is not None: - self.base = base - if subtract is not None: - self.subtract = subtract + self.base = base + self.subtract = subtract @property def base(self): @@ -80,6 +78,8 @@ def base(self, base): :param base: The base of this UsersetTreeDifference. # noqa: E501 :type base: Node """ + if self.local_vars_configuration.client_side_validation and base is None: # noqa: E501 + raise ValueError("Invalid value for `base`, must not be `None`") # noqa: E501 self._base = base @@ -101,6 +101,8 @@ def subtract(self, subtract): :param subtract: The subtract of this UsersetTreeDifference. # noqa: E501 :type subtract: Node """ + if self.local_vars_configuration.client_side_validation and subtract is None: # noqa: E501 + raise ValueError("Invalid value for `subtract`, must not be `None`") # noqa: E501 self._subtract = subtract diff --git a/openfga_sdk/models/userset_tree_tuple_to_userset.py b/openfga_sdk/models/userset_tree_tuple_to_userset.py index 2ac91c6a..72d770f2 100644 --- a/openfga_sdk/models/userset_tree_tuple_to_userset.py +++ b/openfga_sdk/models/userset_tree_tuple_to_userset.py @@ -57,10 +57,8 @@ def __init__(self, tupleset=None, computed=None, local_vars_configuration=None): self._computed = None self.discriminator = None - if tupleset is not None: - self.tupleset = tupleset - if computed is not None: - self.computed = computed + self.tupleset = tupleset + self.computed = computed @property def tupleset(self): @@ -80,6 +78,8 @@ def tupleset(self, tupleset): :param tupleset: The tupleset of this UsersetTreeTupleToUserset. # noqa: E501 :type tupleset: str """ + if self.local_vars_configuration.client_side_validation and tupleset is None: # noqa: E501 + raise ValueError("Invalid value for `tupleset`, must not be `None`") # noqa: E501 self._tupleset = tupleset @@ -101,6 +101,8 @@ def computed(self, computed): :param computed: The computed of this UsersetTreeTupleToUserset. # noqa: E501 :type computed: list[Computed] """ + if self.local_vars_configuration.client_side_validation and computed is None: # noqa: E501 + raise ValueError("Invalid value for `computed`, must not be `None`") # noqa: E501 self._computed = computed diff --git a/openfga_sdk/models/usersets.py b/openfga_sdk/models/usersets.py index 078f550f..e399a6fa 100644 --- a/openfga_sdk/models/usersets.py +++ b/openfga_sdk/models/usersets.py @@ -54,8 +54,7 @@ def __init__(self, child=None, local_vars_configuration=None): # noqa: E501 self._child = None self.discriminator = None - if child is not None: - self.child = child + self.child = child @property def child(self): @@ -75,6 +74,8 @@ def child(self, child): :param child: The child of this Usersets. # noqa: E501 :type child: list[Userset] """ + if self.local_vars_configuration.client_side_validation and child is None: # noqa: E501 + raise ValueError("Invalid value for `child`, must not be `None`") # noqa: E501 self._child = child diff --git a/openfga_sdk/models/write_authorization_model_request.py b/openfga_sdk/models/write_authorization_model_request.py index df9a8898..46f045d0 100644 --- a/openfga_sdk/models/write_authorization_model_request.py +++ b/openfga_sdk/models/write_authorization_model_request.py @@ -39,15 +39,17 @@ class WriteAuthorizationModelRequest(object): """ openapi_types = { 'type_definitions': 'list[TypeDefinition]', - 'schema_version': 'str' + 'schema_version': 'str', + 'conditions': 'dict[str, Condition]' } attribute_map = { 'type_definitions': 'type_definitions', - 'schema_version': 'schema_version' + 'schema_version': 'schema_version', + 'conditions': 'conditions' } - def __init__(self, type_definitions=None, schema_version=None, local_vars_configuration=None): # noqa: E501 + def __init__(self, type_definitions=None, schema_version=None, conditions=None, local_vars_configuration=None): # noqa: E501 """WriteAuthorizationModelRequest - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration.get_default_copy() @@ -55,11 +57,13 @@ def __init__(self, type_definitions=None, schema_version=None, local_vars_config self._type_definitions = None self._schema_version = None + self._conditions = None self.discriminator = None self.type_definitions = type_definitions - if schema_version is not None: - self.schema_version = schema_version + self.schema_version = schema_version + if conditions is not None: + self.conditions = conditions @property def type_definitions(self): @@ -102,9 +106,32 @@ def schema_version(self, schema_version): :param schema_version: The schema_version of this WriteAuthorizationModelRequest. # noqa: E501 :type schema_version: str """ + if self.local_vars_configuration.client_side_validation and schema_version is None: # noqa: E501 + raise ValueError("Invalid value for `schema_version`, must not be `None`") # noqa: E501 self._schema_version = schema_version + @property + def conditions(self): + """Gets the conditions of this WriteAuthorizationModelRequest. # noqa: E501 + + + :return: The conditions of this WriteAuthorizationModelRequest. # noqa: E501 + :rtype: dict[str, Condition] + """ + return self._conditions + + @conditions.setter + def conditions(self, conditions): + """Sets the conditions of this WriteAuthorizationModelRequest. + + + :param conditions: The conditions of this WriteAuthorizationModelRequest. # noqa: E501 + :type conditions: dict[str, Condition] + """ + + self._conditions = conditions + def to_dict(self, serialize=False): """Returns the model properties as a dict""" result = {} diff --git a/openfga_sdk/models/write_authorization_model_response.py b/openfga_sdk/models/write_authorization_model_response.py index 6395804d..568d0276 100644 --- a/openfga_sdk/models/write_authorization_model_response.py +++ b/openfga_sdk/models/write_authorization_model_response.py @@ -54,8 +54,7 @@ def __init__(self, authorization_model_id=None, local_vars_configuration=None): self._authorization_model_id = None self.discriminator = None - if authorization_model_id is not None: - self.authorization_model_id = authorization_model_id + self.authorization_model_id = authorization_model_id @property def authorization_model_id(self): @@ -75,6 +74,8 @@ def authorization_model_id(self, authorization_model_id): :param authorization_model_id: The authorization_model_id of this WriteAuthorizationModelResponse. # noqa: E501 :type authorization_model_id: str """ + if self.local_vars_configuration.client_side_validation and authorization_model_id is None: # noqa: E501 + raise ValueError("Invalid value for `authorization_model_id`, must not be `None`") # noqa: E501 self._authorization_model_id = authorization_model_id diff --git a/openfga_sdk/models/write_request.py b/openfga_sdk/models/write_request.py index 28242b5b..405271ca 100644 --- a/openfga_sdk/models/write_request.py +++ b/openfga_sdk/models/write_request.py @@ -38,8 +38,8 @@ class WriteRequest(object): and the value is json key in definition. """ openapi_types = { - 'writes': 'TupleKeys', - 'deletes': 'TupleKeys', + 'writes': 'WriteRequestWrites', + 'deletes': 'WriteRequestDeletes', 'authorization_model_id': 'str' } @@ -73,7 +73,7 @@ def writes(self): :return: The writes of this WriteRequest. # noqa: E501 - :rtype: TupleKeys + :rtype: WriteRequestWrites """ return self._writes @@ -83,7 +83,7 @@ def writes(self, writes): :param writes: The writes of this WriteRequest. # noqa: E501 - :type writes: TupleKeys + :type writes: WriteRequestWrites """ self._writes = writes @@ -94,7 +94,7 @@ def deletes(self): :return: The deletes of this WriteRequest. # noqa: E501 - :rtype: TupleKeys + :rtype: WriteRequestDeletes """ return self._deletes @@ -104,7 +104,7 @@ def deletes(self, deletes): :param deletes: The deletes of this WriteRequest. # noqa: E501 - :type deletes: TupleKeys + :type deletes: WriteRequestDeletes """ self._deletes = deletes diff --git a/openfga_sdk/models/write_request_deletes.py b/openfga_sdk/models/write_request_deletes.py new file mode 100644 index 00000000..c8ae0098 --- /dev/null +++ b/openfga_sdk/models/write_request_deletes.py @@ -0,0 +1,134 @@ +# coding: utf-8 + +""" + Python SDK for OpenFGA + + API version: 0.1 + Website: https://openfga.dev + Documentation: https://openfga.dev/docs + Support: https://discord.gg/8naAwJfWN6 + 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 +import re # noqa: F401 +import six + +from openfga_sdk.configuration import Configuration + + +class WriteRequestDeletes(object): + """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 = { + 'tuple_keys': 'list[TupleKeyWithoutCondition]' + } + + attribute_map = { + 'tuple_keys': 'tuple_keys' + } + + def __init__(self, tuple_keys=None, local_vars_configuration=None): # noqa: E501 + """WriteRequestDeletes - a model defined in OpenAPI""" # noqa: E501 + 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.discriminator = None + + self.tuple_keys = tuple_keys + + @property + def tuple_keys(self): + """Gets the tuple_keys of this WriteRequestDeletes. # noqa: E501 + + + :return: The tuple_keys of this WriteRequestDeletes. # noqa: E501 + :rtype: list[TupleKeyWithoutCondition] + """ + return self._tuple_keys + + @tuple_keys.setter + def tuple_keys(self, tuple_keys): + """Sets the tuple_keys of this WriteRequestDeletes. + + + :param tuple_keys: The tuple_keys of this WriteRequestDeletes. # noqa: E501 + :type tuple_keys: list[TupleKeyWithoutCondition] + """ + if self.local_vars_configuration.client_side_validation and tuple_keys is None: # noqa: E501 + raise ValueError("Invalid value for `tuple_keys`, must not be `None`") # noqa: E501 + + self._tuple_keys = tuple_keys + + 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 six.iteritems(self.openapi_types): + 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, WriteRequestDeletes): + 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, WriteRequestDeletes): + return True + + return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/models/tuple_keys.py b/openfga_sdk/models/write_request_writes.py similarity index 87% rename from openfga_sdk/models/tuple_keys.py rename to openfga_sdk/models/write_request_writes.py index 34294f78..0ea2efa2 100644 --- a/openfga_sdk/models/tuple_keys.py +++ b/openfga_sdk/models/write_request_writes.py @@ -23,7 +23,7 @@ from openfga_sdk.configuration import Configuration -class TupleKeys(object): +class WriteRequestWrites(object): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -46,7 +46,7 @@ class TupleKeys(object): } def __init__(self, tuple_keys=None, local_vars_configuration=None): # noqa: E501 - """TupleKeys - a model defined in OpenAPI""" # noqa: E501 + """WriteRequestWrites - a model defined in OpenAPI""" # noqa: E501 if local_vars_configuration is None: local_vars_configuration = Configuration.get_default_copy() self.local_vars_configuration = local_vars_configuration @@ -58,20 +58,20 @@ def __init__(self, tuple_keys=None, local_vars_configuration=None): # noqa: E50 @property def tuple_keys(self): - """Gets the tuple_keys of this TupleKeys. # noqa: E501 + """Gets the tuple_keys of this WriteRequestWrites. # noqa: E501 - :return: The tuple_keys of this TupleKeys. # noqa: E501 + :return: The tuple_keys of this WriteRequestWrites. # noqa: E501 :rtype: list[TupleKey] """ return self._tuple_keys @tuple_keys.setter def tuple_keys(self, tuple_keys): - """Sets the tuple_keys of this TupleKeys. + """Sets the tuple_keys of this WriteRequestWrites. - :param tuple_keys: The tuple_keys of this TupleKeys. # noqa: E501 + :param tuple_keys: The tuple_keys of this WriteRequestWrites. # noqa: E501 :type tuple_keys: list[TupleKey] """ if self.local_vars_configuration.client_side_validation and tuple_keys is None: # noqa: E501 @@ -121,14 +121,14 @@ def __repr__(self): def __eq__(self, other): """Returns true if both objects are equal""" - if not isinstance(other, TupleKeys): + 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, TupleKeys): + if not isinstance(other, WriteRequestWrites): return True return self.to_dict() != other.to_dict() diff --git a/openfga_sdk/sync/client/client.py b/openfga_sdk/sync/client/client.py index 6bbf002e..f465a408 100644 --- a/openfga_sdk/sync/client/client.py +++ b/openfga_sdk/sync/client/client.py @@ -32,9 +32,11 @@ from openfga_sdk.models.contextual_tuple_keys import ContextualTupleKeys from openfga_sdk.models.create_store_request import CreateStoreRequest from openfga_sdk.models.expand_request import ExpandRequest +from openfga_sdk.models.expand_request_tuple_key import ExpandRequestTupleKey from openfga_sdk.models.list_objects_request import ListObjectsRequest from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_request import ReadRequest +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.tuple_key import TupleKey from openfga_sdk.models.write_assertions_request import WriteAssertionsRequest from openfga_sdk.models.write_authorization_model_request import WriteAuthorizationModelRequest @@ -73,7 +75,7 @@ def set_heading_if_not_set(options: dict[str, int | str], name: str, value: str) def options_to_kwargs(options: dict[str, int | str] = None): """ - Return kargs with continuation_token and page_size + Return kwargs with continuation_token and page_size """ kwargs = {} if options is not None: @@ -126,7 +128,7 @@ def close(self): def _get_authorization_model_id(self, options: object) -> str | None: """ Return the authorization model ID if specified in the options. - Otherwise return the authorization model ID stored in the client's configuration + Otherwise, return the authorization model ID stored in the client's configuration """ authorization_model_id = self._client_configuration.authorization_model_id if options is not None and "authorization_model_id" in options: @@ -152,13 +154,13 @@ def get_store_id(self): def set_authorization_model_id(self, value): """ - Update the authorizaiton model id in the configuration + Update the authorization model id in the configuration """ self._client_configuration.authorization_model_id = value def get_authorization_model_id(self): """ - Return the authorizaiton model id + Return the authorization model id """ return self._client_configuration.authorization_model_id @@ -186,7 +188,7 @@ def list_stores(self, options: dict[str, int | str] = None): :param retryParams.maxRetry(options) - Override the max number of retries on each API request :param retryParams.minWaitInMs(options) - Override the minimum wait before a retry is initiated """ - # convert options to kargs + # convert options to kwargs options = set_heading_if_not_set(options, CLIENT_METHOD_HEADER, "ListStores") kwargs = options_to_kwargs(options) api_response = self._api.list_stores( @@ -295,7 +297,7 @@ def read_authorization_model(self, options: dict[str, int | str] = None): def read_latest_authorization_model(self, options: dict[str, int | str] = None): """ - Convenient method of reading the latest authorizaiton model + Convenient method of reading the latest authorization model :param header(options) - Custom headers to send alongside the request :param retryParams(options) - Override the retry parameters for this request :param retryParams.maxRetry(options) - Override the max number of retries on each API request @@ -330,7 +332,7 @@ def read_changes(self, body: ClientReadChangesRequest, options: dict[str, str] = ) return api_response - def read(self, body: TupleKey, options: dict[str, str] = None): + def read(self, body: ReadRequestTupleKey, options: dict[str, str] = None): """ Read changes for specified type :param body - the tuples we want to read @@ -505,6 +507,7 @@ def check(self, body: ClientCheckRequest, options: dict[str, str] = None): # no relation=body.relation, object=body.object, ), + context=body.context, authorization_model_id=self._get_authorization_model_id(options), ) if body.contextual_tuples: @@ -575,7 +578,7 @@ def expand(self, body: ClientExpandRequest, options: dict[str, str] = None): # kwargs = options_to_kwargs(options) req_body = ExpandRequest( - tuple_key=TupleKey( + tuple_key=ExpandRequestTupleKey( relation=body.relation, object=body.object, ), @@ -605,6 +608,7 @@ def list_objects(self, body: ClientListObjectsRequest, options: dict[str, str] = user=body.user, relation=body.relation, type=body.type, + context=body.context, ) if body.contextual_tuples: req_body.contextual_tuples = ContextualTupleKeys( diff --git a/openfga_sdk/sync/open_fga_api.py b/openfga_sdk/sync/open_fga_api.py index 14551b07..dfbf5c0a 100644 --- a/openfga_sdk/sync/open_fga_api.py +++ b/openfga_sdk/sync/open_fga_api.py @@ -56,7 +56,7 @@ def close(self): def check(self, body, **kwargs): # noqa: E501 """Check whether a user is authorized to access an object # noqa: E501 - The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. # noqa: E501 + The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. Each of these tuples may have an associated `condition`. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. # noqa: E501 >>> thread = api.check(body) @@ -83,7 +83,7 @@ def check(self, body, **kwargs): # noqa: E501 def check_with_http_info(self, body, **kwargs): # noqa: E501 """Check whether a user is authorized to access an object # noqa: E501 - The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. # noqa: E501 + The Check API queries to check if the user has a certain relationship with an object in a certain store. A `contextual_tuples` object may also be included in the body of the request. This object contains one field `tuple_keys`, which is an array of tuple keys. Each of these tuples may have an associated `condition`. You may also provide an `authorization_model_id` in the body. This will be used to assert that the input `tuple_key` is valid for the model specified. If not specified, the assertion will be made against the latest authorization model ID. It is strongly recommended to specify authorization model id for better performance. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will return whether the relationship exists in the field `allowed`. ## Example In order to check if user `user:anne` of type `user` has a `reader` relationship with object `document:2021-budget` given the following contextual tuple ```json { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ``` the Check API can be used with the following request body: ```json { \"tuple_key\": { \"user\": \"user:anne\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" }, \"contextual_tuples\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"member\", \"object\": \"time_slot:office_hours\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` OpenFGA's response will include `{ \"allowed\": true }` if there is a relationship and `{ \"allowed\": false }` if there isn't. # noqa: E501 >>> thread = api.check_with_http_info(body) @@ -180,6 +180,7 @@ def check_with_http_info(self, body, **kwargs): # noqa: E501 200: "CheckResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -322,6 +323,7 @@ def create_store_with_http_info(self, body, **kwargs): # noqa: E501 201: "CreateStoreResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -599,6 +601,7 @@ def expand_with_http_info(self, body, **kwargs): # noqa: E501 200: "ExpandResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -732,6 +735,7 @@ def get_store_with_http_info(self, **kwargs): # noqa: E501 200: "GetStoreResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -757,7 +761,7 @@ def get_store_with_http_info(self, **kwargs): # noqa: E501 def list_objects(self, body, **kwargs): # noqa: E501 """List all objects of the given type that the user has a relation with # noqa: E501 - The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501 + The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. Each of these tuples may have an associated `condition`. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501 >>> thread = api.list_objects(body) @@ -784,7 +788,7 @@ def list_objects(self, body, **kwargs): # noqa: E501 def list_objects_with_http_info(self, body, **kwargs): # noqa: E501 """List all objects of the given type that the user has a relation with # noqa: E501 - The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501 + The ListObjects API returns a list of all the objects of the given type that the user has a relation with. To achieve this, both the store tuples and the authorization model are used. An `authorization_model_id` may be specified in the body. If it is not specified, the latest authorization model ID will be used. It is strongly recommended to specify authorization model id for better performance. You may also specify `contextual_tuples` that will be treated as regular tuples. Each of these tuples may have an associated `condition`. You may also provide a `context` object that will be used to evaluate the conditioned tuples in the system. It is strongly recommended to provide a value for all the input parameters of all the conditions, to ensure that all tuples be evaluated correctly. The response will contain the related objects in an array in the \"objects\" field of the response and they will be strings in the object format `:` (e.g. \"document:roadmap\"). The number of objects in the response array will be limited by the execution timeout specified in the flag OPENFGA_LIST_OBJECTS_DEADLINE and by the upper bound specified in the flag OPENFGA_LIST_OBJECTS_MAX_RESULTS, whichever is hit first. The objects given will not be sorted, and therefore two identical calls can give a given different set of objects. # noqa: E501 >>> thread = api.list_objects_with_http_info(body) @@ -881,6 +885,7 @@ def list_objects_with_http_info(self, body, **kwargs): # noqa: E501 200: "ListObjectsResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1024,6 +1029,7 @@ def list_stores_with_http_info(self, **kwargs): # noqa: E501 200: "ListStoresResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1173,6 +1179,7 @@ def read_with_http_info(self, body, **kwargs): # noqa: E501 200: "ReadResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1318,6 +1325,7 @@ def read_assertions_with_http_info(self, authorization_model_id, **kwargs): # n 200: "ReadAssertionsResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1464,6 +1472,7 @@ def read_authorization_model_with_http_info(self, id, **kwargs): # noqa: E501 200: "ReadAuthorizationModelResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1611,6 +1620,7 @@ def read_authorization_models_with_http_info(self, **kwargs): # noqa: E501 200: "ReadAuthorizationModelsResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1636,7 +1646,7 @@ def read_authorization_models_with_http_info(self, **kwargs): # noqa: E501 def read_changes(self, **kwargs): # noqa: E501 """Return a list of all the tuple changes # noqa: E501 - The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. # noqa: E501 + The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. When reading a write tuple change, if it was conditioned, the condition will be returned. When reading a delete tuple change, the condition will NOT be returned regardless of whether it was originally conditioned or not. # noqa: E501 >>> thread = api.read_changes() @@ -1667,7 +1677,7 @@ def read_changes(self, **kwargs): # noqa: E501 def read_changes_with_http_info(self, **kwargs): # noqa: E501 """Return a list of all the tuple changes # noqa: E501 - The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. # noqa: E501 + The ReadChanges API will return a paginated list of tuple changes (additions and deletions) that occurred in a given store, sorted by ascending time. The response will include a continuation token that is used to get the next set of changes. If there are no changes after the provided continuation token, the same token will be returned in order for it to be used when new changes are recorded. If the store never had any tuples added or removed, this token will be empty. You can use the `type` parameter to only get the list of tuple changes that affect objects of that type. When reading a write tuple change, if it was conditioned, the condition will be returned. When reading a delete tuple change, the condition will NOT be returned regardless of whether it was originally conditioned or not. # noqa: E501 >>> thread = api.read_changes_with_http_info() @@ -1765,6 +1775,7 @@ def read_changes_with_http_info(self, **kwargs): # noqa: E501 200: "ReadChangesResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -1790,7 +1801,7 @@ def read_changes_with_http_info(self, **kwargs): # noqa: E501 def write(self, body, **kwargs): # noqa: E501 """Add or delete tuples from the store # noqa: E501 - The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples while `deletes` removes existing tuples. The API is not idempotent: if, later on, you try to add the same tuple, or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` # noqa: E501 + The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` # noqa: E501 >>> thread = api.write(body) @@ -1817,7 +1828,7 @@ def write(self, body, **kwargs): # noqa: E501 def write_with_http_info(self, body, **kwargs): # noqa: E501 """Add or delete tuples from the store # noqa: E501 - The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples while `deletes` removes existing tuples. The API is not idempotent: if, later on, you try to add the same tuple, or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` # noqa: E501 + The Write API will update the tuples for a certain store. Tuples and type definitions allow OpenFGA to determine whether a relationship exists between an object and an user. In the body, `writes` adds new tuples and `deletes` removes existing tuples. When deleting a tuple, any `condition` specified with it is ignored. The API is not idempotent: if, later on, you try to add the same tuple key (even if the `condition` is different), or if you try to delete a non-existing tuple, it will throw an error. An `authorization_model_id` may be specified in the body. If it is, it will be used to assert that each written tuple (not deleted) is valid for the model specified. If it is not specified, the latest authorization model ID will be used. ## Example ### Adding relationships To add `user:anne` as a `writer` for `document:2021-budget`, call write API with the following ```json { \"writes\": { \"tuple_keys\": [ { \"user\": \"user:anne\", \"relation\": \"writer\", \"object\": \"document:2021-budget\" } ] }, \"authorization_model_id\": \"01G50QVV17PECNVAHX1GG4Y5NC\" } ``` ### Removing relationships To remove `user:bob` as a `reader` for `document:2021-budget`, call write API with the following ```json { \"deletes\": { \"tuple_keys\": [ { \"user\": \"user:bob\", \"relation\": \"reader\", \"object\": \"document:2021-budget\" } ] } } ``` # noqa: E501 >>> thread = api.write_with_http_info(body) @@ -1914,6 +1925,7 @@ def write_with_http_info(self, body, **kwargs): # noqa: E501 200: "object", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } @@ -2220,6 +2232,7 @@ def write_authorization_model_with_http_info(self, body, **kwargs): # noqa: E50 201: "WriteAuthorizationModelResponse", 400: "ValidationErrorMessageResponse", 404: "PathUnknownErrorMessageResponse", + 409: "AbortedMessageResponse", 500: "InternalErrorMessageResponse", } diff --git a/test/test_client.py b/test/test_client.py index 027f14cf..d286e305 100644 --- a/test/test_client.py +++ b/test/test_client.py @@ -48,11 +48,13 @@ from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_authorization_models_response import ReadAuthorizationModelsResponse from openfga_sdk.models.read_changes_response import ReadChangesResponse +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.read_response import ReadResponse from openfga_sdk.models.store import Store from openfga_sdk.models.tuple import Tuple from openfga_sdk.models.tuple_change import TupleChange from openfga_sdk.models.tuple_key import TupleKey +from openfga_sdk.models.tuple_key_without_condition import TupleKeyWithoutCondition from openfga_sdk.models.tuple_operation import TupleOperation from openfga_sdk.models.type_definition import TypeDefinition from openfga_sdk.models.users import Users @@ -637,7 +639,8 @@ async def test_read(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -645,7 +648,7 @@ async def test_read(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client async with OpenFgaClient(configuration) as api_client: - body = TupleKey( + body = ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -659,7 +662,8 @@ async def test_read(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse( + tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -690,7 +694,8 @@ async def test_read_empty_options(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -698,7 +703,7 @@ async def test_read_empty_options(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client async with OpenFgaClient(configuration) as api_client: - body = TupleKey( + body = ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -711,7 +716,8 @@ async def test_read_empty_options(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse( + tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -742,7 +748,8 @@ async def test_read_empty_body(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -750,7 +757,7 @@ async def test_read_empty_body(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client async with OpenFgaClient(configuration) as api_client: - body = TupleKey() + body = ReadRequestTupleKey() api_response = await api_client.read( body=body, options={} @@ -759,7 +766,8 @@ async def test_read_empty_body(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse( + tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -1844,8 +1852,8 @@ async def test_expand(self, mock_request): options={"authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1"} ) self.assertIsInstance(api_response, ExpandResponse) - curUsers = Users(users=["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]) - leaf = Leaf(users=curUsers) + cur_users = Users(users=["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]) + leaf = Leaf(users=cur_users) node = Node(name="document:budget#reader", leaf=leaf) userTree = UsersetTree(node) expected_response = ExpandResponse(userTree) @@ -2082,8 +2090,8 @@ async def test_read_assertions(self, mock_request): self.assertEqual(api_response, ReadAssertionsResponse( authorization_model_id="01G5JAVJ41T49E9TT3SKVS7X1J", assertions=[Assertion( - tuple_key=TupleKey(object="document:2021-budget", relation="reader", - user="user:anne"), + tuple_key=TupleKeyWithoutCondition(object="document:2021-budget", relation="reader", + user="user:anne"), expectation=True, )] )) diff --git a/test/test_client_sync.py b/test/test_client_sync.py index 57b73266..babd1017 100644 --- a/test/test_client_sync.py +++ b/test/test_client_sync.py @@ -48,11 +48,13 @@ from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_authorization_models_response import ReadAuthorizationModelsResponse from openfga_sdk.models.read_changes_response import ReadChangesResponse +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.read_response import ReadResponse from openfga_sdk.models.store import Store from openfga_sdk.models.tuple import Tuple from openfga_sdk.models.tuple_change import TupleChange from openfga_sdk.models.tuple_key import TupleKey +from openfga_sdk.models.tuple_key_without_condition import TupleKeyWithoutCondition from openfga_sdk.models.tuple_operation import TupleOperation from openfga_sdk.models.type_definition import TypeDefinition from openfga_sdk.models.users import Users @@ -637,7 +639,8 @@ def test_read(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -645,7 +648,7 @@ def test_read(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client with OpenFgaClient(configuration) as api_client: - body = TupleKey( + body = ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -659,7 +662,8 @@ def test_read(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse( + tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -690,7 +694,8 @@ def test_read_empty_options(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -698,7 +703,7 @@ def test_read_empty_options(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client with OpenFgaClient(configuration) as api_client: - body = TupleKey( + body = ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -711,7 +716,8 @@ def test_read_empty_options(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse( + tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -742,7 +748,8 @@ def test_read_empty_body(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -750,7 +757,7 @@ def test_read_empty_body(self, mock_request): configuration.store_id = store_id # Enter a context with an instance of the API client with OpenFgaClient(configuration) as api_client: - body = TupleKey() + body = ReadRequestTupleKey() api_response = api_client.read( body=body, options={} @@ -759,7 +766,8 @@ def test_read_empty_body(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse( + tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -1844,8 +1852,8 @@ def test_expand(self, mock_request): options={"authorization_model_id": "01GXSA8YR785C4FYS3C0RTG7B1"} ) self.assertIsInstance(api_response, ExpandResponse) - curUsers = Users(users=["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]) - leaf = Leaf(users=curUsers) + cur_users = Users(users=["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]) + leaf = Leaf(users=cur_users) node = Node(name="document:budget#reader", leaf=leaf) userTree = UsersetTree(node) expected_response = ExpandResponse(userTree) @@ -2084,8 +2092,8 @@ def test_read_assertions(self, mock_request): self.assertEqual(api_response, ReadAssertionsResponse( authorization_model_id="01G5JAVJ41T49E9TT3SKVS7X1J", assertions=[Assertion( - tuple_key=TupleKey(object="document:2021-budget", relation="reader", - user="user:anne"), + tuple_key=TupleKeyWithoutCondition(object="document:2021-budget", relation="reader", + user="user:anne"), expectation=True, )] )) diff --git a/test/test_open_fga_api.py b/test/test_open_fga_api.py index cb5e7d9a..468c44b3 100644 --- a/test/test_open_fga_api.py +++ b/test/test_open_fga_api.py @@ -33,6 +33,7 @@ from openfga_sdk.models.create_store_response import CreateStoreResponse from openfga_sdk.models.error_code import ErrorCode from openfga_sdk.models.expand_request import ExpandRequest +from openfga_sdk.models.expand_request_tuple_key import ExpandRequestTupleKey from openfga_sdk.models.expand_response import ExpandResponse from openfga_sdk.models.get_store_response import GetStoreResponse from openfga_sdk.models.internal_error_code import InternalErrorCode @@ -49,12 +50,15 @@ from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_changes_response import ReadChangesResponse from openfga_sdk.models.read_request import ReadRequest +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.read_response import ReadResponse from openfga_sdk.models.store import Store from openfga_sdk.models.tuple import Tuple from openfga_sdk.models.tuple_change import TupleChange from openfga_sdk.models.tuple_key import TupleKey -from openfga_sdk.models.tuple_keys import TupleKeys +from openfga_sdk.models.tuple_key_without_condition import TupleKeyWithoutCondition +from openfga_sdk.models.write_request_writes import WriteRequestWrites +from openfga_sdk.models.write_request_deletes import WriteRequestDeletes from openfga_sdk.models.tuple_operation import TupleOperation from openfga_sdk.models.type_definition import TypeDefinition from openfga_sdk.models.users import Users @@ -221,7 +225,7 @@ async def test_expand(self, mock_request): async with openfga_sdk.ApiClient(configuration) as api_client: api_instance = open_fga_api.OpenFgaApi(api_client) body = ExpandRequest( - tuple_key=TupleKey( + tuple_key=ExpandRequestTupleKey( object="document:budget", relation="reader", ), @@ -231,8 +235,8 @@ async def test_expand(self, mock_request): body=body, ) self.assertIsInstance(api_response, ExpandResponse) - curUsers = Users(users=["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]) - leaf = Leaf(users=curUsers) + cur_users = Users(users=["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]) + leaf = Leaf(users=cur_users) node = Node(name="document:budget#reader", leaf=leaf) userTree = UsersetTree(node) expected_response = ExpandResponse(userTree) @@ -408,7 +412,8 @@ async def test_read(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -417,7 +422,7 @@ async def test_read(self, mock_request): async with openfga_sdk.ApiClient(configuration) as api_client: api_instance = open_fga_api.OpenFgaApi(api_client) body = ReadRequest( - tuple_key=TupleKey( + tuple_key=ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -432,7 +437,8 @@ async def test_read(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse( + tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -478,7 +484,7 @@ async def test_read_assertions(self, mock_request): self.assertIsInstance(api_response, ReadAssertionsResponse) self.assertEqual(api_response.authorization_model_id, '01G5JAVJ41T49E9TT3SKVS7X1J') assertion = Assertion( - tuple_key=TupleKey( + tuple_key=TupleKeyWithoutCondition( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -654,7 +660,7 @@ async def test_write(self, mock_request): # example passing only required values which don't have defaults set body = WriteRequest( - writes=TupleKeys( + writes=WriteRequestWrites( tuple_keys=[ TupleKey( object="document:2021-budget", @@ -698,7 +704,7 @@ async def test_write_delete(self, mock_request): # example passing only required values which don't have defaults set body = WriteRequest( - deletes=TupleKeys( + deletes=WriteRequestDeletes( tuple_keys=[ TupleKey( object="document:2021-budget", @@ -1173,12 +1179,12 @@ async def test_check_api_token(self, mock_request): self.assertIsInstance(api_response, CheckResponse) self.assertTrue(api_response.allowed) # Make sure the API was called with the right data - expectedHeader = urllib3.response.HTTPHeaderDict( + expected_headers = urllib3.response.HTTPHeaderDict( {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.3', 'Authorization': 'Bearer TOKEN1'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check', - headers=expectedHeader, + headers=expected_headers, query_params=[], post_params=[], body={"tuple_key": {"object": "document:2021-budget", "relation": "reader", @@ -1216,12 +1222,12 @@ async def test_check_custom_header(self, mock_request): self.assertIsInstance(api_response, CheckResponse) self.assertTrue(api_response.allowed) # Make sure the API was called with the right data - expectedHeader = urllib3.response.HTTPHeaderDict( + expected_headers = urllib3.response.HTTPHeaderDict( {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.3', 'Custom Header': 'custom value'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check', - headers=expectedHeader, + headers=expected_headers, query_params=[], post_params=[], body={"tuple_key": {"object": "document:2021-budget", "relation": "reader", diff --git a/test/test_open_fga_api_sync.py b/test/test_open_fga_api_sync.py index a35b267a..b99c9d28 100644 --- a/test/test_open_fga_api_sync.py +++ b/test/test_open_fga_api_sync.py @@ -34,6 +34,7 @@ from openfga_sdk.models.create_store_response import CreateStoreResponse from openfga_sdk.models.error_code import ErrorCode from openfga_sdk.models.expand_request import ExpandRequest +from openfga_sdk.models.expand_request_tuple_key import ExpandRequestTupleKey from openfga_sdk.models.expand_response import ExpandResponse from openfga_sdk.models.get_store_response import GetStoreResponse from openfga_sdk.models.internal_error_code import InternalErrorCode @@ -50,12 +51,15 @@ from openfga_sdk.models.read_authorization_model_response import ReadAuthorizationModelResponse from openfga_sdk.models.read_changes_response import ReadChangesResponse from openfga_sdk.models.read_request import ReadRequest +from openfga_sdk.models.read_request_tuple_key import ReadRequestTupleKey from openfga_sdk.models.read_response import ReadResponse from openfga_sdk.models.store import Store from openfga_sdk.models.tuple import Tuple from openfga_sdk.models.tuple_change import TupleChange from openfga_sdk.models.tuple_key import TupleKey -from openfga_sdk.models.tuple_keys import TupleKeys +from openfga_sdk.models.tuple_key_without_condition import TupleKeyWithoutCondition +from openfga_sdk.models.write_request_writes import WriteRequestWrites +from openfga_sdk.models.write_request_deletes import WriteRequestDeletes from openfga_sdk.models.tuple_operation import TupleOperation from openfga_sdk.models.type_definition import TypeDefinition from openfga_sdk.models.users import Users @@ -222,7 +226,7 @@ async def test_expand(self, mock_request): with ApiClient(configuration) as api_client: api_instance = open_fga_api.OpenFgaApi(api_client) body = ExpandRequest( - tuple_key=TupleKey( + tuple_key=ExpandRequestTupleKey( object="document:budget", relation="reader", ), @@ -232,8 +236,8 @@ async def test_expand(self, mock_request): body=body, ) self.assertIsInstance(api_response, ExpandResponse) - curUsers = Users(users=["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]) - leaf = Leaf(users=curUsers) + cur_users = Users(users=["user:81684243-9356-4421-8fbf-a4f8d36aa31b"]) + leaf = Leaf(users=cur_users) node = Node(name="document:budget#reader", leaf=leaf) userTree = UsersetTree(node) expected_response = ExpandResponse(userTree) @@ -409,7 +413,8 @@ async def test_read(self, mock_request): }, "timestamp": "2021-10-06T15:32:11.128Z" } - ] + ], + "continuation_token": "" } ''' mock_request.return_value = mock_response(response_body, 200) @@ -418,7 +423,7 @@ async def test_read(self, mock_request): with ApiClient(configuration) as api_client: api_instance = open_fga_api.OpenFgaApi(api_client) body = ReadRequest( - tuple_key=TupleKey( + tuple_key=ReadRequestTupleKey( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -433,7 +438,8 @@ async def test_read(self, mock_request): key = TupleKey(user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", relation="reader", object="document:2021-budget") timestamp = datetime.fromisoformat("2021-10-06T15:32:11.128+00:00") - expected_data = ReadResponse(tuples=[Tuple(key=key, timestamp=timestamp)]) + expected_data = ReadResponse( + tuples=[Tuple(key=key, timestamp=timestamp)], continuation_token='') self.assertEqual(api_response, expected_data) mock_request.assert_called_once_with( 'POST', @@ -479,7 +485,7 @@ async def test_read_assertions(self, mock_request): self.assertIsInstance(api_response, ReadAssertionsResponse) self.assertEqual(api_response.authorization_model_id, '01G5JAVJ41T49E9TT3SKVS7X1J') assertion = Assertion( - tuple_key=TupleKey( + tuple_key=TupleKeyWithoutCondition( object="document:2021-budget", relation="reader", user="user:81684243-9356-4421-8fbf-a4f8d36aa31b", @@ -655,7 +661,7 @@ async def test_write(self, mock_request): # example passing only required values which don't have defaults set body = WriteRequest( - writes=TupleKeys( + writes=WriteRequestWrites( tuple_keys=[ TupleKey( object="document:2021-budget", @@ -699,7 +705,7 @@ async def test_write_delete(self, mock_request): # example passing only required values which don't have defaults set body = WriteRequest( - deletes=TupleKeys( + deletes=WriteRequestDeletes( tuple_keys=[ TupleKey( object="document:2021-budget", @@ -1174,12 +1180,12 @@ async def test_check_api_token(self, mock_request): self.assertIsInstance(api_response, CheckResponse) self.assertTrue(api_response.allowed) # Make sure the API was called with the right data - expectedHeader = urllib3.response.HTTPHeaderDict( + expected_headers = urllib3.response.HTTPHeaderDict( {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.3', 'Authorization': 'Bearer TOKEN1'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check', - headers=expectedHeader, + headers=expected_headers, query_params=[], post_params=[], body={"tuple_key": {"object": "document:2021-budget", "relation": "reader", @@ -1217,12 +1223,12 @@ async def test_check_custom_header(self, mock_request): self.assertIsInstance(api_response, CheckResponse) self.assertTrue(api_response.allowed) # Make sure the API was called with the right data - expectedHeader = urllib3.response.HTTPHeaderDict( + expected_headers = urllib3.response.HTTPHeaderDict( {'Accept': 'application/json', 'Content-Type': 'application/json', 'User-Agent': 'openfga-sdk python/0.3.3', 'Custom Header': 'custom value'}) mock_request.assert_called_once_with( 'POST', 'http://api.fga.example/stores/01H0H015178Y2V4CX10C2KGHF4/check', - headers=expectedHeader, + headers=expected_headers, query_params=[], post_params=[], body={"tuple_key": {"object": "document:2021-budget", "relation": "reader",