コード例 #1
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def issue_commission(self, request):
        """Issue a commission

        Keyword arguments:
        request -- commision request (dict)

        In case of success return commission's id (int).
        Otherwise raise an AstakosClientException.

        """
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(request, self.logger)
        try:
            response = self._call_astakos(self.api_commissions,
                                          headers=req_headers,
                                          body=req_body,
                                          method="POST")
        except AstakosClientException as err:
            if err.status == 413:
                raise QuotaLimit(err.message, err.details)
            else:
                raise

        if "serial" in response:
            return response['serial']
        else:
            msg = "issue_commission_core request returned %s. " + \
                  "No serial found" % response
            self.logger.error(msg)
            raise AstakosClientException(msg)
コード例 #2
0
    def resolve_commissions(self, accept_serials, reject_serials):
        """Resolve multiple commissions at once

        Keyword arguments:
        accept_serials  -- commissions to accept (list of ints)
        reject_serials  -- commissions to reject (list of ints)

        In case of success return a dict of dicts describing which
        commissions accepted, which rejected and which failed to
        resolved.

        """
        check_input("resolve_commissions",
                    self.logger,
                    accept_serials=accept_serials,
                    reject_serials=reject_serials)

        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(
            {
                "accept": accept_serials,
                "reject": reject_serials
            }, self.logger)
        return self._call_astakos(self.api_commissions_action,
                                  headers=req_headers,
                                  body=req_body,
                                  method="POST")
コード例 #3
0
    def issue_commission(self, token, request):
        """Issue a commission

        Keyword arguments:
        token   -- service's token (string)
        request -- commision request (dict)

        In case of success return commission's id (int).
        Otherwise raise an AstakosClientException.

        """
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(request, self.logger)
        try:
            response = self._call_astakos(token, copy(API_COMMISSIONS),
                                          req_headers, req_body, "POST")
        except AstakosClientException as err:
            if err.status == 413:
                raise QuotaLimit(err.message, err.details)
            else:
                raise

        if "serial" in response:
            return response['serial']
        else:
            m = "issue_commission_core request returned %s. No serial found" \
                % response
            self.logger.error(m)
            raise AstakosClientException(m)
コード例 #4
0
    def authenticate(self, tenant_name=None):
        """ Authenticate and get services' endpoints

        Keyword arguments:
        tenant_name         -- user's uniq id (optional)

        It returns back the token as well as information about the token
        holder and the services he/she can access (in json format).

        The tenant_name is optional and if it is given it must match the
        user's uuid.

        In case of error raise an AstakosClientException.

        """
        req_headers = {'content-type': 'application/json'}
        body = {'auth': {'token': {'id': self.token}}}
        if tenant_name is not None:
            body['auth']['tenantName'] = tenant_name
        req_body = parse_request(body, self.logger)
        r = self._call_astakos(self.api_tokens,
                               headers=req_headers,
                               body=req_body,
                               method="POST",
                               log_body=False)
        self._fill_endpoints(r)
        return r
コード例 #5
0
    def resolve_commissions(self, token, accept_serials, reject_serials):
        """Resolve multiple commissions at once

        Keyword arguments:
        token           -- service's token (string)
        accept_serials  -- commissions to accept (list of ints)
        reject_serials  -- commissions to reject (list of ints)

        In case of success return a dict of dicts describing which
        commissions accepted, which rejected and which failed to
        resolved.

        """
        check_input("resolve_commissions",
                    self.logger,
                    accept_serials=accept_serials,
                    reject_serials=reject_serials)

        path = copy(API_COMMISSIONS_ACTION)
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(
            {
                "accept": accept_serials,
                "reject": reject_serials
            }, self.logger)
        return self._call_astakos(token, path, req_headers, req_body, "POST")
コード例 #6
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def authenticate(self, tenant_name=None):
        """ Authenticate and get services' endpoints

        Keyword arguments:
        tenant_name         -- user's uniq id (optional)

        It returns back the token as well as information about the token
        holder and the services he/she can access (in json format).

        The tenant_name is optional and if it is given it must match the
        user's uuid.

        In case of error raise an AstakosClientException.

        """
        req_headers = {'content-type': 'application/json'}
        body = {'auth': {'token': {'id': self.token}}}
        if tenant_name is not None:
            body['auth']['tenantName'] = tenant_name
        req_body = parse_request(body, self.logger)
        r = self._call_astakos(self.api_tokens, headers=req_headers,
                               body=req_body, method="POST",
                               log_body=False)
        self._fill_endpoints(r)
        return r
