Skip to content

Commit

Permalink
Add init docstring to data classes (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
hallarak authored Aug 5, 2021
1 parent f0825a6 commit 40bfeae
Show file tree
Hide file tree
Showing 8 changed files with 124 additions and 34 deletions.
16 changes: 16 additions & 0 deletions exabel_data_sdk/client/api/data_classes/entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,22 @@ def __init__(
properties: Mapping[str, Union[str, bool, int, float]],
read_only: bool = False,
):
r"""
Create an entity resource in the Data API.
Args:
name: The resource name of the entity, for example
"entityTypes/entityTypeIdentifier/entities/entityIdentifier" or
"entityTypes/namespace1.entityTypeIdentifier/entities/
namespace2.entityIdentifier". The namespaces must be empty (being
global) or one of the predetermined namespaces the customer has access
to. If namespace1 is not empty, it must be equal to namespace2. The
entity identifier must match the regex [a-zA-Z][\w-]{0,63}.
display_name: The display name of the entity.
description: One or more paragraphs of text description.
properties: The properties of this entity.
read_only: Whether this resource is read only.
"""
self.name = name
self.display_name = display_name
self.description = description
Expand Down
14 changes: 14 additions & 0 deletions exabel_data_sdk/client/api/data_classes/entity_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,20 @@ def __init__(
description: str,
read_only: bool = False,
):
r"""
Create an entity type resource in the Data API.
Args:
name: The resource name of the entity type, for example
"entityTypes/entityTypeIdentifier" or
"entityTypes/namespace.entityTypeIdentifier". The namespace must be
empty (being global) or one of the predetermined namespaces the
customer has access to. The entity type identifier must match the
regex [a-zA-Z][\w-]{0,63}.
display_name: The display name of the entity type.
description: One or more paragraphs of text description.
read_only: Whether this resource is read only.
"""
self.name = name
self.display_name = display_name
self.description = description
Expand Down
16 changes: 13 additions & 3 deletions exabel_data_sdk/client/api/data_classes/paging_result.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,22 @@ class PagingResult(Generic[TValue]):
A sequence of results from the Exabel API that can be be retrieved with paging.
Attributes:
results: The results of a single request.
next_page_token: The page token where the list continues. Can be sent to a subsequent query.
total_size: The total number of results, irrespective of paging.
results (list): The results of a single request.
next_page_token (str): The page token where the list continues. Can be sent to a subsequent
query.
total_size (int): The total number of results, irrespective of paging.
"""

def __init__(self, results: Sequence[TValue], next_page_token: str, total_size: int):
"""
Create a PagingResult.
Args:
results: The results of a single request.
next_page_token: The page token where the list continues. Can be sent to a subsequent
query.
total_size: The total number of results, irrespective of paging.
"""
self.results = results
self.next_page_token = next_page_token
self.total_size = total_size
Expand Down
42 changes: 30 additions & 12 deletions exabel_data_sdk/client/api/data_classes/relationship.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ class Relationship:
A relationship resource in the Data API.
Attributes:
relationship_type: The resource name of the relationship type, for example
"relationshipTypes/namespace.relationshipTypeIdentifier". The namespace
must be empty (being global) or one of the predetermined namespaces the
customer has access to. The relationship type identifier must match the
regex [A-Z][A-Z0-9_]{0,63}.
from_entity: The resource name of the start point of the relationship, for example
"entityTypes/ns.type1/entities/ns.entity1".
to_entity: The resource name of the end point of the relationship, for example
"entityTypes/ns.type2/entities/ns.entity2".
description: One or more paragraphs of text description.
properties: The properties of this entity.
read_only: Whether this resource is read only.
relationship_type (str): The resource name of the relationship type, for example
"relationshipTypes/namespace.relationshipTypeIdentifier". The
namespace must be empty (being global) or one of the
predetermined namespaces the customer has access to. The
relationship type identifier must match the regex
[A-Z][A-Z0-9_]{0,63}.
from_entity (str): The resource name of the start point of the relationship,
for example "entityTypes/ns.type1/entities/ns.entity1".
to_entity (str): The resource name of the end point of the relationship,
for example "entityTypes/ns.type2/entities/ns.entity2".
description (str): One or more paragraphs of text description.
properties (dict): The properties of this entity.
read_only (bool): Whether this resource is read only.
"""

def __init__(
Expand All @@ -32,6 +33,23 @@ def __init__(
properties: Mapping[str, Union[str, bool, int, float]],
read_only: bool = False,
):
"""
Create a relationship resource in the Data API.
Args:
relationship_type: The resource name of the relationship type, for example
"relationshipTypes/namespace.relationshipTypeIdentifier". The
namespace must be empty (being global) or one of the predetermined
namespaces the customer has access to. The relationship type
identifier must match the regex [A-Z][A-Z0-9_]{0,63}.
from_entity: The resource name of the start point of the relationship, for example
"entityTypes/ns.type1/entities/ns.entity1".
to_entity: The resource name of the end point of the relationship, for example
"entityTypes/ns.type2/entities/ns.entity2".
description: One or more paragraphs of text description.
properties: The properties of this entity.
read_only: Whether this resource is read only.
"""
self.relationship_type = relationship_type
self.from_entity = from_entity
self.to_entity = to_entity
Expand Down
29 changes: 21 additions & 8 deletions exabel_data_sdk/client/api/data_classes/relationship_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ class RelationshipType:
A relationship type resource in the Data API.
Attributes:
name: The resource name of the relationship type, for example
"relationshipTypes/namespace.relationshipTypeIdentifier". The namespace must be
empty (being global) or one of the predetermined namespaces the customer has
access to. The relationship type identifier must match the regex
[A-Z][A-Z0-9_]{0,63}.
description: One or more paragraphs of text description.
properties: The properties of this entity.
read_only: Whether this resource is read only.
name (str): The resource name of the relationship type, for example
"relationshipTypes/namespace.relationshipTypeIdentifier". The namespace
must be empty (being global) or one of the predetermined namespaces
the customer has access to. The relationship type identifier must
match the regex [A-Z][A-Z0-9_]{0,63}.
description (str): One or more paragraphs of text description.
properties (dict): The properties of this entity.
read_only (bool): Whether this resource is read only.
"""

def __init__(
Expand All @@ -28,6 +28,19 @@ def __init__(
properties: Mapping[str, Union[str, bool, int, float]],
read_only: bool = False,
):
"""
Create a relationship type resource in the Data API.
Args:
name: The resource name of the relationship type, for example
"relationshipTypes/namespace.relationshipTypeIdentifier". The namespace
must be empty (being global) or one of the predetermined namespaces the
customer has access to. The relationship type identifier must match the
regex [A-Z][A-Z0-9_]{0,63}.
description: One or more paragraphs of text description.
properties: The properties of this entity.
read_only: Whether this resource is read only.
"""
self.name = name
self.description = description
self.properties = properties
Expand Down
12 changes: 9 additions & 3 deletions exabel_data_sdk/client/api/data_classes/request_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,21 @@ class ErrorType(Enum):


class RequestError(Exception):
"""Represents an error returned from the Exabel Api."""
"""
Represents an error returned from the Exabel Api.
Attributes:
error_type (ErrorType): Type of error.
message (str): Exception message.
"""

def __init__(self, error_type: ErrorType, message: str = None):
"""
Create a new RequestError.
Args:
error_type: type of error
message: exception message
error_type: Type of error.
message: Exception message.
"""
super().__init__(message)
self.error_type = error_type
Expand Down
27 changes: 20 additions & 7 deletions exabel_data_sdk/client/api/data_classes/signal.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ class Signal:
A signal resource in the Data API.
Attributes:
name: The resource name of the signal, for example "signals/signalIdentifier" or
"signals/namespace.signalIdentifier". The namespace must be empty (being
global) or one of the predetermined namespaces the customer has access to. The
signal identifier must match the regex [a-zA-Z]\w{0,63}.
display_name: The display name of the signal.
description: One or more paragraphs of text description.
read_only: Whether this Signal is read only.
name (str): The resource name of the signal, for example
"signals/signalIdentifier" or "signals/namespace.signalIdentifier".
The namespace must be empty (being global) or one of the
predetermined namespaces the customer has access to. The signal
identifier must match the regex [a-zA-Z]\w{0,63}.
display_name (str): The display name of the signal.
description (str): One or more paragraphs of text description.
read_only (bool): Whether this Signal is read only.
"""

def __init__(
Expand All @@ -23,6 +24,18 @@ def __init__(
description: str,
read_only: bool = False,
):
r"""
Create a signal resource in the Data API.
Args:
name: The resource name of the signal, for example "signals/signalIdentifier" or
"signals/namespace.signalIdentifier". The namespace must be empty (being
global) or one of the predetermined namespaces the customer has access
to. The signal identifier must match the regex [a-zA-Z]\w{0,63}.
display_name: The display name of the signal.
description: One or more paragraphs of text description.
read_only: Whether this Signal is read only.
"""
self.name = name
self.display_name = display_name
self.description = description
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="exabel-data-sdk",
version="0.0.17",
version="0.0.18",
author="Exabel",
author_email="[email protected]",
description="Python SDK for the Exabel Data API",
Expand Down

0 comments on commit 40bfeae

Please sign in to comment.