Revision 4334d1c8 astakosclient/astakosclient/__init__.py

b/astakosclient/astakosclient/__init__.py
234 234
        return join_urls(self.account_prefix, "projects")
235 235

  
236 236
    @property
237
    def api_applications(self):
238
        return join_urls(self.api_projects, "apps")
239

  
240
    @property
241 237
    def api_memberships(self):
242 238
        return join_urls(self.api_projects, "memberships")
243 239

  
......
893 889
        path = join_urls(self.api_projects, str(project_id))
894 890
        path = join_urls(path, "action")
895 891
        req_headers = {'content-type': 'application/json'}
896
        req_body = parse_request({action: reason}, self.logger)
892
        req_body = parse_request({action: {"reason": reason}}, self.logger)
897 893
        return self._call_astakos(path, headers=req_headers,
898 894
                                  body=req_body, method="POST")
899 895

  
900
    # --------------------------------
901
    # do a GET to ``API_APPLICATIONS``
902
    def get_applications(self, project=None):
903
        """Retrieve all accessible applications
904

  
905
        Arguments:
906
        project -- filter by project (optional)
907

  
908
        In case of success, return a list of application descriptions.
909
        """
910
        req_headers = {'content-type': 'application/json'}
911
        body = {"project": project} if project is not None else None
912
        req_body = parse_request(body, self.logger) if body else None
913
        return self._call_astakos(self.api_applications,
914
                                  headers=req_headers, body=req_body)
915

  
916
    # -----------------------------------------
917
    # do a GET to ``API_APPLICATIONS``/<app_id>
918
    def get_application(self, app_id):
919
        """Retrieve application description, if accessible
920

  
921
        Arguments:
922
        app_id -- application identifier
923

  
924
        In case of success, return application description.
925
        """
926
        path = join_urls(self.api_applications, str(app_id))
927
        return self._call_astakos(path)
928

  
929 896
    # -------------------------------------------------
930
    # do a POST to ``API_APPLICATIONS``/<app_id>/action
931
    def application_action(self, app_id, action, reason=""):
932
        """Perform action on an application
897
    # do a POST to ``API_PROJECTS``/<project_id>/action
898
    def application_action(self, project_id, app_id, action, reason=""):
899
        """Perform action on a project application
933 900

  
934 901
        Arguments:
935
        app_id -- application identifier
936
        action -- action to perform, one of "approve", "deny",
937
                  "dismiss", "cancel"
938
        reason -- reason of performing the action
902
        project_id -- project identifier
903
        app_id     -- application identifier
904
        action     -- action to perform, one of "approve", "deny",
905
                      "dismiss", "cancel"
906
        reason     -- reason of performing the action
939 907

  
940 908
        In case of success, return nothing.
941 909
        """
942
        path = join_urls(self.api_applications, str(app_id))
910
        path = join_urls(self.api_projects, str(project_id))
943 911
        path = join_urls(path, "action")
944 912
        req_headers = {'content-type': 'application/json'}
945
        req_body = parse_request({action: reason}, self.logger)
913
        req_body = parse_request({action: {
914
                    "reasons": reason,
915
                    "app_id": app_id}}, self.logger)
946 916
        return self._call_astakos(path, headers=req_headers,
947 917
                                  body=req_body, method="POST")
948 918

  

Also available in: Unified diff