-
Notifications
You must be signed in to change notification settings - Fork 13
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 #16 from kiali/swagger-metadata
KIALI-1766 - Using Swagger to generate Kiali Client
- Loading branch information
Showing
14 changed files
with
395 additions
and
655 deletions.
There are no files selected for viewing
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 @@ | ||
Pipfile.lock |
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,17 @@ | ||
[[source]] | ||
url = "https://pypi.org/simple" | ||
verify_ssl = true | ||
name = "pypi" | ||
|
||
[packages] | ||
requests = "*" | ||
pytest = "*" | ||
pyyaml = "*" | ||
swagger-parser = "*" | ||
pytest-cov = "*" | ||
|
||
[dev-packages] | ||
pylint = "*" | ||
|
||
[requires] | ||
python_version = "3.7" |
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
This file was deleted.
Oops, something went wrong.
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 @@ | ||
from __future__ import unicode_literals | ||
|
||
from abc import ABC | ||
import urllib3 | ||
import requests | ||
import requests.utils | ||
from requests.auth import HTTPBasicAuth | ||
|
||
|
||
class KialiApiConnector(ABC): | ||
|
||
def __init__(self, hostname, port, scheme, verify, auth, max_retries): | ||
self.hostname = hostname | ||
self.port = port | ||
self.scheme = scheme | ||
self.auth = auth | ||
self.verify = verify | ||
self.max_retries = max_retries | ||
|
||
def retrieve_url(self, path): | ||
return requests.utils.urlunparse((self.scheme, (self.hostname + ":" +str(self.port)), path, None, None, None)) | ||
|
||
def get(self, url, params=None): | ||
url = self.retrieve_url(url) | ||
session = requests.Session() | ||
session.auth = self.auth | ||
requests.adapters.HTTPAdapter(max_retries=self.max_retries) | ||
session.headers.update({'Host': self.hostname, 'Content-Type': 'application/json'}) | ||
return session.get(url, verify=self.verify, params=params) | ||
|
||
|
||
class KialiHTTPSApiConnector(KialiApiConnector): | ||
""" | ||
Creates new client for Kiali based on HTTPS | ||
""" | ||
|
||
def __init__(self, hostname, port, scheme, username, password, verify, max_retries): | ||
|
||
super().__init__(hostname=hostname, port=port, scheme=scheme, | ||
auth=HTTPBasicAuth(username, password), verify=verify, max_retries=max_retries) | ||
|
||
|
||
class KialiNoAuthApiConnector(KialiApiConnector): | ||
""" | ||
Creates new client for Kiali based on HTTPS | ||
""" | ||
|
||
def __init__(self, hostname, port, scheme, verify): | ||
super().__init__(hostname=hostname, port=port, scheme=scheme, | ||
auth=None, verify=verify) | ||
|
Oops, something went wrong.