All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.honeycode.model.BatchCreateTableRowsRequest Maven / Gradle / Ivy

/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.honeycode.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class BatchCreateTableRowsRequest extends HoneycodeRequest implements
        ToCopyableBuilder {
    private static final SdkField WORKBOOK_ID_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("workbookId").getter(getter(BatchCreateTableRowsRequest::workbookId)).setter(setter(Builder::workbookId))
            .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("workbookId").build()).build();

    private static final SdkField TABLE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("tableId").getter(getter(BatchCreateTableRowsRequest::tableId)).setter(setter(Builder::tableId))
            .traits(LocationTrait.builder().location(MarshallLocation.PATH).locationName("tableId").build()).build();

    private static final SdkField> ROWS_TO_CREATE_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("rowsToCreate")
            .getter(getter(BatchCreateTableRowsRequest::rowsToCreate))
            .setter(setter(Builder::rowsToCreate))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("rowsToCreate").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(CreateRowData::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField CLIENT_REQUEST_TOKEN_FIELD = SdkField. builder(MarshallingType.STRING)
            .memberName("clientRequestToken").getter(getter(BatchCreateTableRowsRequest::clientRequestToken))
            .setter(setter(Builder::clientRequestToken))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("clientRequestToken").build())
            .build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(WORKBOOK_ID_FIELD,
            TABLE_ID_FIELD, ROWS_TO_CREATE_FIELD, CLIENT_REQUEST_TOKEN_FIELD));

    private final String workbookId;

    private final String tableId;

    private final List rowsToCreate;

    private final String clientRequestToken;

    private BatchCreateTableRowsRequest(BuilderImpl builder) {
        super(builder);
        this.workbookId = builder.workbookId;
        this.tableId = builder.tableId;
        this.rowsToCreate = builder.rowsToCreate;
        this.clientRequestToken = builder.clientRequestToken;
    }

    /**
     * 

* The ID of the workbook where the new rows are being added. *

*

* If a workbook with the specified ID could not be found, this API throws ResourceNotFoundException. *

* * @return The ID of the workbook where the new rows are being added.

*

* If a workbook with the specified ID could not be found, this API throws ResourceNotFoundException. */ public final String workbookId() { return workbookId; } /** *

* The ID of the table where the new rows are being added. *

*

* If a table with the specified ID could not be found, this API throws ResourceNotFoundException. *

* * @return The ID of the table where the new rows are being added.

*

* If a table with the specified ID could not be found, this API throws ResourceNotFoundException. */ public final String tableId() { return tableId; } /** * For responses, this returns true if the service returned a value for the RowsToCreate property. This DOES NOT * check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). * This is useful because the SDK will never return a null collection or map, but you may need to differentiate * between the service returning nothing (or null) and the service returning an empty collection or map. For * requests, this returns true if a value for the property was specified in the request builder, and false if a * value was not specified. */ public final boolean hasRowsToCreate() { return rowsToCreate != null && !(rowsToCreate instanceof SdkAutoConstructList); } /** *

* The list of rows to create at the end of the table. Each item in this list needs to have a batch item id to * uniquely identify the element in the request and the cells to create for that row. You need to specify at least * one item in this list. *

*

* Note that if one of the column ids in any of the rows in the request does not exist in the table, then the * request fails and no updates are made to the table. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasRowsToCreate} method. *

* * @return The list of rows to create at the end of the table. Each item in this list needs to have a batch item id * to uniquely identify the element in the request and the cells to create for that row. You need to specify * at least one item in this list.

*

* Note that if one of the column ids in any of the rows in the request does not exist in the table, then * the request fails and no updates are made to the table. */ public final List rowsToCreate() { return rowsToCreate; } /** *

* The request token for performing the batch create operation. Request tokens help to identify duplicate requests. * If a call times out or fails due to a transient error like a failed network connection, you can retry the call * with the same request token. The service ensures that if the first call using that request token is successfully * performed, the second call will not perform the operation again. *

*

* Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe requests * spanning hours or days. *

* * @return The request token for performing the batch create operation. Request tokens help to identify duplicate * requests. If a call times out or fails due to a transient error like a failed network connection, you can * retry the call with the same request token. The service ensures that if the first call using that request * token is successfully performed, the second call will not perform the operation again.

*

* Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe * requests spanning hours or days. */ public final String clientRequestToken() { return clientRequestToken; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(workbookId()); hashCode = 31 * hashCode + Objects.hashCode(tableId()); hashCode = 31 * hashCode + Objects.hashCode(hasRowsToCreate() ? rowsToCreate() : null); hashCode = 31 * hashCode + Objects.hashCode(clientRequestToken()); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof BatchCreateTableRowsRequest)) { return false; } BatchCreateTableRowsRequest other = (BatchCreateTableRowsRequest) obj; return Objects.equals(workbookId(), other.workbookId()) && Objects.equals(tableId(), other.tableId()) && hasRowsToCreate() == other.hasRowsToCreate() && Objects.equals(rowsToCreate(), other.rowsToCreate()) && Objects.equals(clientRequestToken(), other.clientRequestToken()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public final String toString() { return ToString.builder("BatchCreateTableRowsRequest").add("WorkbookId", workbookId()).add("TableId", tableId()) .add("RowsToCreate", hasRowsToCreate() ? rowsToCreate() : null).add("ClientRequestToken", clientRequestToken()) .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "workbookId": return Optional.ofNullable(clazz.cast(workbookId())); case "tableId": return Optional.ofNullable(clazz.cast(tableId())); case "rowsToCreate": return Optional.ofNullable(clazz.cast(rowsToCreate())); case "clientRequestToken": return Optional.ofNullable(clazz.cast(clientRequestToken())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((BatchCreateTableRowsRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends HoneycodeRequest.Builder, SdkPojo, CopyableBuilder { /** *

* The ID of the workbook where the new rows are being added. *

*

* If a workbook with the specified ID could not be found, this API throws ResourceNotFoundException. *

* * @param workbookId * The ID of the workbook where the new rows are being added.

*

* If a workbook with the specified ID could not be found, this API throws ResourceNotFoundException. * @return Returns a reference to this object so that method calls can be chained together. */ Builder workbookId(String workbookId); /** *

* The ID of the table where the new rows are being added. *

*

* If a table with the specified ID could not be found, this API throws ResourceNotFoundException. *

* * @param tableId * The ID of the table where the new rows are being added.

*

* If a table with the specified ID could not be found, this API throws ResourceNotFoundException. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tableId(String tableId); /** *

* The list of rows to create at the end of the table. Each item in this list needs to have a batch item id to * uniquely identify the element in the request and the cells to create for that row. You need to specify at * least one item in this list. *

*

* Note that if one of the column ids in any of the rows in the request does not exist in the table, then the * request fails and no updates are made to the table. *

* * @param rowsToCreate * The list of rows to create at the end of the table. Each item in this list needs to have a batch item * id to uniquely identify the element in the request and the cells to create for that row. You need to * specify at least one item in this list.

*

* Note that if one of the column ids in any of the rows in the request does not exist in the table, then * the request fails and no updates are made to the table. * @return Returns a reference to this object so that method calls can be chained together. */ Builder rowsToCreate(Collection rowsToCreate); /** *

* The list of rows to create at the end of the table. Each item in this list needs to have a batch item id to * uniquely identify the element in the request and the cells to create for that row. You need to specify at * least one item in this list. *

*

* Note that if one of the column ids in any of the rows in the request does not exist in the table, then the * request fails and no updates are made to the table. *

* * @param rowsToCreate * The list of rows to create at the end of the table. Each item in this list needs to have a batch item * id to uniquely identify the element in the request and the cells to create for that row. You need to * specify at least one item in this list.

*

* Note that if one of the column ids in any of the rows in the request does not exist in the table, then * the request fails and no updates are made to the table. * @return Returns a reference to this object so that method calls can be chained together. */ Builder rowsToCreate(CreateRowData... rowsToCreate); /** *

* The list of rows to create at the end of the table. Each item in this list needs to have a batch item id to * uniquely identify the element in the request and the cells to create for that row. You need to specify at * least one item in this list. *

*

* Note that if one of the column ids in any of the rows in the request does not exist in the table, then the * request fails and no updates are made to the table. *

* This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.honeycode.model.CreateRowData.Builder} avoiding the need to create one * manually via {@link software.amazon.awssdk.services.honeycode.model.CreateRowData#builder()}. * *

* When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.honeycode.model.CreateRowData.Builder#build()} is called immediately * and its result is passed to {@link #rowsToCreate(List)}. * * @param rowsToCreate * a consumer that will call methods on * {@link software.amazon.awssdk.services.honeycode.model.CreateRowData.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #rowsToCreate(java.util.Collection) */ Builder rowsToCreate(Consumer... rowsToCreate); /** *

* The request token for performing the batch create operation. Request tokens help to identify duplicate * requests. If a call times out or fails due to a transient error like a failed network connection, you can * retry the call with the same request token. The service ensures that if the first call using that request * token is successfully performed, the second call will not perform the operation again. *

*

* Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe requests * spanning hours or days. *

* * @param clientRequestToken * The request token for performing the batch create operation. Request tokens help to identify duplicate * requests. If a call times out or fails due to a transient error like a failed network connection, you * can retry the call with the same request token. The service ensures that if the first call using that * request token is successfully performed, the second call will not perform the operation again.

*

* Note that request tokens are valid only for a few minutes. You cannot use request tokens to dedupe * requests spanning hours or days. * @return Returns a reference to this object so that method calls can be chained together. */ Builder clientRequestToken(String clientRequestToken); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends HoneycodeRequest.BuilderImpl implements Builder { private String workbookId; private String tableId; private List rowsToCreate = DefaultSdkAutoConstructList.getInstance(); private String clientRequestToken; private BuilderImpl() { } private BuilderImpl(BatchCreateTableRowsRequest model) { super(model); workbookId(model.workbookId); tableId(model.tableId); rowsToCreate(model.rowsToCreate); clientRequestToken(model.clientRequestToken); } public final String getWorkbookId() { return workbookId; } public final void setWorkbookId(String workbookId) { this.workbookId = workbookId; } @Override public final Builder workbookId(String workbookId) { this.workbookId = workbookId; return this; } public final String getTableId() { return tableId; } public final void setTableId(String tableId) { this.tableId = tableId; } @Override public final Builder tableId(String tableId) { this.tableId = tableId; return this; } public final List getRowsToCreate() { List result = CreateRowDataListCopier.copyToBuilder(this.rowsToCreate); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setRowsToCreate(Collection rowsToCreate) { this.rowsToCreate = CreateRowDataListCopier.copyFromBuilder(rowsToCreate); } @Override public final Builder rowsToCreate(Collection rowsToCreate) { this.rowsToCreate = CreateRowDataListCopier.copy(rowsToCreate); return this; } @Override @SafeVarargs public final Builder rowsToCreate(CreateRowData... rowsToCreate) { rowsToCreate(Arrays.asList(rowsToCreate)); return this; } @Override @SafeVarargs public final Builder rowsToCreate(Consumer... rowsToCreate) { rowsToCreate(Stream.of(rowsToCreate).map(c -> CreateRowData.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final String getClientRequestToken() { return clientRequestToken; } public final void setClientRequestToken(String clientRequestToken) { this.clientRequestToken = clientRequestToken; } @Override public final Builder clientRequestToken(String clientRequestToken) { this.clientRequestToken = clientRequestToken; return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public BatchCreateTableRowsRequest build() { return new BatchCreateTableRowsRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy