Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-13787

An annotation based system to write v2 only APIs

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 8.3, 9.0
    • None
    • None

    Description

      example v2 API may look as follows

      @V2EndPoint(method = POST, path = "/cluster/package", permission = PermissionNameProvider.Name.ALL)
      public static class ApiTest {
        @Command(name = "add")
        public void add(SolrQueryRequest req, SolrQueryResponse rsp, AddVersion addVersion) {
      
        }
      
        @Command(name = "delete")
        public void del(SolrQueryRequest req, SolrQueryResponse rsp, List<String> names) {
      
        }
      
      
      
      }
      
      public static class AddVersion {
        @JsonProperty(value = "package", required = true)
        public String pkg;
        @JsonProperty(value = "version", required = true)
        public String version;
        @JsonProperty(value = "files", required = true)
        public List<String> files;
      }
      
      

      This expects you to already hava a POJO annotated with jackson annotations

       

      The annotations are:

       

      @Retention(RetentionPolicy.RUNTIME)
      @Target({ElementType.TYPE})
      public @interface EndPoint {
      /**The suoported http methods*/
        SolrRequest.METHOD[] method();
      
      /**supported paths*/
        String[] path();
      
        PermissionNameProvider.Name permission();
      }
      
      @Retention(RetentionPolicy.RUNTIME)
      @Target(ElementType.METHOD)
      public @interface Command {
         /**if this is not a json command , leave it empty.
         * Keep in mind that you cannot have duplicates.
         * Only one method per name
         *
         */
        String name() default "";
      
      }
      

      Attachments

        Issue Links

          Activity

            People

              noble.paul Noble Paul
              noble.paul Noble Paul
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 10m
                  1h 10m