Source: api/projectValidate.js

  1. "use strict";
  2. module.exports = ProjectValidateClient;
  3. /**
  4. * Used to access Jira REST endpoints in '/rest/api/2/projectvalidate'
  5. *
  6. * @param {JiraClient} jiraClient
  7. * @constructor ProjectValidateClient
  8. */
  9. function ProjectValidateClient(jiraClient) {
  10. this.jiraClient = jiraClient;
  11. /**
  12. * Validates a project key. This endpoint is a little wonky, as it returns a list of errors as a valid response;
  13. * even if the key is invalid, it still returns a 200 response.
  14. * See {@link https://docs.atlassian.com/jira/REST/latest/#d2e297}
  15. *
  16. * @method validateProjectKey
  17. * @memberOf ProjectValidateClient#
  18. * @param opts The request options sent to the Jira API.
  19. * @param opts.projectKey The key of the project.
  20. * @param [callback] Called when the key has been validated.
  21. * @return {Promise} Resolved when the key has been validated.
  22. */
  23. this.validateProjectKey = function (opts, callback) {
  24. var options = {
  25. uri: this.jiraClient.buildURL('/projectvalidate/key'),
  26. method: 'GET',
  27. json: true,
  28. followAllRedirects: true,
  29. qs: {
  30. key: opts.projectKey
  31. }
  32. };
  33. return this.jiraClient.makeRequest(options, callback);
  34. }
  35. }