001 002package com.commercetools.ml.client; 003 004import java.net.URI; 005import java.time.Duration; 006import java.util.ArrayList; 007import java.util.List; 008import java.util.concurrent.CompletableFuture; 009 010import io.vrap.rmf.base.client.*; 011import io.vrap.rmf.base.client.utils.Generated; 012 013import org.apache.commons.lang3.builder.EqualsBuilder; 014import org.apache.commons.lang3.builder.HashCodeBuilder; 015 016/** 017 * <p>Endpoint to update the image search config.</p> 018 * 019 * <hr> 020 * <div class=code-example> 021 * <pre><code class='java'>{@code 022 * CompletableFuture<ApiHttpResponse<com.commercetools.ml.models.image_search_config.ImageSearchConfigResponse>> result = apiRoot 023 * .withProjectKey("{projectKey}") 024 * .imageSearch() 025 * .config() 026 * .post(null) 027 * .execute() 028 * }</code></pre> 029 * </div> 030 */ 031@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 032public class ByProjectKeyImageSearchConfigPost extends 033 BodyApiMethod<ByProjectKeyImageSearchConfigPost, com.commercetools.ml.models.image_search_config.ImageSearchConfigResponse, com.commercetools.ml.models.image_search_config.ImageSearchConfigRequest> { 034 035 private String projectKey; 036 037 private com.commercetools.ml.models.image_search_config.ImageSearchConfigRequest imageSearchConfigRequest; 038 039 public ByProjectKeyImageSearchConfigPost(final ApiHttpClient apiHttpClient, String projectKey, 040 com.commercetools.ml.models.image_search_config.ImageSearchConfigRequest imageSearchConfigRequest) { 041 super(apiHttpClient); 042 this.projectKey = projectKey; 043 this.imageSearchConfigRequest = imageSearchConfigRequest; 044 } 045 046 public ByProjectKeyImageSearchConfigPost(ByProjectKeyImageSearchConfigPost t) { 047 super(t); 048 this.projectKey = t.projectKey; 049 this.imageSearchConfigRequest = t.imageSearchConfigRequest; 050 } 051 052 @Override 053 protected ApiHttpRequest buildHttpRequest() { 054 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 055 String httpRequestPath = String.format("/%s/image-search/config", this.projectKey); 056 if (!params.isEmpty()) { 057 httpRequestPath += "?" + String.join("&", params); 058 } 059 return new ApiHttpRequest(ApiHttpMethod.POST, URI.create(httpRequestPath), getHeaders(), 060 io.vrap.rmf.base.client.utils.json.JsonUtils 061 .executing(() -> apiHttpClient().getSerializerService().toJsonByteArray(imageSearchConfigRequest))); 062 063 } 064 065 @Override 066 public ApiHttpResponse<com.commercetools.ml.models.image_search_config.ImageSearchConfigResponse> executeBlocking( 067 final ApiHttpClient client, final Duration timeout) { 068 return executeBlocking(client, timeout, 069 com.commercetools.ml.models.image_search_config.ImageSearchConfigResponse.class); 070 } 071 072 @Override 073 public CompletableFuture<ApiHttpResponse<com.commercetools.ml.models.image_search_config.ImageSearchConfigResponse>> execute( 074 final ApiHttpClient client) { 075 return execute(client, com.commercetools.ml.models.image_search_config.ImageSearchConfigResponse.class); 076 } 077 078 public String getProjectKey() { 079 return this.projectKey; 080 } 081 082 public void setProjectKey(final String projectKey) { 083 this.projectKey = projectKey; 084 } 085 086 public com.commercetools.ml.models.image_search_config.ImageSearchConfigRequest getBody() { 087 return imageSearchConfigRequest; 088 } 089 090 public ByProjectKeyImageSearchConfigPost withBody( 091 com.commercetools.ml.models.image_search_config.ImageSearchConfigRequest imageSearchConfigRequest) { 092 ByProjectKeyImageSearchConfigPost t = copy(); 093 t.imageSearchConfigRequest = imageSearchConfigRequest; 094 return t; 095 } 096 097 @Override 098 public boolean equals(Object o) { 099 if (this == o) 100 return true; 101 102 if (o == null || getClass() != o.getClass()) 103 return false; 104 105 ByProjectKeyImageSearchConfigPost that = (ByProjectKeyImageSearchConfigPost) o; 106 107 return new EqualsBuilder().append(projectKey, that.projectKey) 108 .append(imageSearchConfigRequest, that.imageSearchConfigRequest) 109 .isEquals(); 110 } 111 112 @Override 113 public int hashCode() { 114 return new HashCodeBuilder(17, 37).append(projectKey).append(imageSearchConfigRequest).toHashCode(); 115 } 116 117 @Override 118 protected ByProjectKeyImageSearchConfigPost copy() { 119 return new ByProjectKeyImageSearchConfigPost(this); 120 } 121}