pulsar-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [pulsar] devinbost edited a comment on issue #5312: Function REST API documentation is insufficient for Create POST action
Date Tue, 08 Oct 2019 17:13:03 GMT
devinbost edited a comment on issue #5312: Function REST API documentation is insufficient
for Create POST action
URL: https://github.com/apache/pulsar/issues/5312#issuecomment-539612612
 
 
   Also, I found the code for the CLI in org.apache.pulsar.client.admin.internal.FunctionsImpl.java,
which contains for the create:
   
    ```
      @Override
       public void createFunctionWithUrl(FunctionConfig functionConfig, String pkgUrl) throws
PulsarAdminException {
           try {
               final FormDataMultiPart mp = new FormDataMultiPart();
   
               mp.bodyPart(new FormDataBodyPart("url", pkgUrl, MediaType.TEXT_PLAIN_TYPE));
   
               mp.bodyPart(new FormDataBodyPart("functionConfig",
                   new Gson().toJson(functionConfig),
                   MediaType.APPLICATION_JSON_TYPE));
               request(functions.path(functionConfig.getTenant()).path(functionConfig.getNamespace()).path(functionConfig.getName()))
                       .post(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA), ErrorData.class);
           } catch (Exception e) {
               throw getApiException(e);
           }
       }
   ```
   
   and for the update:
   
   ```
       @Override
       public void updateFunctionWithUrl(FunctionConfig functionConfig, String pkgUrl, UpdateOptions
updateOptions) throws PulsarAdminException {
           try {
               final FormDataMultiPart mp = new FormDataMultiPart();
   
               mp.bodyPart(new FormDataBodyPart("url", pkgUrl, MediaType.TEXT_PLAIN_TYPE));
   
               mp.bodyPart(new FormDataBodyPart(
                       "functionConfig",
                       ObjectMapperFactory.getThreadLocal().writeValueAsString(functionConfig),
                       MediaType.APPLICATION_JSON_TYPE));
   
               if (updateOptions != null) {
                   mp.bodyPart(new FormDataBodyPart(
                           "updateOptions",
                           ObjectMapperFactory.getThreadLocal().writeValueAsString(updateOptions),
                           MediaType.APPLICATION_JSON_TYPE));
               }
   
               request(functions.path(functionConfig.getTenant()).path(functionConfig.getNamespace())
                       .path(functionConfig.getName())).put(Entity.entity(mp, MediaType.MULTIPART_FORM_DATA),
                       ErrorData.class);
           } catch (Exception e) {
               throw getApiException(e);
           }
       }
   ```
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message