Skip to content

chore: added check to doc style #128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,12 +94,25 @@ jobs:
pip install twine --user
python setup.py sdist bdist_wheel
twine check dist/*
check-docstyle:
docker:
- image: *default-python
environment:
PIPENV_VENV_IN_PROJECT: true
steps:
- checkout
- run:
name: Checks compliance with Python docstring convention.
command: |
pip install pydocstyle --user
pydocstyle --count influxdb_client

workflows:
version: 2
build:
jobs:
- check-code-style
- check-docstyle
- check-twine
- tests-python:
name: test-3.6
Expand Down
8 changes: 4 additions & 4 deletions influxdb_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
# flake8: noqa

"""
Influx API Service
Influx API Service.

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

OpenAPI spec version: 0.1.0
Generated by: https://openapi-generator.tech
OpenAPI spec version: 0.1.0
Generated by: https://openapi-generator.tech
"""


Expand Down
37 changes: 19 additions & 18 deletions influxdb_client/api_client.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# coding: utf-8
"""
Influx API Service
Influx API Service.

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

OpenAPI spec version: 0.1.0
Generated by: https://openapi-generator.tech
OpenAPI spec version: 0.1.0
Generated by: https://openapi-generator.tech
"""

from __future__ import absolute_import
Expand All @@ -28,7 +28,7 @@


class ApiClient(object):
"""Generic API client for OpenAPI client library builds.
"""Generic API client for OpenAPI client library Build.

OpenAPI generic API client. This client handles the client-
server communication, and is invariant across implementations. Specifics of
Expand Down Expand Up @@ -64,6 +64,7 @@ class ApiClient(object):

def __init__(self, configuration=None, header_name=None, header_value=None,
cookie=None, pool_threads=None):
"""Initialize generic API client."""
if configuration is None:
configuration = Configuration()
self.configuration = configuration
Expand All @@ -78,6 +79,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None,
self.user_agent = 'influxdb-client-python/1.9.0dev'

def __del__(self):
"""Dispose pools."""
if self._pool:
self._pool.close()
self._pool.join()
Expand All @@ -87,23 +89,23 @@ def __del__(self):

@property
def pool(self):
"""Create thread pool on first request
avoids instantiating unused threadpool for blocking clients.
"""
"""Create thread pool on first request avoids instantiating unused threadpool for blocking clients."""
if self._pool is None:
self._pool = ThreadPool(self.pool_threads)
return self._pool

@property
def user_agent(self):
"""User agent for this API client"""
"""User agent for this API client."""
return self.default_headers['User-Agent']

@user_agent.setter
def user_agent(self, value):
"""Set User agent for this API client."""
self.default_headers['User-Agent'] = value

def set_default_header(self, header_name, header_value):
"""Set HTTP header for this API client."""
self.default_headers[header_name] = header_value

def __call_api(
Expand Down Expand Up @@ -186,7 +188,7 @@ def __call_api(
response_data.getheaders())

def sanitize_for_serialization(self, obj):
"""Builds a JSON POST object.
"""Build a JSON POST object.

If obj is None, return None.
If obj is str, int, long, float, bool, return directly.
Expand Down Expand Up @@ -294,7 +296,7 @@ def call_api(self, resource_path, method,
response_type=None, auth_settings=None, async_req=None,
_return_http_data_only=None, collection_formats=None,
_preload_content=True, _request_timeout=None):
"""Makes the HTTP request (synchronous) and returns deserialized data.
"""Make the HTTP request (synchronous) and Return deserialized data.

To make an async_req request, set the async_req parameter.

Expand Down Expand Up @@ -351,7 +353,7 @@ def call_api(self, resource_path, method,
def request(self, method, url, query_params=None, headers=None,
post_params=None, body=None, _preload_content=True,
_request_timeout=None):
"""Makes the HTTP request using RESTClient."""
"""Make the HTTP request using RESTClient."""
if method == "GET":
return self.rest_client.GET(url,
query_params=query_params,
Expand Down Expand Up @@ -440,7 +442,7 @@ def parameters_to_tuples(self, params, collection_formats):
return new_params

def prepare_post_parameters(self, post_params=None, files=None):
"""Builds form parameters.
"""Build form parameters.

:param post_params: Normal form parameters.
:param files: File parameters.
Expand Down Expand Up @@ -468,7 +470,7 @@ def prepare_post_parameters(self, post_params=None, files=None):
return params

def select_header_accept(self, accepts):
"""Returns `Accept` based on an array of accepts provided.
"""Return `Accept` based on an array of accepts provided.

:param accepts: List of headers.
:return: Accept (e.g. application/json).
Expand All @@ -484,7 +486,7 @@ def select_header_accept(self, accepts):
return ', '.join(accepts)

def select_header_content_type(self, content_types):
"""Returns `Content-Type` based on an array of content_types provided.
"""Return `Content-Type` based on an array of content_types provided.

:param content_types: List of content-types.
:return: Content-Type (e.g. application/json).
Expand All @@ -500,7 +502,7 @@ def select_header_content_type(self, content_types):
return content_types[0]

def update_params_for_auth(self, headers, querys, auth_settings):
"""Updates header and query params based on authentication setting.
"""Update header and query params based on authentication setting.

:param headers: Header parameters dict to be updated.
:param querys: Query parameters tuple list to be updated.
Expand All @@ -524,7 +526,7 @@ def update_params_for_auth(self, headers, querys, auth_settings):
)

def __deserialize_file(self, response):
"""Deserializes body to file
"""Deserializes body to file.

Saves response body into a file in a temporary folder,
using the filename from the `Content-Disposition` header if provided.
Expand Down Expand Up @@ -615,7 +617,6 @@ def __deserialize_model(self, data, klass):
:param klass: class literal.
:return: model object.
"""

if not klass.openapi_types and not hasattr(klass,
'get_real_child_model'):
return data
Expand Down
14 changes: 12 additions & 2 deletions influxdb_client/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
from __future__ import absolute_import

# flake8: noqa

"""
Influx API Service.

No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501

OpenAPI spec version: 0.1.0
Generated by: https://openapi-generator.tech
"""


from __future__ import absolute_import

# import apis into api package
from influxdb_client.service.authorizations_service import AuthorizationsService
from influxdb_client.service.buckets_service import BucketsService
Expand Down
38 changes: 26 additions & 12 deletions influxdb_client/client/authorizations_api.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
"""Authorization is about managing the security of your InfluxDB instance."""

from influxdb_client import Authorization, AuthorizationsService, User, Organization


class AuthorizationsApi(object):
"""Implementation for '/api/v2/authorizations' endpoint."""

def __init__(self, influxdb_client):
"""Initialize defaults."""
self._influxdb_client = influxdb_client
self._authorizations_service = AuthorizationsService(influxdb_client.api_client)

def create_authorization(self, org_id=None, permissions: list = None,
authorization: Authorization = None) -> Authorization:
"""
Creates an authorization
Create an authorization.

:type permissions: list of Permission
:param org_id: organization id
:param permissions: list of permissions
Expand All @@ -26,15 +31,17 @@ def create_authorization(self, org_id=None, permissions: list = None,

def find_authorization_by_id(self, auth_id: str) -> Authorization:
"""
Finds authorization by id
Find authorization by id.

:param auth_id: authorization id
:return: Authorization
"""
return self._authorizations_service.get_authorizations_id(auth_id=auth_id)

def find_authorizations(self, **kwargs):
"""
Gets a list of all authorizations
Get a list of all authorizations.

:param str user_id: filter authorizations belonging to a user id
:param str user: filter authorizations belonging to a user name
:param str org_id: filter authorizations belonging to a org id
Expand All @@ -47,58 +54,64 @@ def find_authorizations(self, **kwargs):

def find_authorizations_by_user(self, user: User):
"""
Finds authorization by User
Find authorization by User.

:return: Authorization list
"""
return self.find_authorizations(user_id=user.id)

def find_authorizations_by_user_id(self, user_id: str):
"""
Finds authorization by user id
Find authorization by user id.

:return: Authorization list
"""
return self.find_authorizations(user_id=user_id)

def find_authorizations_by_user_name(self, user_name: str):
"""
Finds authorization by user name
Find authorization by user name.

:return: Authorization list
"""
return self.find_authorizations(user=user_name)

def find_authorizations_by_org(self, org: Organization):
"""
Finds authorization by user name
Find authorization by user name.

:return: Authorization list
"""

if isinstance(org, Organization):
return self.find_authorizations(org_id=org.id)

def find_authorizations_by_org_name(self, org_name: str):
"""
Finds authorization by org name
Find authorization by org name.

:return: Authorization list
"""
return self.find_authorizations(org=org_name)

def find_authorizations_by_org_id(self, org_id: str):
"""
Finds authorization by org id
Find authorization by org id.

:return: Authorization list
"""
return self.find_authorizations(org_id=org_id)

def update_authorization(self, auth):
"""
Updates authorization object
Update authorization object.

:param auth:
:return:
"""
return self._authorizations_service.patch_authorizations_id(auth_id=auth.id, authorization_update_request=auth)

def clone_authorization(self, auth) -> Authorization:

"""Clone an authorization."""
if isinstance(auth, Authorization):
cloned = Authorization(org_id=auth.org_id, permissions=auth.permissions)
# cloned.description = auth.description
Expand All @@ -112,6 +125,7 @@ def clone_authorization(self, auth) -> Authorization:
raise ValueError("Invalid argument")

def delete_authorization(self, auth):
"""Delete a authorization."""
if isinstance(auth, Authorization):
return self._authorizations_service.delete_authorizations_id(auth_id=auth.id)

Expand Down
Loading