/src/main/java/com/cdancy/bitbucket/rest/features/TagApi.java

https://github.com/cdancy/bitbucket-rest · Java · 96 lines · 71 code · 9 blank · 16 comment · 0 complexity · 0bfd4cfc76104dfa81d876f9e01366a7 MD5 · raw file

  1. /*
  2. * Licensed to the Apache Software Foundation (ASF) under one or more
  3. * contributor license agreements. See the NOTICE file distributed with
  4. * this work for additional information regarding copyright ownership.
  5. * The ASF licenses this file to You under the Apache License, Version 2.0
  6. * (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. */
  17. package com.cdancy.bitbucket.rest.features;
  18. import com.cdancy.bitbucket.rest.annotations.Documentation;
  19. import com.cdancy.bitbucket.rest.domain.common.RequestStatus;
  20. import com.cdancy.bitbucket.rest.domain.tags.Tag;
  21. import com.cdancy.bitbucket.rest.domain.tags.TagPage;
  22. import com.cdancy.bitbucket.rest.fallbacks.BitbucketFallbacks;
  23. import com.cdancy.bitbucket.rest.filters.BitbucketAuthenticationFilter;
  24. import com.cdancy.bitbucket.rest.options.CreateTag;
  25. import com.cdancy.bitbucket.rest.parsers.RequestStatusParser;
  26. import org.jclouds.rest.annotations.BinderParam;
  27. import org.jclouds.rest.annotations.Fallback;
  28. import org.jclouds.rest.annotations.RequestFilters;
  29. import org.jclouds.rest.binders.BindToJsonPayload;
  30. import javax.inject.Named;
  31. import javax.ws.rs.Consumes;
  32. import javax.ws.rs.DELETE;
  33. import javax.ws.rs.GET;
  34. import javax.ws.rs.POST;
  35. import javax.ws.rs.Path;
  36. import javax.ws.rs.PathParam;
  37. import javax.ws.rs.Produces;
  38. import javax.ws.rs.QueryParam;
  39. import javax.ws.rs.core.MediaType;
  40. import org.jclouds.javax.annotation.Nullable;
  41. import org.jclouds.rest.annotations.ResponseParser;
  42. @Produces(MediaType.APPLICATION_JSON)
  43. @RequestFilters(BitbucketAuthenticationFilter.class)
  44. @Path("/rest")
  45. @SuppressWarnings("PMD.AvoidDuplicateLiterals")
  46. public interface TagApi {
  47. @Named("tag:create")
  48. @Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-rest.html#idm45888278801952"})
  49. @Consumes(MediaType.APPLICATION_JSON)
  50. @Path("/api/{jclouds.api-version}/projects/{project}/repos/{repo}/tags")
  51. @Fallback(BitbucketFallbacks.TagOnError.class)
  52. @POST
  53. Tag create(@PathParam("project") String project,
  54. @PathParam("repo") String repo,
  55. @BinderParam(BindToJsonPayload.class) CreateTag createTag);
  56. @Named("tag:get")
  57. @Documentation({"https://developer.atlassian.com/static/rest/bitbucket-server/latest/bitbucket-rest.html#idm45888278800832"})
  58. @Consumes(MediaType.APPLICATION_JSON)
  59. @Path("/api/{jclouds.api-version}/projects/{project}/repos/{repo}/tags/{tag}")
  60. @Fallback(BitbucketFallbacks.TagOnError.class)
  61. @GET
  62. Tag get(@PathParam("project") String project,
  63. @PathParam("repo") String repo,
  64. @PathParam("tag") String tag);
  65. @Named("tag:list")
  66. @Documentation({"https://docs.atlassian.com/bitbucket-server/rest/5.7.0/bitbucket-rest.html#idm45568367769888"})
  67. @Consumes(MediaType.APPLICATION_JSON)
  68. @Path("/api/{jclouds.api-version}/projects/{project}/repos/{repo}/tags")
  69. @Fallback(BitbucketFallbacks.TagPageOnError.class)
  70. @GET
  71. TagPage list(@PathParam("project") String project,
  72. @PathParam("repo") String repo,
  73. @Nullable @QueryParam("filterText") String filterText,
  74. @Nullable @QueryParam("orderBy") String orderBy,
  75. @Nullable @QueryParam("start") Integer start,
  76. @Nullable @QueryParam("limit") Integer limit);
  77. @Named("tag:delete")
  78. @Documentation({"https://docs.atlassian.com/bitbucket-server/rest/5.4.0/bitbucket-git-rest.html#idm139355817865616"})
  79. @Consumes(MediaType.APPLICATION_JSON)
  80. @Path("/git/{jclouds.api-version}/projects/{project}/repos/{repo}/tags/{tag}")
  81. @Fallback(BitbucketFallbacks.RequestStatusOnError.class)
  82. @ResponseParser(RequestStatusParser.class)
  83. @DELETE
  84. RequestStatus delete(@PathParam("project") String project,
  85. @PathParam("repo") String repo,
  86. @PathParam("tag") String tag);
  87. }