Skip to content

Commit

Permalink
Merge pull request #16 from kiali/swagger-metadata
Browse files Browse the repository at this point in the history
KIALI-1766 - Using Swagger to generate Kiali Client
  • Loading branch information
mattmahoneyrh authored Dec 5, 2018
2 parents 9212af8 + f41a09d commit 601e0ac
Show file tree
Hide file tree
Showing 14 changed files with 395 additions and 655 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pipfile.lock
17 changes: 17 additions & 0 deletions Pipfile
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"
357 changes: 23 additions & 334 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion kiali/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
See the License for the specific language governing permissions and
limitations under the License.
"""
from kiali.api import KialiClient
from kiali.client import KialiClient
__all__ = ['KialiClient']
86 changes: 0 additions & 86 deletions kiali/api.py

This file was deleted.

51 changes: 51 additions & 0 deletions kiali/api_connector.py
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)

Loading

0 comments on commit 601e0ac

Please sign in to comment.