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