001 002package com.commercetools.api.models.api_client; 003 004import java.util.*; 005 006import javax.annotation.Nullable; 007 008import io.vrap.rmf.base.client.Builder; 009import io.vrap.rmf.base.client.utils.Generated; 010 011/** 012 * ApiClientDraftBuilder 013 * <hr> 014 * Example to create an instance using the builder pattern 015 * <div class=code-example> 016 * <pre><code class='java'> 017 * ApiClientDraft apiClientDraft = ApiClientDraft.builder() 018 * .name("{name}") 019 * .scope("{scope}") 020 * .build() 021 * </code></pre> 022 * </div> 023 */ 024@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen") 025public class ApiClientDraftBuilder implements Builder<ApiClientDraft> { 026 027 private String name; 028 029 private String scope; 030 031 @Nullable 032 private Long deleteDaysAfterCreation; 033 034 @Nullable 035 private Integer accessTokenValiditySeconds; 036 037 @Nullable 038 private Integer refreshTokenValiditySeconds; 039 040 /** 041 * <p>Name of the APIClient.</p> 042 * @param name value to be set 043 * @return Builder 044 */ 045 046 public ApiClientDraftBuilder name(final String name) { 047 this.name = name; 048 return this; 049 } 050 051 /** 052 * <p>Whitespace-separated list of OAuth scopes that can be used when obtaining an access token.</p> 053 * @param scope value to be set 054 * @return Builder 055 */ 056 057 public ApiClientDraftBuilder scope(final String scope) { 058 this.scope = scope; 059 return this; 060 } 061 062 /** 063 * <p>If set, the Client will be deleted after the specified amount of days.</p> 064 * @param deleteDaysAfterCreation value to be set 065 * @return Builder 066 */ 067 068 public ApiClientDraftBuilder deleteDaysAfterCreation(@Nullable final Long deleteDaysAfterCreation) { 069 this.deleteDaysAfterCreation = deleteDaysAfterCreation; 070 return this; 071 } 072 073 /** 074 * <p>Expiration time in seconds for each access token obtained by the APIClient. If not set the default value applies.</p> 075 * @param accessTokenValiditySeconds value to be set 076 * @return Builder 077 */ 078 079 public ApiClientDraftBuilder accessTokenValiditySeconds(@Nullable final Integer accessTokenValiditySeconds) { 080 this.accessTokenValiditySeconds = accessTokenValiditySeconds; 081 return this; 082 } 083 084 /** 085 * <p>Inactivity expiration time in seconds for each refresh token obtained by the APIClient. The expiration time for refresh tokens is restarted each time the token is used. If not set the default value applies.</p> 086 * @param refreshTokenValiditySeconds value to be set 087 * @return Builder 088 */ 089 090 public ApiClientDraftBuilder refreshTokenValiditySeconds(@Nullable final Integer refreshTokenValiditySeconds) { 091 this.refreshTokenValiditySeconds = refreshTokenValiditySeconds; 092 return this; 093 } 094 095 /** 096 * <p>Name of the APIClient.</p> 097 * @return name 098 */ 099 100 public String getName() { 101 return this.name; 102 } 103 104 /** 105 * <p>Whitespace-separated list of OAuth scopes that can be used when obtaining an access token.</p> 106 * @return scope 107 */ 108 109 public String getScope() { 110 return this.scope; 111 } 112 113 /** 114 * <p>If set, the Client will be deleted after the specified amount of days.</p> 115 * @return deleteDaysAfterCreation 116 */ 117 118 @Nullable 119 public Long getDeleteDaysAfterCreation() { 120 return this.deleteDaysAfterCreation; 121 } 122 123 /** 124 * <p>Expiration time in seconds for each access token obtained by the APIClient. If not set the default value applies.</p> 125 * @return accessTokenValiditySeconds 126 */ 127 128 @Nullable 129 public Integer getAccessTokenValiditySeconds() { 130 return this.accessTokenValiditySeconds; 131 } 132 133 /** 134 * <p>Inactivity expiration time in seconds for each refresh token obtained by the APIClient. The expiration time for refresh tokens is restarted each time the token is used. If not set the default value applies.</p> 135 * @return refreshTokenValiditySeconds 136 */ 137 138 @Nullable 139 public Integer getRefreshTokenValiditySeconds() { 140 return this.refreshTokenValiditySeconds; 141 } 142 143 /** 144 * builds ApiClientDraft with checking for non-null required values 145 * @return ApiClientDraft 146 */ 147 public ApiClientDraft build() { 148 Objects.requireNonNull(name, ApiClientDraft.class + ": name is missing"); 149 Objects.requireNonNull(scope, ApiClientDraft.class + ": scope is missing"); 150 return new ApiClientDraftImpl(name, scope, deleteDaysAfterCreation, accessTokenValiditySeconds, 151 refreshTokenValiditySeconds); 152 } 153 154 /** 155 * builds ApiClientDraft without checking for non-null required values 156 * @return ApiClientDraft 157 */ 158 public ApiClientDraft buildUnchecked() { 159 return new ApiClientDraftImpl(name, scope, deleteDaysAfterCreation, accessTokenValiditySeconds, 160 refreshTokenValiditySeconds); 161 } 162 163 /** 164 * factory method for an instance of ApiClientDraftBuilder 165 * @return builder 166 */ 167 public static ApiClientDraftBuilder of() { 168 return new ApiClientDraftBuilder(); 169 } 170 171 /** 172 * create builder for ApiClientDraft instance 173 * @param template instance with prefilled values for the builder 174 * @return builder 175 */ 176 public static ApiClientDraftBuilder of(final ApiClientDraft template) { 177 ApiClientDraftBuilder builder = new ApiClientDraftBuilder(); 178 builder.name = template.getName(); 179 builder.scope = template.getScope(); 180 builder.deleteDaysAfterCreation = template.getDeleteDaysAfterCreation(); 181 builder.accessTokenValiditySeconds = template.getAccessTokenValiditySeconds(); 182 builder.refreshTokenValiditySeconds = template.getRefreshTokenValiditySeconds(); 183 return builder; 184 } 185 186}