コード例 #7
0
    def issue_commission(self, request):
        """Issue a commission

        Keyword arguments:
        request -- commision request (dict)

        In case of success return commission's id (int).
        Otherwise raise an AstakosClientException.

        """
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(request, self.logger)
        try:
            response = self._call_astakos(self.api_commissions,
                                          headers=req_headers,
                                          body=req_body,
                                          method="POST")
        except AstakosClientException as err:
            if err.status == 413:
                raise QuotaLimit(err.message, err.details)
            else:
                raise

        if "serial" in response:
            return response['serial']
        else:
            msg = "issue_commission_core request returned %s. " + \
                  "No serial found" % response
            self.logger.error(msg)
            raise AstakosClientException(msg)
コード例 #8
0
ファイル: __init__.py プロジェクト: cstavr/synnefo
    def issue_commission(self, token, request):
        """Issue a commission

        Keyword arguments:
        token   -- service's token (string)
        request -- commision request (dict)

        In case of success return commission's id (int).
        Otherwise raise an AstakosClientException.

        """
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(request, self.logger)
        try:
            response = self._call_astakos(token, copy(API_COMMISSIONS),
                                          req_headers, req_body, "POST")
        except AstakosClientException as err:
            if err.status == 413:
                raise QuotaLimit(err.message, err.details)
            else:
                raise

        if "serial" in response:
            return response['serial']
        else:
            m = "issue_commission_core request returned %s. No serial found" \
                % response
            self.logger.error(m)
            raise AstakosClientException(m)
コード例 #9
0
ファイル: __init__.py プロジェクト: cstavr/synnefo
 def _displayname_catalog(self, token, display_names, req_path):
     req_headers = {'content-type': 'application/json'}
     req_body = parse_request({'displaynames': display_names}, self.logger)
     data = self._call_astakos(
         token, req_path, req_headers, req_body, "POST")
     if "displayname_catalog" in data:
         return data.get("displayname_catalog")
     else:
         m = "_displayname_catalog request returned %s. " \
             "No displayname_catalog found" % data
         self.logger.error(m)
         raise AstakosClientException(m)
コード例 #10
0
 def _uuid_catalog(self, token, uuids, req_path):
     req_headers = {'content-type': 'application/json'}
     req_body = parse_request({'uuids': uuids}, self.logger)
     data = self._call_astakos(token, req_path, req_headers, req_body,
                               "POST")
     if "uuid_catalog" in data:
         return data.get("uuid_catalog")
     else:
         m = "_uuid_catalog request returned %s. No uuid_catalog found" \
             % data
         self.logger.error(m)
         raise AstakosClientException(m)
コード例 #11
0
 def _displayname_catalog(self, token, display_names, req_path):
     req_headers = {'content-type': 'application/json'}
     req_body = parse_request({'displaynames': display_names}, self.logger)
     data = self._call_astakos(token, req_path, req_headers, req_body,
                               "POST")
     if "displayname_catalog" in data:
         return data.get("displayname_catalog")
     else:
         m = "_displayname_catalog request returned %s. " \
             "No displayname_catalog found" % data
         self.logger.error(m)
         raise AstakosClientException(m)
コード例 #12
0
ファイル: __init__.py プロジェクト: cstavr/synnefo
 def _uuid_catalog(self, token, uuids, req_path):
     req_headers = {'content-type': 'application/json'}
     req_body = parse_request({'uuids': uuids}, self.logger)
     data = self._call_astakos(
         token, req_path, req_headers, req_body, "POST")
     if "uuid_catalog" in data:
         return data.get("uuid_catalog")
     else:
         m = "_uuid_catalog request returned %s. No uuid_catalog found" \
             % data
         self.logger.error(m)
         raise AstakosClientException(m)
コード例 #13
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def create_project(self, specs):
        """Submit application to create a new project

        Arguments:
        specs -- dict describing a project

        In case of success, return project and application identifiers.
        """
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(specs, self.logger)
        return self._call_astakos(self.api_projects,
                                  headers=req_headers, body=req_body,
                                  method="POST")
