#78 Add a new API endpoint returning the status of a package
Merged 5 years ago by pingou. Opened 5 years ago by pingou.

file modified
+21
@@ -90,6 +90,27 @@ 

      return anitya_get_endpoint(namespace, repo.name)

  

  

+ @DISTGIT_NS.route("/actived/<namespace>/<repo>", methods=["GET"])

+ @api_method

+ def get_actived_status(namespace, repo):

+     """ Retrieves the active status of the specified package.

+     """

+     _log.info("Received a request to unorphan: %s/%s", namespace, repo)

+ 

+     repo = _get_repo(repo, namespace=namespace)

+ 

+     if repo.user.user != "orphan":

+         raise pagure.exceptions.APIError(

+             401, error_code=APIERROR.EMODIFYPROJECTNOTALLOWED

+         )

+ 

+     # Check if the project is retired in PDC

+     active = _is_active_in_pdc(repo.name, repo.namespace)

+ 

+     output = {"active": active}

+     return flask.jsonify(output)

+ 

+ 

  def _is_active_in_pdc(name, namespace):

      """ Queries PDC and return whether the project is active on the master

      branch in PDC or not.

This endpoint will return True on active packages and False on
retired packages (based on PDC data).

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

rebased onto 6ac1a4c

5 years ago

Pull-Request has been merged by pingou

5 years ago
Metadata