Skip to content

Commit

Permalink
[Tables] Updates for apiview & sphinx docs (#18134)
Browse files Browse the repository at this point in the history
  • Loading branch information
seankane-msft authored Apr 23, 2021
1 parent 7b7b334 commit 24c75af
Show file tree
Hide file tree
Showing 12 changed files with 224 additions and 224 deletions.
2 changes: 1 addition & 1 deletion sdk/tables/azure-data-tables/azure/data/tables/_entity.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def __getattr__(self, name):
:param name:name of entity entry
:type name: str
:return: TableEntity dictionary
:rtype: dict[str,str]
:rtype: Dict[str,str]
"""
try:
return self[name]
Expand Down
65 changes: 44 additions & 21 deletions sdk/tables/azure-data-tables/azure/data/tables/_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# license information.
# --------------------------------------------------------------------------
from enum import Enum
from typing import TYPE_CHECKING

from azure.core.exceptions import HttpResponseError
from azure.core.paging import PageIterator

Expand All @@ -22,6 +24,11 @@
from ._error import _process_table_error
from ._constants import NEXT_PARTITION_KEY, NEXT_ROW_KEY, NEXT_TABLE_NAME

if TYPE_CHECKING:
from ._generated.models import TableQueryResponse
from azure.core.pipeline.transport import HttpResponse
from typing import Any, Dict, List


class TableServiceStats(GenTableServiceStats):
"""Stats for the service
Expand Down Expand Up @@ -133,7 +140,7 @@ class Metrics(GeneratedMetrics):
:keyword str version: The version of Storage Analytics to configure.
:keyword bool enabled: Required. Indicates whether metrics are enabled for the service.
:keyword bool include_ap_is: Indicates whether metrics should generate summary
:keyword bool include_apis: Indicates whether metrics should generate summary
statistics for called API operations.
:keyword ~azure.data.tables.RetentionPolicy retention_policy: Required.
The retention policy for the metrics.
Expand All @@ -150,7 +157,7 @@ def __init__( # pylint: disable=super-init-not-called

@classmethod
def _from_generated(cls, generated):
# type: (...) -> cls
# type: (...) -> Metrics
"""A summary of request statistics grouped by API in hour or minute aggregates.
:param Metrics generated: generated Metrics
Expand Down Expand Up @@ -194,7 +201,7 @@ def __init__( # pylint: disable=super-init-not-called

@classmethod
def _from_generated(cls, generated, **kwargs): # pylint: disable=unused-argument
# type: (...) -> cls
# type: (GeneratedRetentionPolicy, Dict[str, Any]) -> RetentionPolicy
"""The retention policy which determines how long the associated data should
persist.
Expand Down Expand Up @@ -400,12 +407,15 @@ def __init__(
self.delete = kwargs.pop("delete", None) or ("d" in _str)

def __or__(self, other):
# type: (TableSasPermissions) -> TableSasPermissions
return TableSasPermissions(_str=str(self) + str(other))

def __add__(self, other):
# type: (TableSasPermissions) -> TableSasPermissions
return TableSasPermissions(_str=str(self) + str(other))

def __str__(self):
# type: () -> TableSasPermissions
return (
("r" if self.read else "")
+ ("a" if self.add else "")
Expand All @@ -416,9 +426,10 @@ def __str__(self):
@classmethod
def from_string(
cls,
permission, # type: str
permission,
**kwargs
):
# Type: (str, Dict[str, Any]) -> AccountSasPermissions
"""Create AccountSasPermissions from a string.
To specify read, write, delete, etc. permissions you need only to
Expand All @@ -428,8 +439,8 @@ def from_string(
:param str permission: Specify permissions in
the string with the first letter of the word.
:keyword callable cls: A custom type or function that will be passed the direct response
:return: A AccountSasPermissions object
:rtype: ~azure.data.tables.AccountSasPermissions
:return: An AccountSasPermissions object
:rtype: :class:`~azure.data.tables.AccountSasPermissions`
"""
p_read = "r" in permission
p_add = "a" in permission
Expand Down Expand Up @@ -477,23 +488,28 @@ def service_properties_deserialize(generated):

class TableItem(object):
"""
Represents an Azure TableItem. Returned by TableServiceClient.list_tables
and TableServiceClient.query_tables.
Represents an Azure TableItem.
Returned by TableServiceClient.list_tables and TableServiceClient.query_tables.
:param str name: The name of the table.
:ivar str name: The name of the table.
:ivar str api_version: The API version included in the service call
:ivar str date: The date the service call was made
"""

def __init__(self, name, **kwargs):
# type: (str, **Any) -> None
# type: (str, Dict[str, Any]) -> None
"""
:param str name: Name of the Table
:keyword str api_version: The API version included in the service call
:keyword str date: The date the service call was made
"""
self.name = name
self.api_version = kwargs.get("version")
self.date = kwargs.get("date") or kwargs.get("Date")

@classmethod
def _from_generated(cls, generated, **kwargs):
# type: (obj, **Any) -> cls
# type: (TableQueryResponse, Dict[str, Any]) -> TableItem
return cls(generated.table_name, **kwargs)


Expand Down Expand Up @@ -541,12 +557,18 @@ class SASProtocol(str, Enum):
class BatchErrorException(HttpResponseError):
"""There is a failure in batch operations.
:param str message: The message of the exception.
:param message: The message of the exception.
:type message: str
:param response: Server response to be deserialized.
:param list parts: A list of the parts in multipart response.
:type response: str
:param parts: A list of the parts in multipart response.
:type parts: ~azure.core.pipeline.transport.HttpResponse
:param args: Args to be passed through
:type args: List[:class:`~azure.core.pipeline.transport.HttpResponse`]
"""

def __init__(self, message, response, parts, *args, **kwargs):
# type: (str, str, HttpResponse, List[HttpResponse], Dict[str, Any]) -> None
self.parts = parts
super(BatchErrorException, self).__init__(
message=message, response=response, *args, **kwargs
Expand Down Expand Up @@ -577,9 +599,8 @@ class ResourceTypes(object):
Access to object-level APIs for tables (e.g. Get/Create/Query Entity etc.)
"""

def __init__(
self, service=False, object=False
): # pylint: disable=redefined-builtin
def __init__(self, service=False, object=False): # pylint: disable=redefined-builtin
# type: (bool, bool) -> None
self.service = service
self.object = object
self._str = ("s" if self.service else "") + ("o" if self.object else "")
Expand All @@ -589,6 +610,7 @@ def __str__(self):

@classmethod
def from_string(cls, string):
# type: (str) -> ResourceTypes
"""Create a ResourceTypes from a string.
To specify service, container, or object you need only to
Expand All @@ -598,7 +620,7 @@ def from_string(cls, string):
:param str string: Specify service, container, or object in
in the string with the first letter of the word.
:return: A ResourceTypes object
:rtype: ~azure.data.tables.ResourceTypes
:rtype: :class:`~azure.data.tables.ResourceTypes`
"""
res_service = "s" in string
res_object = "o" in string
Expand Down Expand Up @@ -664,17 +686,18 @@ def __str__(self):

@classmethod
def from_string(cls, permission, **kwargs):
# type: (str, Dict[str]) -> AccountSasPermissions
"""Create AccountSasPermissions from a string.
To specify read, write, delete, etc. permissions you need only to
include the first letter of the word in the string. E.g. for read and write
permissions you would provide a string "rw".
:param str permission: Specify permissions in
the string with the first letter of the word.
:param permission: Specify permissions in the string with the first letter of the word.
:type permission: str
:keyword callable cls: A custom type or function that will be passed the direct response
:return: A AccountSasPermissions object
:rtype: ~azure.data.tables.AccountSasPermissions
:return: An AccountSasPermissions object
:rtype: :class:`~azure.data.tables.AccountSasPermissions`
"""
p_read = "r" in permission
p_write = "w" in permission
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def send(self, request):
:param request: The PipelineRequest object
:type request: ~azure.core.pipeline.PipelineRequest
:return: Returns the PipelineResponse or raises error if maximum retries exceeded.
:rtype: ~azure.core.pipeline.PipelineResponse
:rtype: :class:`~azure.core.pipeline.PipelineResponse`
:raises: ~azure.core.exceptions.AzureError if maximum retries exceeded.
:raises: ~azure.core.exceptions.ClientAuthenticationError if authentication
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def _parameter_filter_substitution(parameters, query_filter):
# type: (Dict[str, str], str) -> str
"""Replace user defined parameter in filter
:param parameters: User defined parameters
:param filter: Filter for querying
:param str query_filter: Filter for querying
"""
if parameters:
filter_strings = query_filter.split(' ')
Expand Down
13 changes: 7 additions & 6 deletions sdk/tables/azure-data-tables/azure/data/tables/_table_batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ def create_entity(
:param entity: The properties for the table entity.
:type entity: TableEntity or dict[str,str]
:return: None
:rtype: None
:raises ValueError:
.. admonition:: Example:
Expand Down Expand Up @@ -212,8 +213,10 @@ def update_entity(
:param mode: Merge or Replace entity
:type mode: ~azure.data.tables.UpdateMode
:keyword str etag: Etag of the entity
:keyword ~azure.core.MatchConditions match_condition: MatchCondition
:keyword match_condition: MatchCondition
:paramtype match_condition: ~azure.core.MatchCondition
:return: None
:rtype: None
:raises ValueError:
.. admonition:: Example:
Expand Down Expand Up @@ -298,7 +301,6 @@ def _batch_update_entity(
:type query_options: ~azure.data.tables.models.QueryOptions
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

_format = None
Expand Down Expand Up @@ -406,7 +408,6 @@ def _batch_merge_entity(
:type query_options: ~azure.data.tables.models.QueryOptions
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

_format = None
Expand Down Expand Up @@ -492,7 +493,8 @@ def delete_entity(
:param row_key: The row key of the entity.
:type row_key: str
:keyword str etag: Etag of the entity
:keyword ~azure.core.MatchConditions match_condition: MatchCondition
:keyword match_condition: MatchCondition
:paramtype match_condition: ~azure.core.MatchCondition
:raises ValueError:
.. admonition:: Example:
Expand Down Expand Up @@ -561,7 +563,6 @@ def _batch_delete_entity(
:type query_options: ~azure.data.tables.models.QueryOptions
:return: None
:rtype: None
:raises ~azure.core.exceptions.HttpResponseError:
"""

_format = None
Expand Down Expand Up @@ -632,7 +633,7 @@ def upsert_entity(
:param entity: The properties for the table entity.
:type entity: TableEntity or dict[str,str]
:param mode: Merge or Replace and Insert on fail
:param mode: Merge or Replace entity
:type mode: ~azure.data.tables.UpdateMode
:raises ValueError:
Expand Down
Loading

0 comments on commit 24c75af

Please sign in to comment.