コード例 #14
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
 def _displayname_catalog(self, display_names, req_path):
     """Helper function to retrieve display names catalog"""
     req_headers = {'content-type': 'application/json'}
     req_body = parse_request({'displaynames': display_names}, self.logger)
     data = self._call_astakos(req_path, headers=req_headers,
                               body=req_body, method="POST")
     if "displayname_catalog" in data:
         return data.get("displayname_catalog")
     else:
         msg = "_displayname_catalog request returned %s. " \
               "No displayname_catalog found" % data
         self.logger.error(msg)
         raise AstakosClientException(msg)
コード例 #15
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
 def _uuid_catalog(self, uuids, req_path):
     """Helper function to retrieve uuid catalog"""
     req_headers = {'content-type': 'application/json'}
     req_body = parse_request({'uuids': uuids}, self.logger)
     data = self._call_astakos(req_path, headers=req_headers,
                               body=req_body, method="POST")
     if "uuid_catalog" in data:
         return data.get("uuid_catalog")
     else:
         msg = "_uuid_catalog request returned %s. No uuid_catalog found" \
               % data
         self.logger.error(msg)
         raise AstakosClientException(msg)
コード例 #16
0
ファイル: __init__.py プロジェクト: kins299/mycloud
    def join_project(self, project_id):
        """Join a project

        Arguments:
        project_id -- project identifier

        In case of success, return membership identifier.
        """
        req_headers = {'content-type': 'application/json'}
        body = {"join": {"project": project_id}}
        req_body = parse_request(body, self.logger)
        return self._call_astakos(self.api_memberships, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #17
0
ファイル: __init__.py プロジェクト: kins299/mycloud
    def create_project(self, specs):
        """Submit application to create a new project

        Arguments:
        specs -- dict describing a project

        In case of success, return project and application identifiers.
        """
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(specs, self.logger)
        return self._call_astakos(self.api_projects,
                                  headers=req_headers, body=req_body,
                                  method="POST")
コード例 #18
0
ファイル: __init__.py プロジェクト: kins299/mycloud
 def _displayname_catalog(self, display_names, req_path):
     """Helper function to retrieve display names catalog"""
     req_headers = {'content-type': 'application/json'}
     req_body = parse_request({'displaynames': display_names}, self.logger)
     data = self._call_astakos(req_path, headers=req_headers,
                               body=req_body, method="POST")
     if "displayname_catalog" in data:
         return data.get("displayname_catalog")
     else:
         msg = "_displayname_catalog request returned %r. " \
               "No displayname_catalog found" % data
         self.logger.error(msg)
         raise AstakosClientException(message=msg, response=data)
コード例 #19
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def join_project(self, project_id):
        """Join a project

        Arguments:
        project_id -- project identifier

        In case of success, return membership identifier.
        """
        req_headers = {'content-type': 'application/json'}
        body = {"join": {"project": project_id}}
        req_body = parse_request(body, self.logger)
        return self._call_astakos(self.api_memberships, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #20
0
ファイル: __init__.py プロジェクト: kins299/mycloud
 def _uuid_catalog(self, uuids, req_path):
     """Helper function to retrieve uuid catalog"""
     req_headers = {'content-type': 'application/json'}
     req_body = parse_request({'uuids': uuids}, self.logger)
     data = self._call_astakos(req_path, headers=req_headers,
                               body=req_body, method="POST")
     if "uuid_catalog" in data:
         return data.get("uuid_catalog")
     else:
         msg = "_uuid_catalog request returned %r. No uuid_catalog found" \
               % data
         self.logger.error(msg)
         raise AstakosClientException(message=msg, response=data)
コード例 #21
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def get_memberships(self, project=None):
        """Retrieve all accessible memberships

        Arguments:
        project -- filter by project (optional)

        In case of success, return a list of membership descriptions.
        """
        req_headers = {'content-type': 'application/json'}
        body = {"project": project} if project is not None else None
        req_body = parse_request(body, self.logger) if body else None
        return self._call_astakos(self.api_memberships,
                                  headers=req_headers, body=req_body)
コード例 #22
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def enroll_member(self, project_id, email):
        """Enroll a user in a project

        Arguments:
        project_id -- project identifier
        email      -- user identified by email

        In case of success, return membership identifier.
        """
        req_headers = {'content-type': 'application/json'}
        body = {"enroll": {"project": project_id, "user": email}}
        req_body = parse_request(body, self.logger)
        return self._call_astakos(self.api_memberships, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #23
0
ファイル: __init__.py プロジェクト: kins299/mycloud
    def modify_project(self, project_id, specs):
        """Submit application to modify an existing project

        Arguments:
        project_id -- project identifier
        specs      -- dict describing a project

        In case of success, return project and application identifiers.
        """
        path = join_urls(self.api_projects, str(project_id))
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(specs, self.logger)
        return self._call_astakos(path, headers=req_headers,
                                  body=req_body, method="PUT")
コード例 #24
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def modify_project(self, project_id, specs):
        """Submit application to modify an existing project

        Arguments:
        project_id -- project identifier
        specs      -- dict describing a project

        In case of success, return project and application identifiers.
        """
        path = join_urls(self.api_projects, str(project_id))
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(specs, self.logger)
        return self._call_astakos(path, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #25
0
ファイル: __init__.py プロジェクト: kins299/mycloud
    def enroll_member(self, project_id, email):
        """Enroll a user in a project

        Arguments:
        project_id -- project identifier
        email      -- user identified by email

        In case of success, return membership identifier.
        """
        req_headers = {'content-type': 'application/json'}
        body = {"enroll": {"project": project_id, "user": email}}
        req_body = parse_request(body, self.logger)
        return self._call_astakos(self.api_memberships, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #26
0
    def get_memberships(self, project=None):
        """Retrieve all accessible memberships

        Arguments:
        project -- filter by project (optional)

        In case of success, return a list of membership descriptions.
        """
        req_headers = {'content-type': 'application/json'}
        body = {"project": project} if project is not None else None
        req_body = parse_request(body, self.logger) if body else None
        return self._call_astakos(self.api_memberships,
                                  headers=req_headers,
                                  body=req_body)
コード例 #27
0
ファイル: __init__.py プロジェクト: kins299/mycloud
    def project_action(self, project_id, action, reason=""):
        """Perform action on a project

        Arguments:
        project_id -- project identifier
        action     -- action to perform, one of "suspend", "unsuspend",
                      "terminate", "reinstate"
        reason     -- reason of performing the action

        In case of success, return nothing.
        """
        path = join_urls(self.api_projects, str(project_id))
        path = join_urls(path, "action")
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({action: {"reason": reason}}, self.logger)
        return self._call_astakos(path, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #28
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def project_action(self, project_id, action, reason=""):
        """Perform action on a project

        Arguments:
        project_id -- project identifier
        action     -- action to perform, one of "suspend", "unsuspend",
                      "terminate", "reinstate"
        reason     -- reason of performing the action

        In case of success, return nothing.
        """
        path = join_urls(self.api_projects, str(project_id))
        path = join_urls(path, "action")
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({action: reason}, self.logger)
        return self._call_astakos(path, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #29
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def application_action(self, app_id, action, reason=""):
        """Perform action on an application

        Arguments:
        app_id -- application identifier
        action -- action to perform, one of "approve", "deny",
                  "dismiss", "cancel"
        reason -- reason of performing the action

        In case of success, return nothing.
        """
        path = join_urls(self.api_applications, str(app_id))
        path = join_urls(path, "action")
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({action: reason}, self.logger)
        return self._call_astakos(path, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #30
0
ファイル: __init__.py プロジェクト: kins299/mycloud
    def membership_action(self, memb_id, action, reason=""):
        """Perform action on a membership

        Arguments:
        memb_id -- membership identifier
        action  -- action to perform, one of "leave", "cancel", "accept",
                   "reject", "remove"
        reason  -- reason of performing the action

        In case of success, return nothing.
        """
        path = join_urls(self.api_memberships, str(memb_id))
        path = join_urls(path, "action")
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({action: reason}, self.logger)
        return self._call_astakos(path, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #31
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def membership_action(self, memb_id, action, reason=""):
        """Perform action on a membership

        Arguments:
        memb_id -- membership identifier
        action  -- action to perform, one of "leave", "cancel", "accept",
                   "reject", "remove"
        reason  -- reason of performing the action

        In case of success, return nothing.
        """
        path = join_urls(self.api_memberships, str(memb_id))
        path = join_urls(path, "action")
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({action: reason}, self.logger)
        return self._call_astakos(path, headers=req_headers,
                                  body=req_body, method="POST")
コード例 #32
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def commission_action(self, serial, action):
        """Perform a commission action

        Keyword arguments:
        serial  -- commission's id (int)
        action  -- action to perform, currently accept/reject (string)

        In case of success return nothing.

        """
        check_input("commission_action", self.logger,
                    serial=serial, action=action)

        path = self.api_commissions.rstrip('/') + "/" + str(serial) + "/action"
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({str(action): ""}, self.logger)
        self._call_astakos(path, headers=req_headers,
                           body=req_body, method="POST")
コード例 #33
0
ファイル: __init__.py プロジェクト: cstavr/synnefo
    def commission_action(self, token, serial, action):
        """Perform a commission action

        Keyword arguments:
        token   -- service's token (string)
        serial  -- commission's id (int)
        action  -- action to perform, currently accept/reject (string)

        In case of success return nothing.

        """
        check_input("commission_action", self.logger,
                    serial=serial, action=action)

        path = API_COMMISSIONS + "/" + str(serial) + "/action"
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({str(action): ""}, self.logger)
        self._call_astakos(token, path, req_headers, req_body, "POST")
コード例 #34
0
ファイル: __init__.py プロジェクト: kins299/mycloud
    def commission_action(self, serial, action):
        """Perform a commission action

        Keyword arguments:
        serial  -- commission's id (int)
        action  -- action to perform, currently accept/reject (string)

        In case of success return nothing.

        """
        check_input("commission_action", self.logger,
                    serial=serial, action=action)

        path = self.api_commissions.rstrip('/') + "/" + str(serial) + "/action"
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({str(action): ""}, self.logger)
        self._call_astakos(path, headers=req_headers,
                           body=req_body, method="POST")
コード例 #35
0
    def application_action(self, app_id, action, reason=""):
        """Perform action on an application

        Arguments:
        app_id -- application identifier
        action -- action to perform, one of "approve", "deny",
                  "dismiss", "cancel"
        reason -- reason of performing the action

        In case of success, return nothing.
        """
        path = join_urls(self.api_applications, str(app_id))
        path = join_urls(path, "action")
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({action: reason}, self.logger)
        return self._call_astakos(path,
                                  headers=req_headers,
                                  body=req_body,
                                  method="POST")
コード例 #36
0
    def get_endpoints(self, token, uuid=None):
        """ Fallback call for authenticate

        Keyword arguments:
        token   -- user's token (string)
        uuid    -- user's uniq id

        It returns back the token as well as information about the token
        holder and the services he/she can acess (in json format).
        In case of error raise an AstakosClientException.

        """
        req_path = copy(API_TOKENS)
        req_headers = {'content-type': 'application/json'}
        body = {'auth': {'token': {'id': token}}}
        if uuid is not None:
            body['auth']['tenantName'] = uuid
        req_body = parse_request(body, self.logger)
        return self._call_astakos(token, req_path, req_headers, req_body,
                                  "POST", False)
コード例 #37
0
ファイル: __init__.py プロジェクト: cstavr/synnefo
    def get_endpoints(self, token, uuid=None):
        """ Fallback call for authenticate

        Keyword arguments:
        token   -- user's token (string)
        uuid    -- user's uniq id

        It returns back the token as well as information about the token
        holder and the services he/she can acess (in json format).
        In case of error raise an AstakosClientException.

        """
        req_path = copy(API_TOKENS)
        req_headers = {'content-type': 'application/json'}
        body = {'auth': {'token': {'id': token}}}
        if uuid is not None:
            body['auth']['tenantName'] = uuid
        req_body = parse_request(body, self.logger)
        return self._call_astakos(token, req_path, req_headers,
                                  req_body, "POST", False)
コード例 #38
0
    def commission_action(self, token, serial, action):
        """Perform a commission action

        Keyword arguments:
        token   -- service's token (string)
        serial  -- commission's id (int)
        action  -- action to perform, currently accept/reject (string)

        In case of success return nothing.

        """
        check_input("commission_action",
                    self.logger,
                    serial=serial,
                    action=action)

        path = API_COMMISSIONS + "/" + str(serial) + "/action"
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({str(action): ""}, self.logger)
        self._call_astakos(token, path, req_headers, req_body, "POST")
コード例 #39
0
    def _issue_commission(self, request):
        """Issue a commission

        Keyword arguments:
        request -- commision request (dict)

        In case of success return commission's id (int).
        Otherwise raise an AstakosClientException.

        """
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request(request, self.logger)
        try:
            response = self._call_astakos(self.api_commissions,
                                          headers=req_headers,
                                          body=req_body,
                                          method="POST")
        except AstakosClientException as err:
            if err.status == 413:
                try:
                    msg, details = render_overlimit_exception(
                        err.response, self.logger)
                except Exception as perr:
                    self.logger.error(
                        "issue_commission request returned '413'"
                        " but response '%r' could not be parsed:"
                        " %s", err.response, str(perr))
                    msg, details = err.message, ""
                raise QuotaLimit(message=msg,
                                 details=details,
                                 response=err.response)
            else:
                raise

        if "serial" in response:
            return response['serial']
        else:
            msg = "issue_commission_core request returned %r. " + \
                  "No serial found" % response
            self.logger.error(msg)
            raise AstakosClientException(message=msg, response=response)
コード例 #40
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def get_projects(self, name=None, state=None, owner=None):
        """Retrieve all accessible projects

        Arguments:
        name  -- filter by name (optional)
        state -- filter by state (optional)
        owner -- filter by owner (optional)

        In case of success, return a list of project descriptions.
        """
        filters = {}
        if name is not None:
            filters["name"] = name
        if state is not None:
            filters["state"] = state
        if owner is not None:
            filters["owner"] = owner
        req_headers = {'content-type': 'application/json'}
        req_body = (parse_request({"filter": filters}, self.logger)
                    if filters else None)
        return self._call_astakos(self.api_projects,
                                  headers=req_headers, body=req_body)
コード例 #41
0
    def get_projects(self, name=None, state=None, owner=None):
        """Retrieve all accessible projects

        Arguments:
        name  -- filter by name (optional)
        state -- filter by state (optional)
        owner -- filter by owner (optional)

        In case of success, return a list of project descriptions.
        """
        filters = {}
        if name is not None:
            filters["name"] = name
        if state is not None:
            filters["state"] = state
        if owner is not None:
            filters["owner"] = owner
        req_headers = {'content-type': 'application/json'}
        req_body = (parse_request({"filter": filters}, self.logger)
                    if filters else None)
        return self._call_astakos(self.api_projects,
                                  headers=req_headers,
                                  body=req_body)
コード例 #42
0
ファイル: __init__.py プロジェクト: cstavr/synnefo
    def resolve_commissions(self, token, accept_serials, reject_serials):
        """Resolve multiple commissions at once

        Keyword arguments:
        token           -- service's token (string)
        accept_serials  -- commissions to accept (list of ints)
        reject_serials  -- commissions to reject (list of ints)

        In case of success return a dict of dicts describing which
        commissions accepted, which rejected and which failed to
        resolved.

        """
        check_input("resolve_commissions", self.logger,
                    accept_serials=accept_serials,
                    reject_serials=reject_serials)

        path = copy(API_COMMISSIONS_ACTION)
        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({"accept": accept_serials,
                                  "reject": reject_serials},
                                 self.logger)
        return self._call_astakos(token, path, req_headers, req_body, "POST")
コード例 #43
0
ファイル: __init__.py プロジェクト: antonis-m/synnefo
    def resolve_commissions(self, accept_serials, reject_serials):
        """Resolve multiple commissions at once

        Keyword arguments:
        accept_serials  -- commissions to accept (list of ints)
        reject_serials  -- commissions to reject (list of ints)

        In case of success return a dict of dicts describing which
        commissions accepted, which rejected and which failed to
        resolved.

        """
        check_input("resolve_commissions", self.logger,
                    accept_serials=accept_serials,
                    reject_serials=reject_serials)

        req_headers = {'content-type': 'application/json'}
        req_body = parse_request({"accept": accept_serials,
                                  "reject": reject_serials},
                                 self.logger)
        return self._call_astakos(self.api_commissions_action,
                                  headers=req_headers, body=req_body,
                                  method="POST")