-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from eddeleon/eddeleon/gen_sdk
Generate the client from the Open API definition
- Loading branch information
Showing
9 changed files
with
258 additions
and
0 deletions.
There are no files selected for viewing
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from .rest_client import RestClient | ||
from .version import VERSION | ||
|
||
__all__ = ['RestClient'] | ||
|
||
__version__ = VERSION | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from .project_run_details import ProjectRunDetails | ||
from .executerun_ok_response import ExecuterunOKResponse | ||
|
||
__all__ = [ | ||
'ProjectRunDetails', | ||
'ExecuterunOKResponse', | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from msrest.serialization import Model | ||
|
||
|
||
class ExecuterunOKResponse(Model): | ||
"""ExecuterunOKResponse. | ||
:param result: Json string result, TODO release document | ||
:type result: str | ||
""" | ||
|
||
_attribute_map = { | ||
'result': {'key': 'result', 'type': 'str'}, | ||
} | ||
|
||
def __init__(self, result=None): | ||
super(ExecuterunOKResponse, self).__init__() | ||
self.result = result |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from msrest.serialization import Model | ||
|
||
|
||
class ProjectRunDetails(Model): | ||
"""ProjectRunDetails. | ||
:param project_uri: Git url of the project | ||
:type project_uri: str | ||
:param params: Input parameters of the project | ||
:type params: str | ||
""" | ||
|
||
_attribute_map = { | ||
'project_uri': {'key': 'project_uri', 'type': 'str'}, | ||
'params': {'key': 'params', 'type': 'str'}, | ||
} | ||
|
||
def __init__(self, project_uri=None, params=None): | ||
super(ProjectRunDetails, self).__init__() | ||
self.project_uri = project_uri | ||
self.params = params |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
from msrest.service_client import ServiceClient | ||
from msrest import Configuration, Serializer, Deserializer | ||
from .version import VERSION | ||
from msrest.pipeline import ClientRawResponse | ||
from msrest.exceptions import HttpOperationError | ||
from . import models | ||
|
||
|
||
class RestClientConfiguration(Configuration): | ||
"""Configuration for RestClient | ||
Note that all parameters used to create this instance are saved as instance | ||
attributes. | ||
:param credentials: Subscription credentials which uniquely identify | ||
client subscription. | ||
:type credentials: None | ||
:param str base_url: Service URL | ||
""" | ||
|
||
def __init__( | ||
self, credentials, base_url=None): | ||
|
||
if credentials is None: | ||
raise ValueError("Parameter 'credentials' must not be None.") | ||
if not base_url: | ||
base_url = '/api' | ||
|
||
super(RestClientConfiguration, self).__init__(base_url) | ||
|
||
self.add_user_agent('restclient/{}'.format(VERSION)) | ||
|
||
self.credentials = credentials | ||
|
||
|
||
class RestClient(object): | ||
"""This is the Open API specification of the Burdock service. | ||
:ivar config: Configuration for client. | ||
:vartype config: RestClientConfiguration | ||
:param credentials: Subscription credentials which uniquely identify | ||
client subscription. | ||
:type credentials: None | ||
:param str base_url: Service URL | ||
""" | ||
|
||
def __init__( | ||
self, credentials, base_url=None): | ||
|
||
self.config = RestClientConfiguration(credentials, base_url) | ||
self._client = ServiceClient(self.config.credentials, self.config) | ||
|
||
client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} | ||
self.api_version = '0.0.1' | ||
self._serialize = Serializer(client_models) | ||
self._deserialize = Deserializer(client_models) | ||
|
||
|
||
def executerun( | ||
self, details, custom_headers=None, raw=False, **operation_config): | ||
"""Execute a differentially private module. | ||
Create a run of the specified module and return the results. | ||
:param details: Configuration for the module run. | ||
:type details: ~restclient.models.ProjectRunDetails | ||
:param dict custom_headers: headers that will be added to the request | ||
:param bool raw: returns the direct response alongside the | ||
deserialized response | ||
:param operation_config: :ref:`Operation configuration | ||
overrides<msrest:optionsforoperations>`. | ||
:return: ExecuterunOKResponse or ClientRawResponse if raw=true | ||
:rtype: ~restclient.models.ExecuterunOKResponse or | ||
~msrest.pipeline.ClientRawResponse | ||
:raises: | ||
:class:`HttpOperationError<msrest.exceptions.HttpOperationError>` | ||
""" | ||
# Construct URL | ||
url = self.executerun.metadata['url'] | ||
|
||
# Construct parameters | ||
query_parameters = {} | ||
|
||
# Construct headers | ||
header_parameters = {} | ||
header_parameters['Content-Type'] = 'application/json; charset=utf-8' | ||
if custom_headers: | ||
header_parameters.update(custom_headers) | ||
|
||
# Construct body | ||
body_content = self._serialize.body(details, 'ProjectRunDetails') | ||
|
||
# Construct and send request | ||
request = self._client.post(url, query_parameters) | ||
response = self._client.send( | ||
request, header_parameters, body_content, stream=False, **operation_config) | ||
|
||
if response.status_code not in [200]: | ||
raise HttpOperationError(self._deserialize, response) | ||
|
||
deserialized = None | ||
|
||
if response.status_code == 200: | ||
deserialized = self._deserialize('ExecuterunOKResponse', response) | ||
|
||
if raw: | ||
client_raw_response = ClientRawResponse(deserialized, response) | ||
return client_raw_response | ||
|
||
return deserialized | ||
executerun.metadata = {'url': '/execute'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# coding=utf-8 | ||
# -------------------------------------------------------------------------- | ||
# Code generated by Microsoft (R) AutoRest Code Generator. | ||
# Changes may cause incorrect behavior and will be lost if the code is | ||
# regenerated. | ||
# -------------------------------------------------------------------------- | ||
|
||
VERSION = "1.5.0" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
"""Setup file for differential privacy package.""" | ||
from setuptools import setup, find_packages | ||
import os | ||
import shutil | ||
|
||
_major = "0.1" | ||
_minor = "0.1" | ||
|
||
VERSION = "{}.{}".format(_major, _minor) | ||
SELFVERSION = VERSION | ||
if os.path.exists("patch.version"): | ||
with open("patch.version", "rt") as bf: | ||
_patch = str(bf.read()).strip() | ||
SELFVERSION = "{}.{}".format(VERSION, _patch) | ||
|
||
DEPENDENCIES = [ | ||
"numpy", | ||
"pandas", | ||
"scikit-learn", | ||
"msrest", | ||
"antlr4-python3-runtime" | ||
] | ||
|
||
EXTRAS = { } | ||
|
||
with open("README.md", "r", encoding="utf-8") as f: | ||
README = f.read() | ||
HISTORY = "" | ||
inline_license = "" | ||
|
||
setup( | ||
name="burdock", | ||
|
||
version=SELFVERSION, | ||
|
||
description="", | ||
long_description=README + "\n\n" + HISTORY, | ||
long_description_content_type="text/x-rst", | ||
author="burdock", | ||
license=inline_license, | ||
packages=find_packages(exclude=["*.tests"]), | ||
|
||
install_requires=DEPENDENCIES, | ||
|
||
include_package_data=True, | ||
|
||
extras_require=EXTRAS, | ||
|
||
data_files=[], | ||
zip_safe=False | ||
) |