Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def load(self):
http_client = FidoClientGlobalHeaders(headers=self.headers)
loader = Loader(http_client)
protocol = "https" if self.apikey else "http"
origin_url = f"{protocol}://{self.host}/apispec.json"
spec_dict = loader.load_spec(origin_url)
spec_dict["host"] = self.host
spec_dict["schemes"] = [protocol]
config = {
"validate_responses": False,
"use_models": False,
"include_missing_properties": False,
"formats": [email_format, url_format],
}
bravado_config = bravado_config_from_config_dict(config)
for key in set(bravado_config._fields).intersection(set(config)):
del config[key]
config["bravado"] = bravado_config
swagger_spec = Spec.from_dict(spec_dict, origin_url, http_client, config)
super().__init__(
swagger_spec, also_return_response=bravado_config.also_return_response
)
# expand regex-based query parameters for `data` columns
try:
resp = self.projects.get_entries(_fields=["columns"]).result()
except AttributeError:
# skip in tests
return
@property
def _bravado_config(self):
# type: () -> BravadoConfig
if self.operation:
return self.operation.swagger_spec.config['bravado']
else:
return bravado_config_from_config_dict(CONFIG_DEFAULTS)
config=None):
"""
Build a :class:`SwaggerClient` from a Swagger spec in dict form.
:param spec_dict: a dict with a Swagger spec in json-like form
:param origin_url: the url used to retrieve the spec_dict
:type origin_url: str
:param config: Configuration dict - see spec.CONFIG_DEFAULTS
:rtype: :class:`SwaggerClient`
"""
http_client = http_client or RequestsClient()
config = config or {}
# Apply bravado config defaults
bravado_config = bravado_config_from_config_dict(config)
# remove bravado configs from config dict
for key in set(bravado_config._fields).intersection(set(config)):
del config[key]
# set bravado config object
config['bravado'] = bravado_config
swagger_spec = Spec.from_dict(
spec_dict, origin_url, http_client, config,
)
return cls(swagger_spec, also_return_response=bravado_config.also_return_response)
LOG.error('Server Unavailable')
raise bgwe
else:
LOG.debug(f'getting OIDC session on realm {realm}')
http_client = OauthClient()
http_client.set_oauth(
url_info.netloc,
keycloak_url or f'{server}/auth', realm,
user, pw, offline_token, endpoint_name)
spec_url = _SPEC_URL.format(f'{server}/{realm}/{endpoint_name}')
spec_dict = http_client.authenticator.get_spec(spec_url)
# We take this from the from_url class method of SwaggerClient
# Apply bravado config defaults
bravado_config = bravado_config_from_config_dict(config)
# remove bravado configs from config dict
for key in set(bravado_config._fields).intersection(set(config)):
del config[key]
# set bravado config object
config['bravado'] = bravado_config
swagger_spec = bravado_core.spec.Spec.from_dict(
spec_dict, spec_url, http_client, config)
self.__also_return_response = True
self.swagger_spec = swagger_spec
super(Client, self).__init__(
swagger_spec, also_return_response=self.__also_return_response)