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 * ApiClientBuilder
013 * <hr>
014 * Example to create an instance using the builder pattern
015 * <div class=code-example>
016 * <pre><code class='java'>
017 *     ApiClient apiClient = ApiClient.builder()
018 *             .id("{id}")
019 *             .name("{name}")
020 *             .scope("{scope}")
021 *             .build()
022 * </code></pre>
023 * </div>
024 */
025@Generated(value = "io.vrap.rmf.codegen.rendering.CoreCodeGenerator", comments = "https://github.com/commercetools/rmf-codegen")
026public class ApiClientBuilder implements Builder<ApiClient> {
027
028    private String id;
029
030    private String name;
031
032    private String scope;
033
034    @Nullable
035    private String secret;
036
037    @Nullable
038    private java.time.LocalDate lastUsedAt;
039
040    @Nullable
041    private java.time.ZonedDateTime deleteAt;
042
043    @Nullable
044    private java.time.ZonedDateTime createdAt;
045
046    @Nullable
047    private Integer accessTokenValiditySeconds;
048
049    @Nullable
050    private Integer refreshTokenValiditySeconds;
051
052    /**
053     *  <p>The OAuth2 <code>client_id</code> that can be used to obtain an access token.</p>
054     * @param id value to be set
055     * @return Builder
056     */
057
058    public ApiClientBuilder id(final String id) {
059        this.id = id;
060        return this;
061    }
062
063    /**
064     *  <p>Name of the APIClient.</p>
065     * @param name value to be set
066     * @return Builder
067     */
068
069    public ApiClientBuilder name(final String name) {
070        this.name = name;
071        return this;
072    }
073
074    /**
075     *  <p>Whitespace-separated list of OAuth scopes that can be used when obtaining an access token.</p>
076     * @param scope value to be set
077     * @return Builder
078     */
079
080    public ApiClientBuilder scope(final String scope) {
081        this.scope = scope;
082        return this;
083    }
084
085    /**
086     *  <p>Only shown once in the response of creating the APIClient. This is the OAuth2 <code>client_secret</code> that can be used to obtain an access token.</p>
087     * @param secret value to be set
088     * @return Builder
089     */
090
091    public ApiClientBuilder secret(@Nullable final String secret) {
092        this.secret = secret;
093        return this;
094    }
095
096    /**
097     *  <p>Date of the last day this APIClient was used to obtain an access token.</p>
098     * @param lastUsedAt value to be set
099     * @return Builder
100     */
101
102    public ApiClientBuilder lastUsedAt(@Nullable final java.time.LocalDate lastUsedAt) {
103        this.lastUsedAt = lastUsedAt;
104        return this;
105    }
106
107    /**
108     *  <p>If set, the Client will be deleted on (or shortly after) this point in time.</p>
109     * @param deleteAt value to be set
110     * @return Builder
111     */
112
113    public ApiClientBuilder deleteAt(@Nullable final java.time.ZonedDateTime deleteAt) {
114        this.deleteAt = deleteAt;
115        return this;
116    }
117
118    /**
119     *  <p>Date and time (UTC) the APIClient was initially created at.</p>
120     * @param createdAt value to be set
121     * @return Builder
122     */
123
124    public ApiClientBuilder createdAt(@Nullable final java.time.ZonedDateTime createdAt) {
125        this.createdAt = createdAt;
126        return this;
127    }
128
129    /**
130     *  <p>Expiration time in seconds for each access token obtained by the APIClient. Only present when set with the APIClientDraft. If not present the default value applies.</p>
131     * @param accessTokenValiditySeconds value to be set
132     * @return Builder
133     */
134
135    public ApiClientBuilder accessTokenValiditySeconds(@Nullable final Integer accessTokenValiditySeconds) {
136        this.accessTokenValiditySeconds = accessTokenValiditySeconds;
137        return this;
138    }
139
140    /**
141     *  <p>Inactivity expiration time in seconds for each refresh token obtained by the APIClient. Only present when set with the APIClientDraft. If not present the default value applies.</p>
142     * @param refreshTokenValiditySeconds value to be set
143     * @return Builder
144     */
145
146    public ApiClientBuilder refreshTokenValiditySeconds(@Nullable final Integer refreshTokenValiditySeconds) {
147        this.refreshTokenValiditySeconds = refreshTokenValiditySeconds;
148        return this;
149    }
150
151    /**
152     *  <p>The OAuth2 <code>client_id</code> that can be used to obtain an access token.</p>
153     * @return id
154     */
155
156    public String getId() {
157        return this.id;
158    }
159
160    /**
161     *  <p>Name of the APIClient.</p>
162     * @return name
163     */
164
165    public String getName() {
166        return this.name;
167    }
168
169    /**
170     *  <p>Whitespace-separated list of OAuth scopes that can be used when obtaining an access token.</p>
171     * @return scope
172     */
173
174    public String getScope() {
175        return this.scope;
176    }
177
178    /**
179     *  <p>Only shown once in the response of creating the APIClient. This is the OAuth2 <code>client_secret</code> that can be used to obtain an access token.</p>
180     * @return secret
181     */
182
183    @Nullable
184    public String getSecret() {
185        return this.secret;
186    }
187
188    /**
189     *  <p>Date of the last day this APIClient was used to obtain an access token.</p>
190     * @return lastUsedAt
191     */
192
193    @Nullable
194    public java.time.LocalDate getLastUsedAt() {
195        return this.lastUsedAt;
196    }
197
198    /**
199     *  <p>If set, the Client will be deleted on (or shortly after) this point in time.</p>
200     * @return deleteAt
201     */
202
203    @Nullable
204    public java.time.ZonedDateTime getDeleteAt() {
205        return this.deleteAt;
206    }
207
208    /**
209     *  <p>Date and time (UTC) the APIClient was initially created at.</p>
210     * @return createdAt
211     */
212
213    @Nullable
214    public java.time.ZonedDateTime getCreatedAt() {
215        return this.createdAt;
216    }
217
218    /**
219     *  <p>Expiration time in seconds for each access token obtained by the APIClient. Only present when set with the APIClientDraft. If not present the default value applies.</p>
220     * @return accessTokenValiditySeconds
221     */
222
223    @Nullable
224    public Integer getAccessTokenValiditySeconds() {
225        return this.accessTokenValiditySeconds;
226    }
227
228    /**
229     *  <p>Inactivity expiration time in seconds for each refresh token obtained by the APIClient. Only present when set with the APIClientDraft. If not present the default value applies.</p>
230     * @return refreshTokenValiditySeconds
231     */
232
233    @Nullable
234    public Integer getRefreshTokenValiditySeconds() {
235        return this.refreshTokenValiditySeconds;
236    }
237
238    /**
239     * builds ApiClient with checking for non-null required values
240     * @return ApiClient
241     */
242    public ApiClient build() {
243        Objects.requireNonNull(id, ApiClient.class + ": id is missing");
244        Objects.requireNonNull(name, ApiClient.class + ": name is missing");
245        Objects.requireNonNull(scope, ApiClient.class + ": scope is missing");
246        return new ApiClientImpl(id, name, scope, secret, lastUsedAt, deleteAt, createdAt, accessTokenValiditySeconds,
247            refreshTokenValiditySeconds);
248    }
249
250    /**
251     * builds ApiClient without checking for non-null required values
252     * @return ApiClient
253     */
254    public ApiClient buildUnchecked() {
255        return new ApiClientImpl(id, name, scope, secret, lastUsedAt, deleteAt, createdAt, accessTokenValiditySeconds,
256            refreshTokenValiditySeconds);
257    }
258
259    /**
260     * factory method for an instance of ApiClientBuilder
261     * @return builder
262     */
263    public static ApiClientBuilder of() {
264        return new ApiClientBuilder();
265    }
266
267    /**
268     * create builder for ApiClient instance
269     * @param template instance with prefilled values for the builder
270     * @return builder
271     */
272    public static ApiClientBuilder of(final ApiClient template) {
273        ApiClientBuilder builder = new ApiClientBuilder();
274        builder.id = template.getId();
275        builder.name = template.getName();
276        builder.scope = template.getScope();
277        builder.secret = template.getSecret();
278        builder.lastUsedAt = template.getLastUsedAt();
279        builder.deleteAt = template.getDeleteAt();
280        builder.createdAt = template.getCreatedAt();
281        builder.accessTokenValiditySeconds = template.getAccessTokenValiditySeconds();
282        builder.refreshTokenValiditySeconds = template.getRefreshTokenValiditySeconds();
283        return builder;
284    }
285
286}