Пример #1
0
    def get(self, *args, **kwargs):
        """ Lists all the tenants requested. Returns 404 if the requested
        tenant does not exists.

        Args:
            tenant_id: network name of a tenant

        Example URLs:

            GET /api/v1/pending
            GET /api/v1/pending/TenantName

        """

        try:
            if len(args) > 1:
                raise ValueError("Invalid url")
            if len(args) == 0:
                user = self.get_argument("user", default=None)
                if user:
                    pendings = RUNTIME.load_pending_tenants(user)
                else:
                    pendings = RUNTIME.load_pending_tenants()
                self.write(json.dumps(pendings, cls=EmpowerEncoder))
            else:
                tenant_id = UUID(args[0])
                pending = RUNTIME.load_pending_tenant(tenant_id)
                self.write(json.dumps(pending, cls=EmpowerEncoder))
        except ValueError as ex:
            self.send_error(400, message=ex)
        except KeyError as ex:
            self.send_error(404, message=ex)
Пример #2
0
    def get(self, *args, **kwargs):
        """ Lists all the tenants requested. Returns 404 if the requested
        tenant does not exists.

        Args:
            tenant_id: network name of a tenant

        Example URLs:

            GET /api/v1/pending
            GET /api/v1/pending/TenantName

        """

        try:
            if len(args) > 1:
                raise ValueError("Invalid url")
            if len(args) == 0:
                user = self.get_argument("user", default=None)
                if user:
                    pendings = RUNTIME.load_pending_tenants(user)
                else:
                    pendings = RUNTIME.load_pending_tenants()
                self.write_as_json(pendings)
            else:
                tenant_id = UUID(args[0])
                pending = RUNTIME.load_pending_tenant(tenant_id)
                self.write_as_json(pending)
        except ValueError as ex:
            self.send_error(400, message=ex)
        except KeyError as ex:
            self.send_error(404, message=ex)
Пример #3
0
    def delete(self, *args, **kwargs):
        """ Delete a tenant request.

        Args:
            tenant_id: network name of a tenant

        Example URLs:

            PUT /api/v1/pending/52313ecb-9d00-4b7d-b873-b55d3d9ada26

        """

        try:

            if len(args) == 0:

                pendings = RUNTIME.load_pending_tenants()

                for pending in pendings:
                    RUNTIME.reject_tenant(pending.tenant_id)

            else:

                tenant_id = UUID(args[0])
                RUNTIME.reject_tenant(tenant_id)

        except ValueError as ex:
            self.send_error(400, message=ex)
        except KeyError as ex:
            self.send_error(404, message=ex)
        self.set_status(204, None)
Пример #4
0
    def delete(self, *args, **kwargs):
        """ Delete a tenant request.

        Args:
            tenant_id: network name of a tenant

        Example URLs:

            PUT /api/v1/pending/52313ecb-9d00-4b7d-b873-b55d3d9ada26

        """

        try:

            if len(args) == 0:

                pendings = RUNTIME.load_pending_tenants()

                for pending in pendings:
                    RUNTIME.reject_tenant(pending.tenant_id)

            else:

                tenant_id = UUID(args[0])
                RUNTIME.reject_tenant(tenant_id)

        except ValueError as ex:
            self.send_error(400, message=ex)
        except KeyError as ex:
            self.send_error(404, message=ex)
        self.set_status(204, None)