def all(client=RestClient()): res = client.session.get(API.get_endpoint(), verify=client.verify) if not res.status_code == 200: print(res.json()) raise Exception("Error getting APIs list") print("Status code: {}".format(res.status_code)) return [API(**api) for api in res.json()['list']]
def get(cls, resource_id, client=RestClient()): res = client.session.get(cls.get_endpoint() + "/{}".format(resource_id), verify=client.verify) if res.status_code != 200: print("Warning Error while getting the Resource {}\nERROR: {}". format(resource_id, res.content)) print("Status code: {}".format(res.status_code)) return cls(**res.json())
def delete_all(client=RestClient()): res = client.session.get(Application.get_endpoint(), verify=client.verify) if not res.status_code == 200: print(res.json()) raise Exception("Error getting Applications list") print("Status code: {}".format(res.status_code)) apps_list = res.json()['list'] for app in apps_list: res = client.session.delete(Application.get_endpoint() + "/{}".format(app['applicationId']), verify=client.verify) if res.status_code != 200: print("Warning Error while deleting the API {}\nERROR: {}".format(app['name'], res.content)) print("Status code: {}".format(res.status_code))
def set_rest_client(self, client=RestClient()): self.client = client
def __init__(self, debug=True): self.debub = debug self.client = RestClient() # TODO: Move this to map to make it extensible self.store_client = RestClient("store")
def set_rest_client(self, client=RestClient(APPLICATION)): self.client = client