def create_user(self, email, password, name, surname): url = "{}/user/signup".format(self.base_path) body = { "email": email, "password": password, "lastName": name, "firstName": surname } return request("POST", url, "", body)
def create_agent(self, name, host, arch=""): fog_type_id = 0 if arch != "": if arch not in ["x86", "arm"]: raise Exception( "Agent architecture {} not supported".format(arch)) fog_type_id = 1 if arch == "x86" else 2 url = "{}/iofog".format(self.base_path) body = {"name": name, "fogType": fog_type_id, "host": host} return request("POST", url, self.token, body)["uuid"]
def create_app(self, name, msvcs, routes): if routes is None: routes = [] url = "{}/application/".format(self.base_path) body = { "name": name, "routes": routes, "microservices": msvcs, "isActivated": True, "isSystem": False } return request("POST", url, self.token, body)
def patch_agent(self, agent_name, config): uuid = self.get_agent_uuid(agent_name) url = "{}/iofog/{}".format(self.base_path, uuid) return request("PATCH", url, self.token, config)
def upgrade_agent(self, agent_name): uuid = self.get_agent_uuid(agent_name) url = "{}/iofog/{}/version/upgrade".format(self.base_path, uuid) return request("POST", url, self.token)
def get_agent_uuid(self, name): url = "{}/iofog-list".format(self.base_path) resp = request("GET", url, self.token) for fog in resp["fogs"]: if fog["name"] == name: return fog["uuid"]
def _delete_agent(self, agent_id): url = "{}/iofog/{}".format(self.base_path, agent_id) request("DELETE", url, self.token)
def _get_provision_key(self, agent_id): url = "{}/iofog/{}/provisioning-key".format(self.base_path, agent_id) return request("GET", url, self.token)["key"]
def get_status(self): url = "{}/status".format(self.base_path) return request("GET", url)
def _login(self, email, password): url = "{}/user/login".format(self.base_path) body = {"email": email, "password": password} self.token = request("POST", url, "", body)["accessToken"]
def get_app(self, name): url = "{}/application/{}".format(self.base_path, name) return request("GET", url, self.token)
def delete_app(self, name): url = "{}/application/{}".format(self.base_path, name) return request("DELETE", url, self.token)