Exemplo n.º 1
0
 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)
Exemplo n.º 2
0
 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"]
Exemplo n.º 3
0
 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)
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
 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)
Exemplo n.º 6
0
 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"]
Exemplo n.º 7
0
 def _delete_agent(self, agent_id):
     url = "{}/iofog/{}".format(self.base_path, agent_id)
     request("DELETE", url, self.token)
Exemplo n.º 8
0
 def _get_provision_key(self, agent_id):
     url = "{}/iofog/{}/provisioning-key".format(self.base_path, agent_id)
     return request("GET", url, self.token)["key"]
Exemplo n.º 9
0
 def get_status(self):
     url = "{}/status".format(self.base_path)
     return request("GET", url)
Exemplo n.º 10
0
 def _login(self, email, password):
     url = "{}/user/login".format(self.base_path)
     body = {"email": email, "password": password}
     self.token = request("POST", url, "", body)["accessToken"]
Exemplo n.º 11
0
 def get_app(self, name):
     url = "{}/application/{}".format(self.base_path, name)
     return request("GET", url, self.token)
Exemplo n.º 12
0
 def delete_app(self, name):
     url = "{}/application/{}".format(self.base_path, name)
     return request("DELETE", url, self.token)