001 002package com.commercetools.importapi.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>Updates the import container given by the key.</p> 019 * 020 * <hr> 021 * <div class=code-example> 022 * <pre><code class='java'>{@code 023 * CompletableFuture<ApiHttpResponse<com.commercetools.importapi.models.importcontainers.ImportContainer>> result = apiRoot 024 * .withProjectKeyValue("{projectKey}") 025 * .importContainers() 026 * .withImportContainerKeyValue("{importContainerKey}") 027 * .put("") 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 ByProjectKeyImportContainersByImportContainerKeyPutString extends 034 StringBodyApiMethod<ByProjectKeyImportContainersByImportContainerKeyPutString, com.commercetools.importapi.models.importcontainers.ImportContainer> 035 implements 036 com.commercetools.importapi.client.Secured_by_manage_import_containersTrait<ByProjectKeyImportContainersByImportContainerKeyPutString> { 037 038 private String projectKey; 039 private String importContainerKey; 040 041 private String importContainerUpdateDraft; 042 043 public ByProjectKeyImportContainersByImportContainerKeyPutString(final ApiHttpClient apiHttpClient, 044 String projectKey, String importContainerKey, String importContainerUpdateDraft) { 045 super(apiHttpClient); 046 this.projectKey = projectKey; 047 this.importContainerKey = importContainerKey; 048 this.importContainerUpdateDraft = importContainerUpdateDraft; 049 } 050 051 public ByProjectKeyImportContainersByImportContainerKeyPutString( 052 ByProjectKeyImportContainersByImportContainerKeyPutString t) { 053 super(t); 054 this.projectKey = t.projectKey; 055 this.importContainerKey = t.importContainerKey; 056 this.importContainerUpdateDraft = t.importContainerUpdateDraft; 057 } 058 059 @Override 060 protected ApiHttpRequest buildHttpRequest() { 061 List<String> params = new ArrayList<>(getQueryParamUriStrings()); 062 String httpRequestPath = String.format("%s/import-containers/%s", this.projectKey, this.importContainerKey); 063 if (!params.isEmpty()) { 064 httpRequestPath += "?" + String.join("&", params); 065 } 066 return new ApiHttpRequest(ApiHttpMethod.PUT, URI.create(httpRequestPath), getHeaders(), 067 importContainerUpdateDraft.getBytes(StandardCharsets.UTF_8)); 068 069 } 070 071 @Override 072 public ApiHttpResponse<com.commercetools.importapi.models.importcontainers.ImportContainer> executeBlocking( 073 final ApiHttpClient client, final Duration timeout) { 074 return executeBlocking(client, timeout, 075 com.commercetools.importapi.models.importcontainers.ImportContainer.class); 076 } 077 078 @Override 079 public CompletableFuture<ApiHttpResponse<com.commercetools.importapi.models.importcontainers.ImportContainer>> execute( 080 final ApiHttpClient client) { 081 return execute(client, com.commercetools.importapi.models.importcontainers.ImportContainer.class); 082 } 083 084 public String getProjectKey() { 085 return this.projectKey; 086 } 087 088 public String getImportContainerKey() { 089 return this.importContainerKey; 090 } 091 092 public void setProjectKey(final String projectKey) { 093 this.projectKey = projectKey; 094 } 095 096 public void setImportContainerKey(final String importContainerKey) { 097 this.importContainerKey = importContainerKey; 098 } 099 100 public String getBody() { 101 return importContainerUpdateDraft; 102 } 103 104 public ByProjectKeyImportContainersByImportContainerKeyPutString withBody(String importContainerUpdateDraft) { 105 ByProjectKeyImportContainersByImportContainerKeyPutString t = copy(); 106 t.importContainerUpdateDraft = importContainerUpdateDraft; 107 return t; 108 } 109 110 @Override 111 public boolean equals(Object o) { 112 if (this == o) 113 return true; 114 115 if (o == null || getClass() != o.getClass()) 116 return false; 117 118 ByProjectKeyImportContainersByImportContainerKeyPutString that = (ByProjectKeyImportContainersByImportContainerKeyPutString) o; 119 120 return new EqualsBuilder().append(projectKey, that.projectKey) 121 .append(importContainerKey, that.importContainerKey) 122 .append(importContainerUpdateDraft, that.importContainerUpdateDraft) 123 .isEquals(); 124 } 125 126 @Override 127 public int hashCode() { 128 return new HashCodeBuilder(17, 37).append(projectKey) 129 .append(importContainerKey) 130 .append(importContainerUpdateDraft) 131 .toHashCode(); 132 } 133 134 @Override 135 protected ByProjectKeyImportContainersByImportContainerKeyPutString copy() { 136 return new ByProjectKeyImportContainersByImportContainerKeyPutString(this); 137 } 138}