本文整理汇总了Python中bravado.client.SwaggerClient.from_url方法的典型用法代码示例。如果您正苦于以下问题:Python SwaggerClient.from_url方法的具体用法?Python SwaggerClient.from_url怎么用?Python SwaggerClient.from_url使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bravado.client.SwaggerClient
的用法示例。
在下文中一共展示了SwaggerClient.from_url方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_kafka_discovery_client
# 需要导入模块: from bravado.client import SwaggerClient [as 别名]
# 或者: from bravado.client.SwaggerClient import from_url [as 别名]
def get_kafka_discovery_client(client_id):
"""Create smartstack-client for kafka_discovery service."""
# Default retry is 1 on response timeout
retry_config = UserFacingRetryConfig(timeout=RESPONSE_TIMEOUT)
swagger_url = get_swagger_url()
swagger_client = SwaggerClient.from_url(
swagger_url,
RequestsClient(),
)
zipkin_wrapped_client = ZipkinClientDecorator(swagger_client)
return SmartStackClient(
zipkin_wrapped_client,
retry_config,
client_name=client_id,
service_name='kafka_discovery',
)
示例2: setup_client
# 需要导入模块: from bravado.client import SwaggerClient [as 别名]
# 或者: from bravado.client.SwaggerClient import from_url [as 别名]
def setup_client(
url: str,
schema: Optional[Dict[str, Any]] = None,
) -> Optional[str]:
"""
:returns: error message, if appropriate.
"""
if get_abstraction().client:
return None
try:
config = {'internally_dereference_refs': True}
if not schema:
client = SwaggerClient.from_url(url, config=config)
else:
client = SwaggerClient.from_spec(schema, origin_url=url, config=config)
except requests.exceptions.ConnectionError:
return 'Unable to connect to server.'
except (
simplejson.errors.JSONDecodeError, # type: ignore
yaml.YAMLError,
HTTPError,
):
return (
'Invalid swagger file. Please check to make sure the '
'swagger file can be found at: {}.'.format(url)
)
except SwaggerValidationError:
return 'Invalid swagger format.'
get_abstraction().client = client
return None
示例3: setup_paasta_api_client
# 需要导入模块: from bravado.client import SwaggerClient [as 别名]
# 或者: from bravado.client.SwaggerClient import from_url [as 别名]
def setup_paasta_api_client():
return SwaggerClient.from_url(get_paasta_api_url())
示例4: __init__
# 需要导入模块: from bravado.client import SwaggerClient [as 别名]
# 或者: from bravado.client.SwaggerClient import from_url [as 别名]
def __init__(self, API_KEY, API_SECRET):
print("websocket start 1")
self.initTradeSide = "Buy"
HOST = "https://www.bitmex.com"
SPEC_URI = HOST + "/api/explorer/swagger.json"
config = {
'use_models': False,
'validate_responses': False,
'also_return_response': True,
}
bitMEX = SwaggerClient.from_url(
SPEC_URI,
config=config)
self.API_KEY = API_KEY
self.API_SECRET = API_SECRET
request_client = RequestsClient()
print("websocket start 2")
request_client.authenticator = APIKeyAuthenticator(HOST, self.API_KEY, self.API_SECRET)
self.bitMEXAuthenticated = SwaggerClient.from_url(
SPEC_URI,
config=config,
http_client=request_client)
print("websocket end")
# Basic authenticated call
print('\n---A basic Position GET:---')
print('The following call requires an API key. If one is not set, it will throw an Unauthorized error.')
self.avgPrice = 0
self.pos = 0
示例5: _get_swagger_client
# 需要导入模块: from bravado.client import SwaggerClient [as 别名]
# 或者: from bravado.client.SwaggerClient import from_url [as 别名]
def _get_swagger_client(self, url):
return SwaggerClient.from_url(
url,
config=dict(
validate_swagger_spec=False,
validate_requests=False,
validate_responses=False,
formats=[uuid_format]
),
http_client=self._http_client)
示例6: schematizer_client
# 需要导入模块: from bravado.client import SwaggerClient [as 别名]
# 或者: from bravado.client.SwaggerClient import from_url [as 别名]
def schematizer_client(self):
"""Returns a bravado client for the schematizer api.
By default, this will connect to a schematizer instance running in the
included docker-compose file.
"""
return SwaggerClient.from_url(
'http://{0}/swagger.json'.format(self.schematizer_host_and_port)
)
示例7: __init__
# 需要导入模块: from bravado.client import SwaggerClient [as 别名]
# 或者: from bravado.client.SwaggerClient import from_url [as 别名]
def __init__(self, url=None, config=DEFAULT_CONFIG, http_client=None, request_headers=None, local=False):
"""
Instantiates :class:`~bravado.client.SwaggerClient`.
For further documentation, refer to the documentation
for :meth:`bravado.client.SwaggerClient.from_url` and
:meth:`bravado.client.SwaggerClient.from_spec`.
:param str url: the URL of a Swagger specification. If ``local``
is True, this should be the base URL of a DOS
implementation (see ``local``).
:param dict config: see :meth:`bravado.client.SwaggerClient`
:param http_client: see :meth:`bravado.client.SwaggerClient`
:param request_headers: see :meth:`beravado.client.SwaggerClient`
:param bool local: set this to True to load the local schema.
If this is True, the ``url`` parameter should
point to the host and base path of the
implementation under test::
Client(url='https://example.com/ga4gh/drs/v1/', local=True)
If False, the ``url`` parameter should point to a
Swagger specification (``swagger.json``).
"""
self._config = config
config['formats'] = [int64_format]
if local:
# :meth:`bravado.client.SwaggerClient.from_spec` takes a schema
# as a Python dictionary, which we can conveniently expose
# via :func:`ga4gh.drs.schema.present_schema`.
schema = ga4gh.drs.schema.present_schema()
# Set schema['host'] and schema['basePath'] to the provided
# values if specified, otherwise leave them as they are
url = urlparse.urlparse(url)
schema['host'] = url.netloc or schema['host']
schema['basePath'] = url.path or schema['basePath']
self.models = SwaggerClient.from_spec(spec_dict=schema,
config=config,
http_client=http_client)
else:
# If ``local=False``, ``url`` is expected to be a ``swagger.json``
swagger_path = '{}/swagger.json'.format(url.rstrip("/"))
self.models = SwaggerClient.from_url(swagger_path,
config=config,
http_client=http_client,
request_headers=request_headers)
self.client = self.models.DataRepositoryService