index
int64
0
0
repo_id
stringlengths
26
205
file_path
stringlengths
51
246
content
stringlengths
8
433k
__index_level_0__
int64
0
10k
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsresponse.java
package software.amazon.awssdk.services.sharedeventstream.model; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; import software.amazon.awssdk.core.SdkPojo; 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 StreamBirthsResponse extends SharedEventStreamResponse implements ToCopyableBuilder<StreamBirthsResponse.Builder, StreamBirthsResponse> { private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); private StreamBirthsResponse(BuilderImpl builder) { super(builder); } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); 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 StreamBirthsResponse)) { return false; } return true; } /** * 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("StreamBirthsResponse").build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { return Optional.empty(); } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } public interface Builder extends SharedEventStreamResponse.Builder, SdkPojo, CopyableBuilder<Builder, StreamBirthsResponse> { } static final class BuilderImpl extends SharedEventStreamResponse.BuilderImpl implements Builder { private BuilderImpl() { } private BuilderImpl(StreamBirthsResponse model) { super(model); } @Override public StreamBirthsResponse build() { return new StreamBirthsResponse(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,200
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streambirthsrequest.java
package software.amazon.awssdk.services.sharedeventstream.model; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.function.Consumer; 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.utils.ToString; import software.amazon.awssdk.utils.builder.CopyableBuilder; import software.amazon.awssdk.utils.builder.ToCopyableBuilder; @Generated("software.amazon.awssdk:codegen") public final class StreamBirthsRequest extends SharedEventStreamRequest implements ToCopyableBuilder<StreamBirthsRequest.Builder, StreamBirthsRequest> { private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); private StreamBirthsRequest(BuilderImpl builder) { super(builder); } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); 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 StreamBirthsRequest)) { return false; } return true; } /** * 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("StreamBirthsRequest").build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { return Optional.empty(); } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } public interface Builder extends SharedEventStreamRequest.Builder, SdkPojo, CopyableBuilder<Builder, StreamBirthsRequest> { @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer); } static final class BuilderImpl extends SharedEventStreamRequest.BuilderImpl implements Builder { private BuilderImpl() { } private BuilderImpl(StreamBirthsRequest model) { super(model); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public StreamBirthsRequest build() { return new StreamBirthsRequest(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,201
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/eventstream.java
package software.amazon.awssdk.services.sharedeventstream.model; import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Map; import java.util.Set; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.core.SdkField; import software.amazon.awssdk.core.SdkPojo; import software.amazon.awssdk.services.sharedeventstream.model.eventstream.DefaultPerson; import software.amazon.awssdk.utils.internal.EnumUtils; /** * Base interface for all event types in EventStream. */ @Generated("software.amazon.awssdk:codegen") @SdkPublicApi public interface EventStream extends SdkPojo { /** * Special type of {@link EventStream} for unknown types of events that this version of the SDK does not know about */ EventStream UNKNOWN = new EventStream() { @Override public List<SdkField<?>> sdkFields() { return Collections.emptyList(); } @Override public void accept(StreamBirthsResponseHandler.Visitor visitor) { visitor.visitDefault(this); } @Override public void accept(StreamDeathsResponseHandler.Visitor visitor) { visitor.visitDefault(this); } }; /** * Create a builder for the {@code Person} event type for this stream. */ static Person.Builder personBuilder() { return DefaultPerson.builder(); } /** * The type of this event. Corresponds to the {@code :event-type} header on the Message. */ default EventType sdkEventType() { return EventType.UNKNOWN_TO_SDK_VERSION; } /** * Calls the appropriate visit method depending on the subtype of {@link EventStream}. * * @param visitor * Visitor to invoke. */ void accept(StreamBirthsResponseHandler.Visitor visitor); /** * Calls the appropriate visit method depending on the subtype of {@link EventStream}. * * @param visitor * Visitor to invoke. */ void accept(StreamDeathsResponseHandler.Visitor visitor); /** * The known possible types of events for {@code EventStream}. */ @Generated("software.amazon.awssdk:codegen") enum EventType { PERSON("Person"), UNKNOWN_TO_SDK_VERSION(null); private static final Map<String, EventType> VALUE_MAP = EnumUtils.uniqueIndex(EventType.class, EventType::toString); private final String value; private EventType(String value) { this.value = value; } @Override public String toString() { return String.valueOf(value); } /** * Use this in place of valueOf to convert the raw string returned by the service into the enum value. * * @param value * real value * @return EventType corresponding to the value */ public static EventType fromValue(String value) { if (value == null) { return null; } return VALUE_MAP.getOrDefault(value, UNKNOWN_TO_SDK_VERSION); } /** * Use this in place of {@link #values()} to return a {@link Set} of all values known to the SDK. This will * return all known enum values except {@link #UNKNOWN_TO_SDK_VERSION}. * * @return a {@link Set} of known {@link EventType}s */ public static Set<EventType> knownValues() { Set<EventType> knownValues = EnumSet.allOf(EventType.class); knownValues.remove(UNKNOWN_TO_SDK_VERSION); return knownValues; } } }
3,202
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/person.java
package software.amazon.awssdk.services.sharedeventstream.model; import java.io.Serializable; import java.time.Instant; import java.util.Arrays; 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 software.amazon.awssdk.annotations.Generated; 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.LocationTrait; 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 class Person implements SdkPojo, Serializable, ToCopyableBuilder<Person.Builder, Person>, EventStream { private static final SdkField<String> NAME_FIELD = SdkField.<String> builder(MarshallingType.STRING).memberName("Name") .getter(getter(Person::name)).setter(setter(Builder::name)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build(); private static final SdkField<Instant> BIRTHDAY_FIELD = SdkField.<Instant> builder(MarshallingType.INSTANT) .memberName("Birthday").getter(getter(Person::birthday)).setter(setter(Builder::birthday)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Birthday").build()).build(); private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, BIRTHDAY_FIELD)); private static final long serialVersionUID = 1L; private final String name; private final Instant birthday; protected Person(BuilderImpl builder) { this.name = builder.name; this.birthday = builder.birthday; } /** * Returns the value of the Name property for this object. * * @return The value of the Name property for this object. */ public final String name() { return name; } /** * Returns the value of the Birthday property for this object. * * @return The value of the Birthday property for this object. */ public final Instant birthday() { return birthday; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(name()); hashCode = 31 * hashCode + Objects.hashCode(birthday()); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof Person)) { return false; } Person other = (Person) obj; return Objects.equals(name(), other.name()) && Objects.equals(birthday(), other.birthday()); } /** * 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("Person").add("Name", name()).add("Birthday", birthday()).build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "Name": return Optional.ofNullable(clazz.cast(name())); case "Birthday": return Optional.ofNullable(clazz.cast(birthday())); default: return Optional.empty(); } } @Override public final Person copy(Consumer<? super Builder> modifier) { return ToCopyableBuilder.super.copy(modifier); } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } private static <T> Function<Object, T> getter(Function<Person, T> g) { return obj -> g.apply((Person) obj); } private static <T> BiConsumer<Object, T> setter(BiConsumer<Builder, T> s) { return (obj, val) -> s.accept((Builder) obj, val); } /** * Calls the appropriate visit method depending on the subtype of {@link Person}. * * @param visitor * Visitor to invoke. */ @Override public void accept(StreamBirthsResponseHandler.Visitor visitor) { throw new UnsupportedOperationException(); } /** * Calls the appropriate visit method depending on the subtype of {@link Person}. * * @param visitor * Visitor to invoke. */ @Override public void accept(StreamDeathsResponseHandler.Visitor visitor) { throw new UnsupportedOperationException(); } public interface Builder extends SdkPojo, CopyableBuilder<Builder, Person> { /** * Sets the value of the Name property for this object. * * @param name * The new value for the Name property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder name(String name); /** * Sets the value of the Birthday property for this object. * * @param birthday * The new value for the Birthday property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder birthday(Instant birthday); } protected static class BuilderImpl implements Builder { private String name; private Instant birthday; protected BuilderImpl() { } protected BuilderImpl(Person model) { name(model.name); birthday(model.birthday); } public final String getName() { return name; } public final void setName(String name) { this.name = name; } @Override public final Builder name(String name) { this.name = name; return this; } public final Instant getBirthday() { return birthday; } public final void setBirthday(Instant birthday) { this.birthday = birthday; } @Override public final Builder birthday(Instant birthday) { this.birthday = birthday; return this; } @Override public Person build() { return new Person(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,203
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsrequest.java
package software.amazon.awssdk.services.sharedeventstream.model; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; import java.util.function.Consumer; 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.utils.ToString; import software.amazon.awssdk.utils.builder.CopyableBuilder; import software.amazon.awssdk.utils.builder.ToCopyableBuilder; @Generated("software.amazon.awssdk:codegen") public final class StreamDeathsRequest extends SharedEventStreamRequest implements ToCopyableBuilder<StreamDeathsRequest.Builder, StreamDeathsRequest> { private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); private StreamDeathsRequest(BuilderImpl builder) { super(builder); } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); 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 StreamDeathsRequest)) { return false; } return true; } /** * 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("StreamDeathsRequest").build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { return Optional.empty(); } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } public interface Builder extends SharedEventStreamRequest.Builder, SdkPojo, CopyableBuilder<Builder, StreamDeathsRequest> { @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer); } static final class BuilderImpl extends SharedEventStreamRequest.BuilderImpl implements Builder { private BuilderImpl() { } private BuilderImpl(StreamDeathsRequest model) { super(model); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public StreamDeathsRequest build() { return new StreamDeathsRequest(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,204
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/streamdeathsresponse.java
package software.amazon.awssdk.services.sharedeventstream.model; import java.util.Arrays; import java.util.Collections; import java.util.List; import java.util.Optional; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.SdkField; import software.amazon.awssdk.core.SdkPojo; 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 StreamDeathsResponse extends SharedEventStreamResponse implements ToCopyableBuilder<StreamDeathsResponse.Builder, StreamDeathsResponse> { private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList()); private StreamDeathsResponse(BuilderImpl builder) { super(builder); } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); 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 StreamDeathsResponse)) { return false; } return true; } /** * 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("StreamDeathsResponse").build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { return Optional.empty(); } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } public interface Builder extends SharedEventStreamResponse.Builder, SdkPojo, CopyableBuilder<Builder, StreamDeathsResponse> { } static final class BuilderImpl extends SharedEventStreamResponse.BuilderImpl implements Builder { private BuilderImpl() { } private BuilderImpl(StreamDeathsResponse model) { super(model); } @Override public StreamDeathsResponse build() { return new StreamDeathsResponse(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,205
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/sharedstream/getrandompersonresponse.java
package software.amazon.awssdk.services.sharedeventstream.model; import java.time.Instant; import java.util.Arrays; 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 software.amazon.awssdk.annotations.Generated; 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.LocationTrait; 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 class GetRandomPersonResponse extends SharedEventStreamResponse implements ToCopyableBuilder<GetRandomPersonResponse.Builder, GetRandomPersonResponse> { private static final SdkField<String> NAME_FIELD = SdkField.<String> builder(MarshallingType.STRING).memberName("Name") .getter(getter(GetRandomPersonResponse::name)).setter(setter(Builder::name)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build(); private static final SdkField<Instant> BIRTHDAY_FIELD = SdkField.<Instant> builder(MarshallingType.INSTANT) .memberName("Birthday").getter(getter(GetRandomPersonResponse::birthday)).setter(setter(Builder::birthday)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Birthday").build()).build(); private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD, BIRTHDAY_FIELD)); private final String name; private final Instant birthday; protected GetRandomPersonResponse(BuilderImpl builder) { super(builder); this.name = builder.name; this.birthday = builder.birthday; } /** * Returns the value of the Name property for this object. * * @return The value of the Name property for this object. */ public final String name() { return name; } /** * Returns the value of the Birthday property for this object. * * @return The value of the Birthday property for this object. */ public final Instant birthday() { return birthday; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(name()); hashCode = 31 * hashCode + Objects.hashCode(birthday()); 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 GetRandomPersonResponse)) { return false; } GetRandomPersonResponse other = (GetRandomPersonResponse) obj; return Objects.equals(name(), other.name()) && Objects.equals(birthday(), other.birthday()); } /** * 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("GetRandomPersonResponse").add("Name", name()).add("Birthday", birthday()).build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "Name": return Optional.ofNullable(clazz.cast(name())); case "Birthday": return Optional.ofNullable(clazz.cast(birthday())); default: return Optional.empty(); } } @Override public final GetRandomPersonResponse copy(Consumer<? super Builder> modifier) { return ToCopyableBuilder.super.copy(modifier); } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } private static <T> Function<Object, T> getter(Function<GetRandomPersonResponse, T> g) { return obj -> g.apply((GetRandomPersonResponse) obj); } private static <T> BiConsumer<Object, T> setter(BiConsumer<Builder, T> s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SharedEventStreamResponse.Builder, SdkPojo, CopyableBuilder<Builder, GetRandomPersonResponse> { /** * Sets the value of the Name property for this object. * * @param name * The new value for the Name property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder name(String name); /** * Sets the value of the Birthday property for this object. * * @param birthday * The new value for the Birthday property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder birthday(Instant birthday); } protected static class BuilderImpl extends SharedEventStreamResponse.BuilderImpl implements Builder { private String name; private Instant birthday; protected BuilderImpl() { } protected BuilderImpl(GetRandomPersonResponse model) { super(model); name(model.name); birthday(model.birthday); } public final String getName() { return name; } public final void setName(String name) { this.name = name; } @Override public final Builder name(String name) { this.name = name; return this; } public final Instant getBirthday() { return birthday; } public final void setBirthday(Instant birthday) { this.birthday = birthday; } @Override public final Builder birthday(Instant birthday) { this.birthday = birthday; return this; } @Override public GetRandomPersonResponse build() { return new GetRandomPersonResponse(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,206
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/existencechecknamingresponse.java
package software.amazon.awssdk.services.jsonprotocoltests.model; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Function; import software.amazon.awssdk.annotations.Generated; 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.traits.MapTrait; import software.amazon.awssdk.core.util.SdkAutoConstructList; import software.amazon.awssdk.core.util.SdkAutoConstructMap; 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 ExistenceCheckNamingResponse extends JsonProtocolTestsResponse implements ToCopyableBuilder<ExistenceCheckNamingResponse.Builder, ExistenceCheckNamingResponse> { private static final SdkField<List<String>> BUILD_FIELD = SdkField .<List<String>> builder(MarshallingType.LIST) .memberName("Build") .getter(getter(ExistenceCheckNamingResponse::build)) .setter(setter(Builder::build)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Build").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<List<String>> SUPER_FIELD = SdkField .<List<String>> builder(MarshallingType.LIST) .memberName("super") .getter(getter(ExistenceCheckNamingResponse::superValue)) .setter(setter(Builder::superValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("super").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<Map<String, String>> TO_STRING_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("toString") .getter(getter(ExistenceCheckNamingResponse::toStringValue)) .setter(setter(Builder::toStringValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("toString").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, String>> EQUALS_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("equals") .getter(getter(ExistenceCheckNamingResponse::equalsValue)) .setter(setter(Builder::equalsValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("equals").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BUILD_FIELD, SUPER_FIELD, TO_STRING_FIELD, EQUALS_FIELD)); private final List<String> build; private final List<String> superValue; private final Map<String, String> toStringValue; private final Map<String, String> equalsValue; private ExistenceCheckNamingResponse(BuilderImpl builder) { super(builder); this.build = builder.build; this.superValue = builder.superValue; this.toStringValue = builder.toStringValue; this.equalsValue = builder.equalsValue; } /** * Returns true if the Build property was specified by the sender (it may be empty), or false if the sender did not * specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasBuild() { return build != null && !(build instanceof SdkAutoConstructList); } /** * Returns the value of the Build property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasBuild()} to see if a value was sent in this field. * </p> * * @return The value of the Build property for this object. */ public final List<String> build() { return build; } /** * Returns true if the Super property was specified by the sender (it may be empty), or false if the sender did not * specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasSuperValue() { return superValue != null && !(superValue instanceof SdkAutoConstructList); } /** * Returns the value of the Super property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasSuperValue()} to see if a value was sent in this field. * </p> * * @return The value of the Super property for this object. */ public final List<String> superValue() { return superValue; } /** * Returns true if the ToString property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasToStringValue() { return toStringValue != null && !(toStringValue instanceof SdkAutoConstructMap); } /** * Returns the value of the ToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasToStringValue()} to see if a value was sent in this field. * </p> * * @return The value of the ToString property for this object. */ public final Map<String, String> toStringValue() { return toStringValue; } /** * Returns true if the Equals property was specified by the sender (it may be empty), or false if the sender did not * specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasEqualsValue() { return equalsValue != null && !(equalsValue instanceof SdkAutoConstructMap); } /** * Returns the value of the Equals property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasEqualsValue()} to see if a value was sent in this field. * </p> * * @return The value of the Equals property for this object. */ public final Map<String, String> equalsValue() { return equalsValue; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(build()); hashCode = 31 * hashCode + Objects.hashCode(superValue()); hashCode = 31 * hashCode + Objects.hashCode(toStringValue()); hashCode = 31 * hashCode + Objects.hashCode(equalsValue()); 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 ExistenceCheckNamingResponse)) { return false; } ExistenceCheckNamingResponse other = (ExistenceCheckNamingResponse) obj; return Objects.equals(build(), other.build()) && Objects.equals(superValue(), other.superValue()) && Objects.equals(toStringValue(), other.toStringValue()) && Objects.equals(equalsValue(), other.equalsValue()); } /** * 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("ExistenceCheckNamingResponse").add("Build", build()).add("Super", superValue()) .add("ToString", toStringValue()).add("Equals", equalsValue()).build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "Build": return Optional.ofNullable(clazz.cast(build())); case "super": return Optional.ofNullable(clazz.cast(superValue())); case "toString": return Optional.ofNullable(clazz.cast(toStringValue())); case "equals": return Optional.ofNullable(clazz.cast(equalsValue())); default: return Optional.empty(); } } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } private static <T> Function<Object, T> getter(Function<ExistenceCheckNamingResponse, T> g) { return obj -> g.apply((ExistenceCheckNamingResponse) obj); } private static <T> BiConsumer<Object, T> setter(BiConsumer<Builder, T> s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, CopyableBuilder<Builder, ExistenceCheckNamingResponse> { /** * Sets the value of the Build property for this object. * * @param build * The new value for the Build property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder build(Collection<String> build); /** * Sets the value of the Build property for this object. * * @param build * The new value for the Build property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder build(String... build); /** * Sets the value of the Super property for this object. * * @param superValue * The new value for the Super property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder superValue(Collection<String> superValue); /** * Sets the value of the Super property for this object. * * @param superValue * The new value for the Super property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder superValue(String... superValue); /** * Sets the value of the ToString property for this object. * * @param toStringValue * The new value for the ToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder toStringValue(Map<String, String> toStringValue); /** * Sets the value of the Equals property for this object. * * @param equalsValue * The new value for the Equals property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder equalsValue(Map<String, String> equalsValue); } static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl implements Builder { private List<String> build; private List<String> superValue; private Map<String, String> toStringValue; private Map<String, String> equalsValue; private BuilderImpl() { } private BuilderImpl(ExistenceCheckNamingResponse model) { super(model); build(model.build); superValue(model.superValue); toStringValue(model.toStringValue); equalsValue(model.equalsValue); } public final Collection<String> getBuild() { return build; } @Override public final Builder build(Collection<String> build) { this.build = ListOfStringsCopier.copy(build); return this; } @Override @SafeVarargs public final Builder build(String... build) { build(Arrays.asList(build)); return this; } public final void setBuild(Collection<String> build) { this.build = ListOfStringsCopier.copy(build); } public final Collection<String> getSuperValue() { return superValue; } @Override public final Builder superValue(Collection<String> superValue) { this.superValue = ListOfStringsCopier.copy(superValue); return this; } @Override @SafeVarargs public final Builder superValue(String... superValue) { superValue(Arrays.asList(superValue)); return this; } public final void setSuperValue(Collection<String> superValue) { this.superValue = ListOfStringsCopier.copy(superValue); } public final Map<String, String> getToStringValue() { return toStringValue; } @Override public final Builder toStringValue(Map<String, String> toStringValue) { this.toStringValue = MapOfStringToStringCopier.copy(toStringValue); return this; } public final void setToStringValue(Map<String, String> toStringValue) { this.toStringValue = MapOfStringToStringCopier.copy(toStringValue); } public final Map<String, String> getEqualsValue() { return equalsValue; } @Override public final Builder equalsValue(Map<String, String> equalsValue) { this.equalsValue = MapOfStringToStringCopier.copy(equalsValue); return this; } public final void setEqualsValue(Map<String, String> equalsValue) { this.equalsValue = MapOfStringToStringCopier.copy(equalsValue); } @Override public ExistenceCheckNamingResponse build() { return new ExistenceCheckNamingResponse(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,207
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/nestedcontainersresponse.java
package software.amazon.awssdk.services.jsonprotocoltests.model; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Function; import software.amazon.awssdk.annotations.Generated; 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.traits.MapTrait; import software.amazon.awssdk.core.util.SdkAutoConstructList; import software.amazon.awssdk.core.util.SdkAutoConstructMap; 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 NestedContainersResponse extends JsonProtocolTestsResponse implements ToCopyableBuilder<NestedContainersResponse.Builder, NestedContainersResponse> { private static final SdkField<List<List<String>>> LIST_OF_LIST_OF_STRINGS_FIELD = SdkField .<List<List<String>>> builder(MarshallingType.LIST) .memberName("ListOfListOfStrings") .getter(getter(NestedContainersResponse::listOfListOfStrings)) .setter(setter(Builder::listOfListOfStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfStrings").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<List<String>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()) .build()).build()).build()).build(); private static final SdkField<List<List<List<String>>>> LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD = SdkField .<List<List<List<String>>>> builder(MarshallingType.LIST) .memberName("ListOfListOfListOfStrings") .getter(getter(NestedContainersResponse::listOfListOfListOfStrings)) .setter(setter(Builder::listOfListOfListOfStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfListOfStrings").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<List<List<String>>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<List<String>> builder(MarshallingType.LIST) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder( MarshallingType.STRING) .traits(LocationTrait .builder() .location( MarshallLocation.PAYLOAD) .locationName( "member") .build()) .build()).build()) .build()).build()).build()).build()).build(); private static final SdkField<Map<String, List<List<String>>>> MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD = SdkField .<Map<String, List<List<String>>>> builder(MarshallingType.MAP) .memberName("MapOfStringToListOfListOfStrings") .getter(getter(NestedContainersResponse::mapOfStringToListOfListOfStrings)) .setter(setter(Builder::mapOfStringToListOfListOfStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToListOfListOfStrings") .build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<List<List<String>>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<List<String>> builder(MarshallingType.LIST) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder( MarshallingType.STRING) .traits(LocationTrait .builder() .location( MarshallLocation.PAYLOAD) .locationName( "member") .build()) .build()).build()) .build()).build()).build()).build()).build(); private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LIST_OF_LIST_OF_STRINGS_FIELD, LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD, MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD)); private final List<List<String>> listOfListOfStrings; private final List<List<List<String>>> listOfListOfListOfStrings; private final Map<String, List<List<String>>> mapOfStringToListOfListOfStrings; private NestedContainersResponse(BuilderImpl builder) { super(builder); this.listOfListOfStrings = builder.listOfListOfStrings; this.listOfListOfListOfStrings = builder.listOfListOfListOfStrings; this.mapOfStringToListOfListOfStrings = builder.mapOfStringToListOfListOfStrings; } /** * Returns true if the ListOfListOfStrings property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasListOfListOfStrings() { return listOfListOfStrings != null && !(listOfListOfStrings instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfListOfStrings property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfListOfStrings()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfListOfStrings property for this object. */ public final List<List<String>> listOfListOfStrings() { return listOfListOfStrings; } /** * Returns true if the ListOfListOfListOfStrings property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasListOfListOfListOfStrings() { return listOfListOfListOfStrings != null && !(listOfListOfListOfStrings instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfListOfListOfStrings property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfListOfListOfStrings()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfListOfListOfStrings property for this object. */ public final List<List<List<String>>> listOfListOfListOfStrings() { return listOfListOfListOfStrings; } /** * Returns true if the MapOfStringToListOfListOfStrings property was specified by the sender (it may be empty), or * false if the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender * is the AWS service. */ public final boolean hasMapOfStringToListOfListOfStrings() { return mapOfStringToListOfListOfStrings != null && !(mapOfStringToListOfListOfStrings instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToListOfListOfStrings property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToListOfListOfStrings()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToListOfListOfStrings property for this object. */ public final Map<String, List<List<String>>> mapOfStringToListOfListOfStrings() { return mapOfStringToListOfListOfStrings; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(listOfListOfStrings()); hashCode = 31 * hashCode + Objects.hashCode(listOfListOfListOfStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToListOfListOfStrings()); 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 NestedContainersResponse)) { return false; } NestedContainersResponse other = (NestedContainersResponse) obj; return Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); } /** * 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("NestedContainersResponse").add("ListOfListOfStrings", listOfListOfStrings()) .add("ListOfListOfListOfStrings", listOfListOfListOfStrings()) .add("MapOfStringToListOfListOfStrings", mapOfStringToListOfListOfStrings()).build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "ListOfListOfStrings": return Optional.ofNullable(clazz.cast(listOfListOfStrings())); case "ListOfListOfListOfStrings": return Optional.ofNullable(clazz.cast(listOfListOfListOfStrings())); case "MapOfStringToListOfListOfStrings": return Optional.ofNullable(clazz.cast(mapOfStringToListOfListOfStrings())); default: return Optional.empty(); } } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } private static <T> Function<Object, T> getter(Function<NestedContainersResponse, T> g) { return obj -> g.apply((NestedContainersResponse) obj); } private static <T> BiConsumer<Object, T> setter(BiConsumer<Builder, T> s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, CopyableBuilder<Builder, NestedContainersResponse> { /** * Sets the value of the ListOfListOfStrings property for this object. * * @param listOfListOfStrings * The new value for the ListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfListOfStrings(Collection<? extends Collection<String>> listOfListOfStrings); /** * Sets the value of the ListOfListOfStrings property for this object. * * @param listOfListOfStrings * The new value for the ListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfListOfStrings(Collection<String>... listOfListOfStrings); /** * Sets the value of the ListOfListOfListOfStrings property for this object. * * @param listOfListOfListOfStrings * The new value for the ListOfListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfListOfListOfStrings(Collection<? extends Collection<? extends Collection<String>>> listOfListOfListOfStrings); /** * Sets the value of the ListOfListOfListOfStrings property for this object. * * @param listOfListOfListOfStrings * The new value for the ListOfListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfListOfListOfStrings(Collection<? extends Collection<String>>... listOfListOfListOfStrings); /** * Sets the value of the MapOfStringToListOfListOfStrings property for this object. * * @param mapOfStringToListOfListOfStrings * The new value for the MapOfStringToListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToListOfListOfStrings( Map<String, ? extends Collection<? extends Collection<String>>> mapOfStringToListOfListOfStrings); } static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl implements Builder { private List<List<String>> listOfListOfStrings; private List<List<List<String>>> listOfListOfListOfStrings; private Map<String, List<List<String>>> mapOfStringToListOfListOfStrings; private BuilderImpl() { } private BuilderImpl(NestedContainersResponse model) { super(model); listOfListOfStrings(model.listOfListOfStrings); listOfListOfListOfStrings(model.listOfListOfListOfStrings); mapOfStringToListOfListOfStrings(model.mapOfStringToListOfListOfStrings); } public final Collection<? extends Collection<String>> getListOfListOfStrings() { return listOfListOfStrings; } @Override public final Builder listOfListOfStrings(Collection<? extends Collection<String>> listOfListOfStrings) { this.listOfListOfStrings = ListOfListOfStringsCopier.copy(listOfListOfStrings); return this; } @Override @SafeVarargs public final Builder listOfListOfStrings(Collection<String>... listOfListOfStrings) { listOfListOfStrings(Arrays.asList(listOfListOfStrings)); return this; } public final void setListOfListOfStrings(Collection<? extends Collection<String>> listOfListOfStrings) { this.listOfListOfStrings = ListOfListOfStringsCopier.copy(listOfListOfStrings); } public final Collection<? extends Collection<? extends Collection<String>>> getListOfListOfListOfStrings() { return listOfListOfListOfStrings; } @Override public final Builder listOfListOfListOfStrings( Collection<? extends Collection<? extends Collection<String>>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); return this; } @Override @SafeVarargs public final Builder listOfListOfListOfStrings(Collection<? extends Collection<String>>... listOfListOfListOfStrings) { listOfListOfListOfStrings(Arrays.asList(listOfListOfListOfStrings)); return this; } public final void setListOfListOfListOfStrings( Collection<? extends Collection<? extends Collection<String>>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); } public final Map<String, ? extends Collection<? extends Collection<String>>> getMapOfStringToListOfListOfStrings() { return mapOfStringToListOfListOfStrings; } @Override public final Builder mapOfStringToListOfListOfStrings( Map<String, ? extends Collection<? extends Collection<String>>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); return this; } public final void setMapOfStringToListOfListOfStrings( Map<String, ? extends Collection<? extends Collection<String>>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); } @Override public NestedContainersResponse build() { return new NestedContainersResponse(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,208
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/recursivestructtype.java
package software.amazon.awssdk.services.jsonprotocoltests.model; import java.io.Serializable; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; 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.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.traits.MapTrait; import software.amazon.awssdk.core.util.SdkAutoConstructList; import software.amazon.awssdk.core.util.SdkAutoConstructMap; import software.amazon.awssdk.utils.CollectionUtils; 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 RecursiveStructType implements SdkPojo, Serializable, ToCopyableBuilder<RecursiveStructType.Builder, RecursiveStructType> { private static final SdkField<String> NO_RECURSE_FIELD = SdkField.<String> builder(MarshallingType.STRING) .memberName("NoRecurse").getter(getter(RecursiveStructType::noRecurse)).setter(setter(Builder::noRecurse)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("NoRecurse").build()).build(); private static final SdkField<RecursiveStructType> RECURSIVE_STRUCT_FIELD = SdkField .<RecursiveStructType> builder(MarshallingType.SDK_POJO).memberName("RecursiveStruct") .getter(getter(RecursiveStructType::recursiveStruct)).setter(setter(Builder::recursiveStruct)) .constructor(RecursiveStructType::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveStruct").build()).build(); private static final SdkField<List<RecursiveStructType>> RECURSIVE_LIST_FIELD = SdkField .<List<RecursiveStructType>> builder(MarshallingType.LIST) .memberName("RecursiveList") .getter(getter(RecursiveStructType::recursiveList)) .setter(setter(Builder::recursiveList)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveList").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<RecursiveStructType> builder(MarshallingType.SDK_POJO) .constructor(RecursiveStructType::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<Map<String, RecursiveStructType>> RECURSIVE_MAP_FIELD = SdkField .<Map<String, RecursiveStructType>> builder(MarshallingType.MAP) .memberName("RecursiveMap") .getter(getter(RecursiveStructType::recursiveMap)) .setter(setter(Builder::recursiveMap)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveMap").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<RecursiveStructType> builder(MarshallingType.SDK_POJO) .constructor(RecursiveStructType::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NO_RECURSE_FIELD, RECURSIVE_STRUCT_FIELD, RECURSIVE_LIST_FIELD, RECURSIVE_MAP_FIELD)); private static final long serialVersionUID = 1L; private final String noRecurse; private final RecursiveStructType recursiveStruct; private final List<RecursiveStructType> recursiveList; private final Map<String, RecursiveStructType> recursiveMap; private RecursiveStructType(BuilderImpl builder) { this.noRecurse = builder.noRecurse; this.recursiveStruct = builder.recursiveStruct; this.recursiveList = builder.recursiveList; this.recursiveMap = builder.recursiveMap; } /** * Returns the value of the NoRecurse property for this object. * * @return The value of the NoRecurse property for this object. */ public final String noRecurse() { return noRecurse; } /** * Returns the value of the RecursiveStruct property for this object. * * @return The value of the RecursiveStruct property for this object. */ public final RecursiveStructType recursiveStruct() { return recursiveStruct; } /** * Returns true if the RecursiveList property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasRecursiveList() { return recursiveList != null && !(recursiveList instanceof SdkAutoConstructList); } /** * Returns the value of the RecursiveList property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasRecursiveList()} to see if a value was sent in this field. * </p> * * @return The value of the RecursiveList property for this object. */ public final List<RecursiveStructType> recursiveList() { return recursiveList; } /** * Returns true if the RecursiveMap property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasRecursiveMap() { return recursiveMap != null && !(recursiveMap instanceof SdkAutoConstructMap); } /** * Returns the value of the RecursiveMap property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasRecursiveMap()} to see if a value was sent in this field. * </p> * * @return The value of the RecursiveMap property for this object. */ public final Map<String, RecursiveStructType> recursiveMap() { return recursiveMap; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + Objects.hashCode(noRecurse()); hashCode = 31 * hashCode + Objects.hashCode(recursiveStruct()); hashCode = 31 * hashCode + Objects.hashCode(recursiveList()); hashCode = 31 * hashCode + Objects.hashCode(recursiveMap()); return hashCode; } @Override public final boolean equals(Object obj) { return equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof RecursiveStructType)) { return false; } RecursiveStructType other = (RecursiveStructType) obj; return Objects.equals(noRecurse(), other.noRecurse()) && Objects.equals(recursiveStruct(), other.recursiveStruct()) && Objects.equals(recursiveList(), other.recursiveList()) && Objects.equals(recursiveMap(), other.recursiveMap()); } /** * 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("RecursiveStructType").add("NoRecurse", noRecurse()).add("RecursiveStruct", recursiveStruct()) .add("RecursiveList", recursiveList()).add("RecursiveMap", recursiveMap()).build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "NoRecurse": return Optional.ofNullable(clazz.cast(noRecurse())); case "RecursiveStruct": return Optional.ofNullable(clazz.cast(recursiveStruct())); case "RecursiveList": return Optional.ofNullable(clazz.cast(recursiveList())); case "RecursiveMap": return Optional.ofNullable(clazz.cast(recursiveMap())); default: return Optional.empty(); } } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } private static <T> Function<Object, T> getter(Function<RecursiveStructType, T> g) { return obj -> g.apply((RecursiveStructType) obj); } private static <T> BiConsumer<Object, T> setter(BiConsumer<Builder, T> s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SdkPojo, CopyableBuilder<Builder, RecursiveStructType> { /** * Sets the value of the NoRecurse property for this object. * * @param noRecurse * The new value for the NoRecurse property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder noRecurse(String noRecurse); /** * Sets the value of the RecursiveStruct property for this object. * * @param recursiveStruct * The new value for the RecursiveStruct property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder recursiveStruct(RecursiveStructType recursiveStruct); /** * Sets the value of the RecursiveStruct property for this object. * * This is a convenience that creates an instance of the {@link RecursiveStructType.Builder} avoiding the need * to create one manually via {@link RecursiveStructType#builder()}. * * When the {@link Consumer} completes, {@link RecursiveStructType.Builder#build()} is called immediately and * its result is passed to {@link #recursiveStruct(RecursiveStructType)}. * * @param recursiveStruct * a consumer that will call methods on {@link RecursiveStructType.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #recursiveStruct(RecursiveStructType) */ default Builder recursiveStruct(Consumer<Builder> recursiveStruct) { return recursiveStruct(RecursiveStructType.builder().applyMutation(recursiveStruct).build()); } /** * Sets the value of the RecursiveList property for this object. * * @param recursiveList * The new value for the RecursiveList property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder recursiveList(Collection<RecursiveStructType> recursiveList); /** * Sets the value of the RecursiveList property for this object. * * @param recursiveList * The new value for the RecursiveList property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder recursiveList(RecursiveStructType... recursiveList); /** * Sets the value of the RecursiveList property for this object. * * This is a convenience that creates an instance of the {@link List<RecursiveStructType>.Builder} avoiding the * need to create one manually via {@link List<RecursiveStructType>#builder()}. * * When the {@link Consumer} completes, {@link List<RecursiveStructType>.Builder#build()} is called immediately * and its result is passed to {@link #recursiveList(List<RecursiveStructType>)}. * * @param recursiveList * a consumer that will call methods on {@link List<RecursiveStructType>.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #recursiveList(List<RecursiveStructType>) */ Builder recursiveList(Consumer<Builder>... recursiveList); /** * Sets the value of the RecursiveMap property for this object. * * @param recursiveMap * The new value for the RecursiveMap property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder recursiveMap(Map<String, RecursiveStructType> recursiveMap); } static final class BuilderImpl implements Builder { private String noRecurse; private RecursiveStructType recursiveStruct; private List<RecursiveStructType> recursiveList; private Map<String, RecursiveStructType> recursiveMap; private BuilderImpl() { } private BuilderImpl(RecursiveStructType model) { noRecurse(model.noRecurse); recursiveStruct(model.recursiveStruct); recursiveList(model.recursiveList); recursiveMap(model.recursiveMap); } public final String getNoRecurse() { return noRecurse; } @Override public final Builder noRecurse(String noRecurse) { this.noRecurse = noRecurse; return this; } public final void setNoRecurse(String noRecurse) { this.noRecurse = noRecurse; } public final Builder getRecursiveStruct() { return recursiveStruct != null ? recursiveStruct.toBuilder() : null; } @Override public final Builder recursiveStruct(RecursiveStructType recursiveStruct) { this.recursiveStruct = recursiveStruct; return this; } public final void setRecursiveStruct(BuilderImpl recursiveStruct) { this.recursiveStruct = recursiveStruct != null ? recursiveStruct.build() : null; } public final Collection<Builder> getRecursiveList() { return recursiveList != null ? recursiveList.stream().map(RecursiveStructType::toBuilder) .collect(Collectors.toList()) : null; } @Override public final Builder recursiveList(Collection<RecursiveStructType> recursiveList) { this.recursiveList = RecursiveListTypeCopier.copy(recursiveList); return this; } @Override @SafeVarargs public final Builder recursiveList(RecursiveStructType... recursiveList) { recursiveList(Arrays.asList(recursiveList)); return this; } @Override @SafeVarargs public final Builder recursiveList(Consumer<Builder>... recursiveList) { recursiveList(Stream.of(recursiveList).map(c -> RecursiveStructType.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setRecursiveList(Collection<BuilderImpl> recursiveList) { this.recursiveList = RecursiveListTypeCopier.copyFromBuilder(recursiveList); } public final Map<String, Builder> getRecursiveMap() { return recursiveMap != null ? CollectionUtils.mapValues(recursiveMap, RecursiveStructType::toBuilder) : null; } @Override public final Builder recursiveMap(Map<String, RecursiveStructType> recursiveMap) { this.recursiveMap = RecursiveMapTypeCopier.copy(recursiveMap); return this; } public final void setRecursiveMap(Map<String, BuilderImpl> recursiveMap) { this.recursiveMap = RecursiveMapTypeCopier.copyFromBuilder(recursiveMap); } @Override public RecursiveStructType build() { return new RecursiveStructType(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,209
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/nestedcontainersrequest.java
package software.amazon.awssdk.services.jsonprotocoltests.model; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; 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.traits.MapTrait; import software.amazon.awssdk.core.util.SdkAutoConstructList; import software.amazon.awssdk.core.util.SdkAutoConstructMap; 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 NestedContainersRequest extends JsonProtocolTestsRequest implements ToCopyableBuilder<NestedContainersRequest.Builder, NestedContainersRequest> { private static final SdkField<List<List<String>>> LIST_OF_LIST_OF_STRINGS_FIELD = SdkField .<List<List<String>>> builder(MarshallingType.LIST) .memberName("ListOfListOfStrings") .getter(getter(NestedContainersRequest::listOfListOfStrings)) .setter(setter(Builder::listOfListOfStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfStrings").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<List<String>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()) .build()).build()).build()).build(); private static final SdkField<List<List<List<String>>>> LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD = SdkField .<List<List<List<String>>>> builder(MarshallingType.LIST) .memberName("ListOfListOfListOfStrings") .getter(getter(NestedContainersRequest::listOfListOfListOfStrings)) .setter(setter(Builder::listOfListOfListOfStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfListOfListOfStrings").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<List<List<String>>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<List<String>> builder(MarshallingType.LIST) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder( MarshallingType.STRING) .traits(LocationTrait .builder() .location( MarshallLocation.PAYLOAD) .locationName( "member") .build()) .build()).build()) .build()).build()).build()).build()).build(); private static final SdkField<Map<String, List<List<String>>>> MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD = SdkField .<Map<String, List<List<String>>>> builder(MarshallingType.MAP) .memberName("MapOfStringToListOfListOfStrings") .getter(getter(NestedContainersRequest::mapOfStringToListOfListOfStrings)) .setter(setter(Builder::mapOfStringToListOfListOfStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToListOfListOfStrings") .build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<List<List<String>>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<List<String>> builder(MarshallingType.LIST) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder( MarshallingType.STRING) .traits(LocationTrait .builder() .location( MarshallLocation.PAYLOAD) .locationName( "member") .build()) .build()).build()) .build()).build()).build()).build()).build(); private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(LIST_OF_LIST_OF_STRINGS_FIELD, LIST_OF_LIST_OF_LIST_OF_STRINGS_FIELD, MAP_OF_STRING_TO_LIST_OF_LIST_OF_STRINGS_FIELD)); private final List<List<String>> listOfListOfStrings; private final List<List<List<String>>> listOfListOfListOfStrings; private final Map<String, List<List<String>>> mapOfStringToListOfListOfStrings; private NestedContainersRequest(BuilderImpl builder) { super(builder); this.listOfListOfStrings = builder.listOfListOfStrings; this.listOfListOfListOfStrings = builder.listOfListOfListOfStrings; this.mapOfStringToListOfListOfStrings = builder.mapOfStringToListOfListOfStrings; } /** * Returns true if the ListOfListOfStrings property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasListOfListOfStrings() { return listOfListOfStrings != null && !(listOfListOfStrings instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfListOfStrings property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfListOfStrings()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfListOfStrings property for this object. */ public final List<List<String>> listOfListOfStrings() { return listOfListOfStrings; } /** * Returns true if the ListOfListOfListOfStrings property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasListOfListOfListOfStrings() { return listOfListOfListOfStrings != null && !(listOfListOfListOfStrings instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfListOfListOfStrings property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfListOfListOfStrings()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfListOfListOfStrings property for this object. */ public final List<List<List<String>>> listOfListOfListOfStrings() { return listOfListOfListOfStrings; } /** * Returns true if the MapOfStringToListOfListOfStrings property was specified by the sender (it may be empty), or * false if the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender * is the AWS service. */ public final boolean hasMapOfStringToListOfListOfStrings() { return mapOfStringToListOfListOfStrings != null && !(mapOfStringToListOfListOfStrings instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToListOfListOfStrings property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToListOfListOfStrings()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToListOfListOfStrings property for this object. */ public final Map<String, List<List<String>>> mapOfStringToListOfListOfStrings() { return mapOfStringToListOfListOfStrings; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(listOfListOfStrings()); hashCode = 31 * hashCode + Objects.hashCode(listOfListOfListOfStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToListOfListOfStrings()); 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 NestedContainersRequest)) { return false; } NestedContainersRequest other = (NestedContainersRequest) obj; return Objects.equals(listOfListOfStrings(), other.listOfListOfStrings()) && Objects.equals(listOfListOfListOfStrings(), other.listOfListOfListOfStrings()) && Objects.equals(mapOfStringToListOfListOfStrings(), other.mapOfStringToListOfListOfStrings()); } /** * 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("NestedContainersRequest").add("ListOfListOfStrings", listOfListOfStrings()) .add("ListOfListOfListOfStrings", listOfListOfListOfStrings()) .add("MapOfStringToListOfListOfStrings", mapOfStringToListOfListOfStrings()).build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "ListOfListOfStrings": return Optional.ofNullable(clazz.cast(listOfListOfStrings())); case "ListOfListOfListOfStrings": return Optional.ofNullable(clazz.cast(listOfListOfListOfStrings())); case "MapOfStringToListOfListOfStrings": return Optional.ofNullable(clazz.cast(mapOfStringToListOfListOfStrings())); default: return Optional.empty(); } } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } private static <T> Function<Object, T> getter(Function<NestedContainersRequest, T> g) { return obj -> g.apply((NestedContainersRequest) obj); } private static <T> BiConsumer<Object, T> setter(BiConsumer<Builder, T> s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, CopyableBuilder<Builder, NestedContainersRequest> { /** * Sets the value of the ListOfListOfStrings property for this object. * * @param listOfListOfStrings * The new value for the ListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfListOfStrings(Collection<? extends Collection<String>> listOfListOfStrings); /** * Sets the value of the ListOfListOfStrings property for this object. * * @param listOfListOfStrings * The new value for the ListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfListOfStrings(Collection<String>... listOfListOfStrings); /** * Sets the value of the ListOfListOfListOfStrings property for this object. * * @param listOfListOfListOfStrings * The new value for the ListOfListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfListOfListOfStrings(Collection<? extends Collection<? extends Collection<String>>> listOfListOfListOfStrings); /** * Sets the value of the ListOfListOfListOfStrings property for this object. * * @param listOfListOfListOfStrings * The new value for the ListOfListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfListOfListOfStrings(Collection<? extends Collection<String>>... listOfListOfListOfStrings); /** * Sets the value of the MapOfStringToListOfListOfStrings property for this object. * * @param mapOfStringToListOfListOfStrings * The new value for the MapOfStringToListOfListOfStrings property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToListOfListOfStrings( Map<String, ? extends Collection<? extends Collection<String>>> mapOfStringToListOfListOfStrings); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer); } static final class BuilderImpl extends JsonProtocolTestsRequest.BuilderImpl implements Builder { private List<List<String>> listOfListOfStrings; private List<List<List<String>>> listOfListOfListOfStrings; private Map<String, List<List<String>>> mapOfStringToListOfListOfStrings; private BuilderImpl() { } private BuilderImpl(NestedContainersRequest model) { super(model); listOfListOfStrings(model.listOfListOfStrings); listOfListOfListOfStrings(model.listOfListOfListOfStrings); mapOfStringToListOfListOfStrings(model.mapOfStringToListOfListOfStrings); } public final Collection<? extends Collection<String>> getListOfListOfStrings() { return listOfListOfStrings; } @Override public final Builder listOfListOfStrings(Collection<? extends Collection<String>> listOfListOfStrings) { this.listOfListOfStrings = ListOfListOfStringsCopier.copy(listOfListOfStrings); return this; } @Override @SafeVarargs public final Builder listOfListOfStrings(Collection<String>... listOfListOfStrings) { listOfListOfStrings(Arrays.asList(listOfListOfStrings)); return this; } public final void setListOfListOfStrings(Collection<? extends Collection<String>> listOfListOfStrings) { this.listOfListOfStrings = ListOfListOfStringsCopier.copy(listOfListOfStrings); } public final Collection<? extends Collection<? extends Collection<String>>> getListOfListOfListOfStrings() { return listOfListOfListOfStrings; } @Override public final Builder listOfListOfListOfStrings( Collection<? extends Collection<? extends Collection<String>>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); return this; } @Override @SafeVarargs public final Builder listOfListOfListOfStrings(Collection<? extends Collection<String>>... listOfListOfListOfStrings) { listOfListOfListOfStrings(Arrays.asList(listOfListOfListOfStrings)); return this; } public final void setListOfListOfListOfStrings( Collection<? extends Collection<? extends Collection<String>>> listOfListOfListOfStrings) { this.listOfListOfListOfStrings = ListOfListOfListOfStringsCopier.copy(listOfListOfListOfStrings); } public final Map<String, ? extends Collection<? extends Collection<String>>> getMapOfStringToListOfListOfStrings() { return mapOfStringToListOfListOfStrings; } @Override public final Builder mapOfStringToListOfListOfStrings( Map<String, ? extends Collection<? extends Collection<String>>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); return this; } public final void setMapOfStringToListOfListOfStrings( Map<String, ? extends Collection<? extends Collection<String>>> mapOfStringToListOfListOfStrings) { this.mapOfStringToListOfListOfStrings = MapOfStringToListOfListOfStringsCopier.copy(mapOfStringToListOfListOfStrings); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public NestedContainersRequest build() { return new NestedContainersRequest(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,210
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/alltypesresponse.java
package software.amazon.awssdk.services.jsonprotocoltests.model; import java.nio.ByteBuffer; import java.time.Instant; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; 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.core.SdkBytes; import software.amazon.awssdk.core.SdkField; import software.amazon.awssdk.core.SdkPojo; import software.amazon.awssdk.core.adapter.StandardMemberCopier; 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.traits.MapTrait; import software.amazon.awssdk.core.util.SdkAutoConstructList; import software.amazon.awssdk.core.util.SdkAutoConstructMap; import software.amazon.awssdk.utils.CollectionUtils; 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 AllTypesResponse extends JsonProtocolTestsResponse implements ToCopyableBuilder<AllTypesResponse.Builder, AllTypesResponse> { private static final SdkField<String> STRING_MEMBER_FIELD = SdkField.<String> builder(MarshallingType.STRING) .memberName("StringMember").getter(getter(AllTypesResponse::stringMember)).setter(setter(Builder::stringMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StringMember").build()).build(); private static final SdkField<Integer> INTEGER_MEMBER_FIELD = SdkField.<Integer> builder(MarshallingType.INTEGER) .memberName("IntegerMember").getter(getter(AllTypesResponse::integerMember)).setter(setter(Builder::integerMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IntegerMember").build()).build(); private static final SdkField<Boolean> BOOLEAN_MEMBER_FIELD = SdkField.<Boolean> builder(MarshallingType.BOOLEAN) .memberName("BooleanMember").getter(getter(AllTypesResponse::booleanMember)).setter(setter(Builder::booleanMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BooleanMember").build()).build(); private static final SdkField<Float> FLOAT_MEMBER_FIELD = SdkField.<Float> builder(MarshallingType.FLOAT) .memberName("FloatMember").getter(getter(AllTypesResponse::floatMember)).setter(setter(Builder::floatMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FloatMember").build()).build(); private static final SdkField<Double> DOUBLE_MEMBER_FIELD = SdkField.<Double> builder(MarshallingType.DOUBLE) .memberName("DoubleMember").getter(getter(AllTypesResponse::doubleMember)).setter(setter(Builder::doubleMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DoubleMember").build()).build(); private static final SdkField<Long> LONG_MEMBER_FIELD = SdkField.<Long> builder(MarshallingType.LONG) .memberName("LongMember").getter(getter(AllTypesResponse::longMember)).setter(setter(Builder::longMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LongMember").build()).build(); private static final SdkField<List<String>> SIMPLE_LIST_FIELD = SdkField .<List<String>> builder(MarshallingType.LIST) .memberName("SimpleList") .getter(getter(AllTypesResponse::simpleList)) .setter(setter(Builder::simpleList)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SimpleList").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<List<String>> LIST_OF_ENUMS_FIELD = SdkField .<List<String>> builder(MarshallingType.LIST) .memberName("ListOfEnums") .getter(getter(AllTypesResponse::listOfEnumsAsStrings)) .setter(setter(Builder::listOfEnumsWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfEnums").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<List<Map<String, String>>> LIST_OF_MAPS_FIELD = SdkField .<List<Map<String, String>>> builder(MarshallingType.LIST) .memberName("ListOfMaps") .getter(getter(AllTypesResponse::listOfMaps)) .setter(setter(Builder::listOfMaps)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMaps").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<Map<String, String>> builder(MarshallingType.MAP) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()) .build()).build()).build()).build(); private static final SdkField<List<SimpleStruct>> LIST_OF_STRUCTS_FIELD = SdkField .<List<SimpleStruct>> builder(MarshallingType.LIST) .memberName("ListOfStructs") .getter(getter(AllTypesResponse::listOfStructs)) .setter(setter(Builder::listOfStructs)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfStructs").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<SimpleStruct> builder(MarshallingType.SDK_POJO) .constructor(SimpleStruct::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<List<Map<String, String>>> LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD = SdkField .<List<Map<String, String>>> builder(MarshallingType.LIST) .memberName("ListOfMapOfEnumToString") .getter(getter(AllTypesResponse::listOfMapOfEnumToStringAsStrings)) .setter(setter(Builder::listOfMapOfEnumToStringWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMapOfEnumToString").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<Map<String, String>> builder(MarshallingType.MAP) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()) .build()).build()).build()).build(); private static final SdkField<Map<String, List<Integer>>> MAP_OF_STRING_TO_INTEGER_LIST_FIELD = SdkField .<Map<String, List<Integer>>> builder(MarshallingType.MAP) .memberName("MapOfStringToIntegerList") .getter(getter(AllTypesResponse::mapOfStringToIntegerList)) .setter(setter(Builder::mapOfStringToIntegerList)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToIntegerList").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<List<Integer>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<Integer> builder(MarshallingType.INTEGER) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()) .build()).build()).build()).build(); private static final SdkField<Map<String, String>> MAP_OF_STRING_TO_STRING_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("MapOfStringToString") .getter(getter(AllTypesResponse::mapOfStringToString)) .setter(setter(Builder::mapOfStringToString)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToString").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, SimpleStruct>> MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD = SdkField .<Map<String, SimpleStruct>> builder(MarshallingType.MAP) .memberName("MapOfStringToSimpleStruct") .getter(getter(AllTypesResponse::mapOfStringToSimpleStruct)) .setter(setter(Builder::mapOfStringToSimpleStruct)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToSimpleStruct").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<SimpleStruct> builder(MarshallingType.SDK_POJO) .constructor(SimpleStruct::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, String>> MAP_OF_ENUM_TO_ENUM_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("MapOfEnumToEnum") .getter(getter(AllTypesResponse::mapOfEnumToEnumAsStrings)) .setter(setter(Builder::mapOfEnumToEnumWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToEnum").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, String>> MAP_OF_ENUM_TO_STRING_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("MapOfEnumToString") .getter(getter(AllTypesResponse::mapOfEnumToStringAsStrings)) .setter(setter(Builder::mapOfEnumToStringWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToString").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, String>> MAP_OF_STRING_TO_ENUM_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("MapOfStringToEnum") .getter(getter(AllTypesResponse::mapOfStringToEnumAsStrings)) .setter(setter(Builder::mapOfStringToEnumWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToEnum").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, SimpleStruct>> MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD = SdkField .<Map<String, SimpleStruct>> builder(MarshallingType.MAP) .memberName("MapOfEnumToSimpleStruct") .getter(getter(AllTypesResponse::mapOfEnumToSimpleStructAsStrings)) .setter(setter(Builder::mapOfEnumToSimpleStructWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToSimpleStruct").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<SimpleStruct> builder(MarshallingType.SDK_POJO) .constructor(SimpleStruct::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, List<String>>> MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD = SdkField .<Map<String, List<String>>> builder(MarshallingType.MAP) .memberName("MapOfEnumToListOfEnums") .getter(getter(AllTypesResponse::mapOfEnumToListOfEnumsAsStrings)) .setter(setter(Builder::mapOfEnumToListOfEnumsWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToListOfEnums").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<List<String>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()) .build()).build()).build()).build(); private static final SdkField<Map<String, Map<String, String>>> MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD = SdkField .<Map<String, Map<String, String>>> builder(MarshallingType.MAP) .memberName("MapOfEnumToMapOfStringToEnum") .getter(getter(AllTypesResponse::mapOfEnumToMapOfStringToEnumAsStrings)) .setter(setter(Builder::mapOfEnumToMapOfStringToEnumWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToMapOfStringToEnum") .build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<Map<String, String>> builder(MarshallingType.MAP) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()) .build()).build()).build()).build(); private static final SdkField<Instant> TIMESTAMP_MEMBER_FIELD = SdkField.<Instant> builder(MarshallingType.INSTANT) .memberName("TimestampMember").getter(getter(AllTypesResponse::timestampMember)) .setter(setter(Builder::timestampMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimestampMember").build()).build(); private static final SdkField<StructWithTimestamp> STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD = SdkField .<StructWithTimestamp> builder(MarshallingType.SDK_POJO) .memberName("StructWithNestedTimestampMember") .getter(getter(AllTypesResponse::structWithNestedTimestampMember)) .setter(setter(Builder::structWithNestedTimestampMember)) .constructor(StructWithTimestamp::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StructWithNestedTimestampMember") .build()).build(); private static final SdkField<SdkBytes> BLOB_ARG_FIELD = SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES) .memberName("BlobArg").getter(getter(AllTypesResponse::blobArg)).setter(setter(Builder::blobArg)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BlobArg").build()).build(); private static final SdkField<StructWithNestedBlobType> STRUCT_WITH_NESTED_BLOB_FIELD = SdkField .<StructWithNestedBlobType> builder(MarshallingType.SDK_POJO).memberName("StructWithNestedBlob") .getter(getter(AllTypesResponse::structWithNestedBlob)).setter(setter(Builder::structWithNestedBlob)) .constructor(StructWithNestedBlobType::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StructWithNestedBlob").build()) .build(); private static final SdkField<Map<String, SdkBytes>> BLOB_MAP_FIELD = SdkField .<Map<String, SdkBytes>> builder(MarshallingType.MAP) .memberName("BlobMap") .getter(getter(AllTypesResponse::blobMap)) .setter(setter(Builder::blobMap)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BlobMap").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<List<SdkBytes>> LIST_OF_BLOBS_FIELD = SdkField .<List<SdkBytes>> builder(MarshallingType.LIST) .memberName("ListOfBlobs") .getter(getter(AllTypesResponse::listOfBlobs)) .setter(setter(Builder::listOfBlobs)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfBlobs").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<RecursiveStructType> RECURSIVE_STRUCT_FIELD = SdkField .<RecursiveStructType> builder(MarshallingType.SDK_POJO).memberName("RecursiveStruct") .getter(getter(AllTypesResponse::recursiveStruct)).setter(setter(Builder::recursiveStruct)) .constructor(RecursiveStructType::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveStruct").build()).build(); private static final SdkField<BaseType> POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD = SdkField .<BaseType> builder(MarshallingType.SDK_POJO) .memberName("PolymorphicTypeWithSubTypes") .getter(getter(AllTypesResponse::polymorphicTypeWithSubTypes)) .setter(setter(Builder::polymorphicTypeWithSubTypes)) .constructor(BaseType::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolymorphicTypeWithSubTypes") .build()).build(); private static final SdkField<SubTypeOne> POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD = SdkField .<SubTypeOne> builder(MarshallingType.SDK_POJO) .memberName("PolymorphicTypeWithoutSubTypes") .getter(getter(AllTypesResponse::polymorphicTypeWithoutSubTypes)) .setter(setter(Builder::polymorphicTypeWithoutSubTypes)) .constructor(SubTypeOne::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolymorphicTypeWithoutSubTypes") .build()).build(); private static final SdkField<String> ENUM_TYPE_FIELD = SdkField.<String> builder(MarshallingType.STRING) .memberName("EnumType").getter(getter(AllTypesResponse::enumTypeAsString)).setter(setter(Builder::enumType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EnumType").build()).build(); private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STRING_MEMBER_FIELD, INTEGER_MEMBER_FIELD, BOOLEAN_MEMBER_FIELD, FLOAT_MEMBER_FIELD, DOUBLE_MEMBER_FIELD, LONG_MEMBER_FIELD, SIMPLE_LIST_FIELD, LIST_OF_ENUMS_FIELD, LIST_OF_MAPS_FIELD, LIST_OF_STRUCTS_FIELD, LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD, MAP_OF_STRING_TO_INTEGER_LIST_FIELD, MAP_OF_STRING_TO_STRING_FIELD, MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD, MAP_OF_ENUM_TO_ENUM_FIELD, MAP_OF_ENUM_TO_STRING_FIELD, MAP_OF_STRING_TO_ENUM_FIELD, MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD, MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD, MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD, TIMESTAMP_MEMBER_FIELD, STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD, BLOB_ARG_FIELD, STRUCT_WITH_NESTED_BLOB_FIELD, BLOB_MAP_FIELD, LIST_OF_BLOBS_FIELD, RECURSIVE_STRUCT_FIELD, POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD, POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD, ENUM_TYPE_FIELD)); private final String stringMember; private final Integer integerMember; private final Boolean booleanMember; private final Float floatMember; private final Double doubleMember; private final Long longMember; private final List<String> simpleList; private final List<String> listOfEnums; private final List<Map<String, String>> listOfMaps; private final List<SimpleStruct> listOfStructs; private final List<Map<String, String>> listOfMapOfEnumToString; private final Map<String, List<Integer>> mapOfStringToIntegerList; private final Map<String, String> mapOfStringToString; private final Map<String, SimpleStruct> mapOfStringToSimpleStruct; private final Map<String, String> mapOfEnumToEnum; private final Map<String, String> mapOfEnumToString; private final Map<String, String> mapOfStringToEnum; private final Map<String, SimpleStruct> mapOfEnumToSimpleStruct; private final Map<String, List<String>> mapOfEnumToListOfEnums; private final Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum; private final Instant timestampMember; private final StructWithTimestamp structWithNestedTimestampMember; private final SdkBytes blobArg; private final StructWithNestedBlobType structWithNestedBlob; private final Map<String, SdkBytes> blobMap; private final List<SdkBytes> listOfBlobs; private final RecursiveStructType recursiveStruct; private final BaseType polymorphicTypeWithSubTypes; private final SubTypeOne polymorphicTypeWithoutSubTypes; private final String enumType; private AllTypesResponse(BuilderImpl builder) { super(builder); this.stringMember = builder.stringMember; this.integerMember = builder.integerMember; this.booleanMember = builder.booleanMember; this.floatMember = builder.floatMember; this.doubleMember = builder.doubleMember; this.longMember = builder.longMember; this.simpleList = builder.simpleList; this.listOfEnums = builder.listOfEnums; this.listOfMaps = builder.listOfMaps; this.listOfStructs = builder.listOfStructs; this.listOfMapOfEnumToString = builder.listOfMapOfEnumToString; this.mapOfStringToIntegerList = builder.mapOfStringToIntegerList; this.mapOfStringToString = builder.mapOfStringToString; this.mapOfStringToSimpleStruct = builder.mapOfStringToSimpleStruct; this.mapOfEnumToEnum = builder.mapOfEnumToEnum; this.mapOfEnumToString = builder.mapOfEnumToString; this.mapOfStringToEnum = builder.mapOfStringToEnum; this.mapOfEnumToSimpleStruct = builder.mapOfEnumToSimpleStruct; this.mapOfEnumToListOfEnums = builder.mapOfEnumToListOfEnums; this.mapOfEnumToMapOfStringToEnum = builder.mapOfEnumToMapOfStringToEnum; this.timestampMember = builder.timestampMember; this.structWithNestedTimestampMember = builder.structWithNestedTimestampMember; this.blobArg = builder.blobArg; this.structWithNestedBlob = builder.structWithNestedBlob; this.blobMap = builder.blobMap; this.listOfBlobs = builder.listOfBlobs; this.recursiveStruct = builder.recursiveStruct; this.polymorphicTypeWithSubTypes = builder.polymorphicTypeWithSubTypes; this.polymorphicTypeWithoutSubTypes = builder.polymorphicTypeWithoutSubTypes; this.enumType = builder.enumType; } /** * Returns the value of the StringMember property for this object. * * @return The value of the StringMember property for this object. */ public final String stringMember() { return stringMember; } /** * Returns the value of the IntegerMember property for this object. * * @return The value of the IntegerMember property for this object. */ public final Integer integerMember() { return integerMember; } /** * Returns the value of the BooleanMember property for this object. * * @return The value of the BooleanMember property for this object. */ public final Boolean booleanMember() { return booleanMember; } /** * Returns the value of the FloatMember property for this object. * * @return The value of the FloatMember property for this object. */ public final Float floatMember() { return floatMember; } /** * Returns the value of the DoubleMember property for this object. * * @return The value of the DoubleMember property for this object. */ public final Double doubleMember() { return doubleMember; } /** * Returns the value of the LongMember property for this object. * * @return The value of the LongMember property for this object. */ public final Long longMember() { return longMember; } /** * Returns true if the SimpleList property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasSimpleList() { return simpleList != null && !(simpleList instanceof SdkAutoConstructList); } /** * Returns the value of the SimpleList property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasSimpleList()} to see if a value was sent in this field. * </p> * * @return The value of the SimpleList property for this object. */ public final List<String> simpleList() { return simpleList; } /** * Returns the value of the ListOfEnums property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfEnums()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfEnums property for this object. */ public final List<EnumType> listOfEnums() { return ListOfEnumsCopier.copyStringToEnum(listOfEnums); } /** * Returns true if the ListOfEnums property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasListOfEnums() { return listOfEnums != null && !(listOfEnums instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfEnums property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfEnums()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfEnums property for this object. */ public final List<String> listOfEnumsAsStrings() { return listOfEnums; } /** * Returns true if the ListOfMaps property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasListOfMaps() { return listOfMaps != null && !(listOfMaps instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfMaps property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfMaps()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfMaps property for this object. */ public final List<Map<String, String>> listOfMaps() { return listOfMaps; } /** * Returns true if the ListOfStructs property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasListOfStructs() { return listOfStructs != null && !(listOfStructs instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfStructs property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfStructs()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfStructs property for this object. */ public final List<SimpleStruct> listOfStructs() { return listOfStructs; } /** * Returns the value of the ListOfMapOfEnumToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfMapOfEnumToString()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfMapOfEnumToString property for this object. */ public final List<Map<EnumType, String>> listOfMapOfEnumToString() { return ListOfMapOfEnumToStringCopier.copyStringToEnum(listOfMapOfEnumToString); } /** * Returns true if the ListOfMapOfEnumToString property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasListOfMapOfEnumToString() { return listOfMapOfEnumToString != null && !(listOfMapOfEnumToString instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfMapOfEnumToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfMapOfEnumToString()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfMapOfEnumToString property for this object. */ public final List<Map<String, String>> listOfMapOfEnumToStringAsStrings() { return listOfMapOfEnumToString; } /** * Returns true if the MapOfStringToIntegerList property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfStringToIntegerList() { return mapOfStringToIntegerList != null && !(mapOfStringToIntegerList instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToIntegerList property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToIntegerList()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToIntegerList property for this object. */ public final Map<String, List<Integer>> mapOfStringToIntegerList() { return mapOfStringToIntegerList; } /** * Returns true if the MapOfStringToString property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfStringToString() { return mapOfStringToString != null && !(mapOfStringToString instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToString()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToString property for this object. */ public final Map<String, String> mapOfStringToString() { return mapOfStringToString; } /** * Returns true if the MapOfStringToSimpleStruct property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfStringToSimpleStruct() { return mapOfStringToSimpleStruct != null && !(mapOfStringToSimpleStruct instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToSimpleStruct property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToSimpleStruct()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToSimpleStruct property for this object. */ public final Map<String, SimpleStruct> mapOfStringToSimpleStruct() { return mapOfStringToSimpleStruct; } /** * Returns the value of the MapOfEnumToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToEnum property for this object. */ public final Map<EnumType, EnumType> mapOfEnumToEnum() { return MapOfEnumToEnumCopier.copyStringToEnum(mapOfEnumToEnum); } /** * Returns true if the MapOfEnumToEnum property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfEnumToEnum() { return mapOfEnumToEnum != null && !(mapOfEnumToEnum instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToEnum property for this object. */ public final Map<String, String> mapOfEnumToEnumAsStrings() { return mapOfEnumToEnum; } /** * Returns the value of the MapOfEnumToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToString()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToString property for this object. */ public final Map<EnumType, String> mapOfEnumToString() { return MapOfEnumToStringCopier.copyStringToEnum(mapOfEnumToString); } /** * Returns true if the MapOfEnumToString property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfEnumToString() { return mapOfEnumToString != null && !(mapOfEnumToString instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToString()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToString property for this object. */ public final Map<String, String> mapOfEnumToStringAsStrings() { return mapOfEnumToString; } /** * Returns the value of the MapOfStringToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToEnum property for this object. */ public final Map<String, EnumType> mapOfStringToEnum() { return MapOfStringToEnumCopier.copyStringToEnum(mapOfStringToEnum); } /** * Returns true if the MapOfStringToEnum property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfStringToEnum() { return mapOfStringToEnum != null && !(mapOfStringToEnum instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToEnum property for this object. */ public final Map<String, String> mapOfStringToEnumAsStrings() { return mapOfStringToEnum; } /** * Returns the value of the MapOfEnumToSimpleStruct property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToSimpleStruct()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToSimpleStruct property for this object. */ public final Map<EnumType, SimpleStruct> mapOfEnumToSimpleStruct() { return MapOfEnumToSimpleStructCopier.copyStringToEnum(mapOfEnumToSimpleStruct); } /** * Returns true if the MapOfEnumToSimpleStruct property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfEnumToSimpleStruct() { return mapOfEnumToSimpleStruct != null && !(mapOfEnumToSimpleStruct instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToSimpleStruct property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToSimpleStruct()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToSimpleStruct property for this object. */ public final Map<String, SimpleStruct> mapOfEnumToSimpleStructAsStrings() { return mapOfEnumToSimpleStruct; } /** * Returns the value of the MapOfEnumToListOfEnums property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToListOfEnums()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToListOfEnums property for this object. */ public final Map<EnumType, List<EnumType>> mapOfEnumToListOfEnums() { return MapOfEnumToListOfEnumsCopier.copyStringToEnum(mapOfEnumToListOfEnums); } /** * Returns true if the MapOfEnumToListOfEnums property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfEnumToListOfEnums() { return mapOfEnumToListOfEnums != null && !(mapOfEnumToListOfEnums instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToListOfEnums property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToListOfEnums()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToListOfEnums property for this object. */ public final Map<String, List<String>> mapOfEnumToListOfEnumsAsStrings() { return mapOfEnumToListOfEnums; } /** * Returns the value of the MapOfEnumToMapOfStringToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToMapOfStringToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToMapOfStringToEnum property for this object. */ public final Map<EnumType, Map<String, EnumType>> mapOfEnumToMapOfStringToEnum() { return MapOfEnumToMapOfStringToEnumCopier.copyStringToEnum(mapOfEnumToMapOfStringToEnum); } /** * Returns true if the MapOfEnumToMapOfStringToEnum property was specified by the sender (it may be empty), or false * if the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the * AWS service. */ public final boolean hasMapOfEnumToMapOfStringToEnum() { return mapOfEnumToMapOfStringToEnum != null && !(mapOfEnumToMapOfStringToEnum instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToMapOfStringToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToMapOfStringToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToMapOfStringToEnum property for this object. */ public final Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnumAsStrings() { return mapOfEnumToMapOfStringToEnum; } /** * Returns the value of the TimestampMember property for this object. * * @return The value of the TimestampMember property for this object. */ public final Instant timestampMember() { return timestampMember; } /** * Returns the value of the StructWithNestedTimestampMember property for this object. * * @return The value of the StructWithNestedTimestampMember property for this object. */ public final StructWithTimestamp structWithNestedTimestampMember() { return structWithNestedTimestampMember; } /** * Returns the value of the BlobArg property for this object. * * @return The value of the BlobArg property for this object. */ public final SdkBytes blobArg() { return blobArg; } /** * Returns the value of the StructWithNestedBlob property for this object. * * @return The value of the StructWithNestedBlob property for this object. */ public final StructWithNestedBlobType structWithNestedBlob() { return structWithNestedBlob; } /** * Returns true if the BlobMap property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasBlobMap() { return blobMap != null && !(blobMap instanceof SdkAutoConstructMap); } /** * Returns the value of the BlobMap property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasBlobMap()} to see if a value was sent in this field. * </p> * * @return The value of the BlobMap property for this object. */ public final Map<String, SdkBytes> blobMap() { return blobMap; } /** * Returns true if the ListOfBlobs property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasListOfBlobs() { return listOfBlobs != null && !(listOfBlobs instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfBlobs property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfBlobs()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfBlobs property for this object. */ public final List<SdkBytes> listOfBlobs() { return listOfBlobs; } /** * Returns the value of the RecursiveStruct property for this object. * * @return The value of the RecursiveStruct property for this object. */ public final RecursiveStructType recursiveStruct() { return recursiveStruct; } /** * Returns the value of the PolymorphicTypeWithSubTypes property for this object. * * @return The value of the PolymorphicTypeWithSubTypes property for this object. */ public final BaseType polymorphicTypeWithSubTypes() { return polymorphicTypeWithSubTypes; } /** * Returns the value of the PolymorphicTypeWithoutSubTypes property for this object. * * @return The value of the PolymorphicTypeWithoutSubTypes property for this object. */ public final SubTypeOne polymorphicTypeWithoutSubTypes() { return polymorphicTypeWithoutSubTypes; } /** * Returns the value of the EnumType property for this object. * <p> * If the service returns an enum value that is not available in the current SDK version, {@link #enumType} will * return {@link EnumType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #enumTypeAsString}. * </p> * * @return The value of the EnumType property for this object. * @see EnumType */ public final EnumType enumType() { return EnumType.fromValue(enumType); } /** * Returns the value of the EnumType property for this object. * <p> * If the service returns an enum value that is not available in the current SDK version, {@link #enumType} will * return {@link EnumType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #enumTypeAsString}. * </p> * * @return The value of the EnumType property for this object. * @see EnumType */ public final String enumTypeAsString() { return enumType; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(stringMember()); hashCode = 31 * hashCode + Objects.hashCode(integerMember()); hashCode = 31 * hashCode + Objects.hashCode(booleanMember()); hashCode = 31 * hashCode + Objects.hashCode(floatMember()); hashCode = 31 * hashCode + Objects.hashCode(doubleMember()); hashCode = 31 * hashCode + Objects.hashCode(longMember()); hashCode = 31 * hashCode + Objects.hashCode(simpleList()); hashCode = 31 * hashCode + Objects.hashCode(listOfEnumsAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(listOfMaps()); hashCode = 31 * hashCode + Objects.hashCode(listOfStructs()); hashCode = 31 * hashCode + Objects.hashCode(listOfMapOfEnumToStringAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToIntegerList()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToString()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToSimpleStruct()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToEnumAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToStringAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToEnumAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToSimpleStructAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToListOfEnumsAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToMapOfStringToEnumAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(timestampMember()); hashCode = 31 * hashCode + Objects.hashCode(structWithNestedTimestampMember()); hashCode = 31 * hashCode + Objects.hashCode(blobArg()); hashCode = 31 * hashCode + Objects.hashCode(structWithNestedBlob()); hashCode = 31 * hashCode + Objects.hashCode(blobMap()); hashCode = 31 * hashCode + Objects.hashCode(listOfBlobs()); hashCode = 31 * hashCode + Objects.hashCode(recursiveStruct()); hashCode = 31 * hashCode + Objects.hashCode(polymorphicTypeWithSubTypes()); hashCode = 31 * hashCode + Objects.hashCode(polymorphicTypeWithoutSubTypes()); hashCode = 31 * hashCode + Objects.hashCode(enumTypeAsString()); 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 AllTypesResponse)) { return false; } AllTypesResponse other = (AllTypesResponse) obj; return Objects.equals(stringMember(), other.stringMember()) && Objects.equals(integerMember(), other.integerMember()) && Objects.equals(booleanMember(), other.booleanMember()) && Objects.equals(floatMember(), other.floatMember()) && Objects.equals(doubleMember(), other.doubleMember()) && Objects.equals(longMember(), other.longMember()) && Objects.equals(simpleList(), other.simpleList()) && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) && Objects.equals(listOfMaps(), other.listOfMaps()) && Objects.equals(listOfStructs(), other.listOfStructs()) && Objects.equals(listOfMapOfEnumToStringAsStrings(), other.listOfMapOfEnumToStringAsStrings()) && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) && Objects.equals(mapOfEnumToListOfEnumsAsStrings(), other.mapOfEnumToListOfEnumsAsStrings()) && Objects.equals(mapOfEnumToMapOfStringToEnumAsStrings(), other.mapOfEnumToMapOfStringToEnumAsStrings()) && Objects.equals(timestampMember(), other.timestampMember()) && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) && Objects.equals(blobArg(), other.blobArg()) && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) && Objects.equals(blobMap(), other.blobMap()) && Objects.equals(listOfBlobs(), other.listOfBlobs()) && Objects.equals(recursiveStruct(), other.recursiveStruct()) && Objects.equals(polymorphicTypeWithSubTypes(), other.polymorphicTypeWithSubTypes()) && Objects.equals(polymorphicTypeWithoutSubTypes(), other.polymorphicTypeWithoutSubTypes()) && Objects.equals(enumTypeAsString(), other.enumTypeAsString()); } /** * 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("AllTypesResponse").add("StringMember", stringMember()).add("IntegerMember", integerMember()) .add("BooleanMember", booleanMember()).add("FloatMember", floatMember()).add("DoubleMember", doubleMember()) .add("LongMember", longMember()).add("SimpleList", simpleList()).add("ListOfEnums", listOfEnumsAsStrings()) .add("ListOfMaps", listOfMaps()).add("ListOfStructs", listOfStructs()) .add("ListOfMapOfEnumToString", listOfMapOfEnumToStringAsStrings()) .add("MapOfStringToIntegerList", mapOfStringToIntegerList()).add("MapOfStringToString", mapOfStringToString()) .add("MapOfStringToSimpleStruct", mapOfStringToSimpleStruct()).add("MapOfEnumToEnum", mapOfEnumToEnumAsStrings()) .add("MapOfEnumToString", mapOfEnumToStringAsStrings()).add("MapOfStringToEnum", mapOfStringToEnumAsStrings()) .add("MapOfEnumToSimpleStruct", mapOfEnumToSimpleStructAsStrings()) .add("MapOfEnumToListOfEnums", mapOfEnumToListOfEnumsAsStrings()) .add("MapOfEnumToMapOfStringToEnum", mapOfEnumToMapOfStringToEnumAsStrings()) .add("TimestampMember", timestampMember()) .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", blobMap()).add("ListOfBlobs", listOfBlobs()) .add("RecursiveStruct", recursiveStruct()).add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) .build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "StringMember": return Optional.ofNullable(clazz.cast(stringMember())); case "IntegerMember": return Optional.ofNullable(clazz.cast(integerMember())); case "BooleanMember": return Optional.ofNullable(clazz.cast(booleanMember())); case "FloatMember": return Optional.ofNullable(clazz.cast(floatMember())); case "DoubleMember": return Optional.ofNullable(clazz.cast(doubleMember())); case "LongMember": return Optional.ofNullable(clazz.cast(longMember())); case "SimpleList": return Optional.ofNullable(clazz.cast(simpleList())); case "ListOfEnums": return Optional.ofNullable(clazz.cast(listOfEnumsAsStrings())); case "ListOfMaps": return Optional.ofNullable(clazz.cast(listOfMaps())); case "ListOfStructs": return Optional.ofNullable(clazz.cast(listOfStructs())); case "ListOfMapOfEnumToString": return Optional.ofNullable(clazz.cast(listOfMapOfEnumToStringAsStrings())); case "MapOfStringToIntegerList": return Optional.ofNullable(clazz.cast(mapOfStringToIntegerList())); case "MapOfStringToString": return Optional.ofNullable(clazz.cast(mapOfStringToString())); case "MapOfStringToSimpleStruct": return Optional.ofNullable(clazz.cast(mapOfStringToSimpleStruct())); case "MapOfEnumToEnum": return Optional.ofNullable(clazz.cast(mapOfEnumToEnumAsStrings())); case "MapOfEnumToString": return Optional.ofNullable(clazz.cast(mapOfEnumToStringAsStrings())); case "MapOfStringToEnum": return Optional.ofNullable(clazz.cast(mapOfStringToEnumAsStrings())); case "MapOfEnumToSimpleStruct": return Optional.ofNullable(clazz.cast(mapOfEnumToSimpleStructAsStrings())); case "MapOfEnumToListOfEnums": return Optional.ofNullable(clazz.cast(mapOfEnumToListOfEnumsAsStrings())); case "MapOfEnumToMapOfStringToEnum": return Optional.ofNullable(clazz.cast(mapOfEnumToMapOfStringToEnumAsStrings())); case "TimestampMember": return Optional.ofNullable(clazz.cast(timestampMember())); case "StructWithNestedTimestampMember": return Optional.ofNullable(clazz.cast(structWithNestedTimestampMember())); case "BlobArg": return Optional.ofNullable(clazz.cast(blobArg())); case "StructWithNestedBlob": return Optional.ofNullable(clazz.cast(structWithNestedBlob())); case "BlobMap": return Optional.ofNullable(clazz.cast(blobMap())); case "ListOfBlobs": return Optional.ofNullable(clazz.cast(listOfBlobs())); case "RecursiveStruct": return Optional.ofNullable(clazz.cast(recursiveStruct())); case "PolymorphicTypeWithSubTypes": return Optional.ofNullable(clazz.cast(polymorphicTypeWithSubTypes())); case "PolymorphicTypeWithoutSubTypes": return Optional.ofNullable(clazz.cast(polymorphicTypeWithoutSubTypes())); case "EnumType": return Optional.ofNullable(clazz.cast(enumTypeAsString())); default: return Optional.empty(); } } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } private static <T> Function<Object, T> getter(Function<AllTypesResponse, T> g) { return obj -> g.apply((AllTypesResponse) obj); } private static <T> BiConsumer<Object, T> setter(BiConsumer<Builder, T> s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends JsonProtocolTestsResponse.Builder, SdkPojo, CopyableBuilder<Builder, AllTypesResponse> { /** * Sets the value of the StringMember property for this object. * * @param stringMember * The new value for the StringMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder stringMember(String stringMember); /** * Sets the value of the IntegerMember property for this object. * * @param integerMember * The new value for the IntegerMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder integerMember(Integer integerMember); /** * Sets the value of the BooleanMember property for this object. * * @param booleanMember * The new value for the BooleanMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder booleanMember(Boolean booleanMember); /** * Sets the value of the FloatMember property for this object. * * @param floatMember * The new value for the FloatMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder floatMember(Float floatMember); /** * Sets the value of the DoubleMember property for this object. * * @param doubleMember * The new value for the DoubleMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder doubleMember(Double doubleMember); /** * Sets the value of the LongMember property for this object. * * @param longMember * The new value for the LongMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder longMember(Long longMember); /** * Sets the value of the SimpleList property for this object. * * @param simpleList * The new value for the SimpleList property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder simpleList(Collection<String> simpleList); /** * Sets the value of the SimpleList property for this object. * * @param simpleList * The new value for the SimpleList property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder simpleList(String... simpleList); /** * Sets the value of the ListOfEnums property for this object. * * @param listOfEnums * The new value for the ListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfEnumsWithStrings(Collection<String> listOfEnums); /** * Sets the value of the ListOfEnums property for this object. * * @param listOfEnums * The new value for the ListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfEnumsWithStrings(String... listOfEnums); /** * Sets the value of the ListOfEnums property for this object. * * @param listOfEnums * The new value for the ListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfEnums(Collection<EnumType> listOfEnums); /** * Sets the value of the ListOfEnums property for this object. * * @param listOfEnums * The new value for the ListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfEnums(EnumType... listOfEnums); /** * Sets the value of the ListOfMaps property for this object. * * @param listOfMaps * The new value for the ListOfMaps property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps); /** * Sets the value of the ListOfMaps property for this object. * * @param listOfMaps * The new value for the ListOfMaps property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfMaps(Map<String, String>... listOfMaps); /** * Sets the value of the ListOfStructs property for this object. * * @param listOfStructs * The new value for the ListOfStructs property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfStructs(Collection<SimpleStruct> listOfStructs); /** * Sets the value of the ListOfStructs property for this object. * * @param listOfStructs * The new value for the ListOfStructs property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfStructs(SimpleStruct... listOfStructs); /** * Sets the value of the ListOfStructs property for this object. * * This is a convenience that creates an instance of the {@link List<SimpleStruct>.Builder} avoiding the need to * create one manually via {@link List<SimpleStruct>#builder()}. * * When the {@link Consumer} completes, {@link List<SimpleStruct>.Builder#build()} is called immediately and its * result is passed to {@link #listOfStructs(List<SimpleStruct>)}. * * @param listOfStructs * a consumer that will call methods on {@link List<SimpleStruct>.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #listOfStructs(List<SimpleStruct>) */ Builder listOfStructs(Consumer<SimpleStruct.Builder>... listOfStructs); /** * Sets the value of the ListOfMapOfEnumToString property for this object. * * @param listOfMapOfEnumToString * The new value for the ListOfMapOfEnumToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfMapOfEnumToStringWithStrings(Collection<? extends Map<String, String>> listOfMapOfEnumToString); /** * Sets the value of the ListOfMapOfEnumToString property for this object. * * @param listOfMapOfEnumToString * The new value for the ListOfMapOfEnumToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfMapOfEnumToStringWithStrings(Map<String, String>... listOfMapOfEnumToString); /** * Sets the value of the MapOfStringToIntegerList property for this object. * * @param mapOfStringToIntegerList * The new value for the MapOfStringToIntegerList property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToIntegerList(Map<String, ? extends Collection<Integer>> mapOfStringToIntegerList); /** * Sets the value of the MapOfStringToString property for this object. * * @param mapOfStringToString * The new value for the MapOfStringToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToString(Map<String, String> mapOfStringToString); /** * Sets the value of the MapOfStringToSimpleStruct property for this object. * * @param mapOfStringToSimpleStruct * The new value for the MapOfStringToSimpleStruct property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToSimpleStruct(Map<String, SimpleStruct> mapOfStringToSimpleStruct); /** * Sets the value of the MapOfEnumToEnum property for this object. * * @param mapOfEnumToEnum * The new value for the MapOfEnumToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToEnumWithStrings(Map<String, String> mapOfEnumToEnum); /** * Sets the value of the MapOfEnumToEnum property for this object. * * @param mapOfEnumToEnum * The new value for the MapOfEnumToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToEnum(Map<EnumType, EnumType> mapOfEnumToEnum); /** * Sets the value of the MapOfEnumToString property for this object. * * @param mapOfEnumToString * The new value for the MapOfEnumToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToStringWithStrings(Map<String, String> mapOfEnumToString); /** * Sets the value of the MapOfEnumToString property for this object. * * @param mapOfEnumToString * The new value for the MapOfEnumToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToString(Map<EnumType, String> mapOfEnumToString); /** * Sets the value of the MapOfStringToEnum property for this object. * * @param mapOfStringToEnum * The new value for the MapOfStringToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToEnumWithStrings(Map<String, String> mapOfStringToEnum); /** * Sets the value of the MapOfStringToEnum property for this object. * * @param mapOfStringToEnum * The new value for the MapOfStringToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToEnum(Map<String, EnumType> mapOfStringToEnum); /** * Sets the value of the MapOfEnumToSimpleStruct property for this object. * * @param mapOfEnumToSimpleStruct * The new value for the MapOfEnumToSimpleStruct property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToSimpleStructWithStrings(Map<String, SimpleStruct> mapOfEnumToSimpleStruct); /** * Sets the value of the MapOfEnumToSimpleStruct property for this object. * * @param mapOfEnumToSimpleStruct * The new value for the MapOfEnumToSimpleStruct property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToSimpleStruct(Map<EnumType, SimpleStruct> mapOfEnumToSimpleStruct); /** * Sets the value of the MapOfEnumToListOfEnums property for this object. * * @param mapOfEnumToListOfEnums * The new value for the MapOfEnumToListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToListOfEnumsWithStrings(Map<String, ? extends Collection<String>> mapOfEnumToListOfEnums); /** * Sets the value of the MapOfEnumToListOfEnums property for this object. * * @param mapOfEnumToListOfEnums * The new value for the MapOfEnumToListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToListOfEnums(Map<EnumType, ? extends Collection<EnumType>> mapOfEnumToListOfEnums); /** * Sets the value of the MapOfEnumToMapOfStringToEnum property for this object. * * @param mapOfEnumToMapOfStringToEnum * The new value for the MapOfEnumToMapOfStringToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToMapOfStringToEnumWithStrings(Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum); /** * Sets the value of the MapOfEnumToMapOfStringToEnum property for this object. * * @param mapOfEnumToMapOfStringToEnum * The new value for the MapOfEnumToMapOfStringToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToMapOfStringToEnum(Map<EnumType, Map<String, EnumType>> mapOfEnumToMapOfStringToEnum); /** * Sets the value of the TimestampMember property for this object. * * @param timestampMember * The new value for the TimestampMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder timestampMember(Instant timestampMember); /** * Sets the value of the StructWithNestedTimestampMember property for this object. * * @param structWithNestedTimestampMember * The new value for the StructWithNestedTimestampMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder structWithNestedTimestampMember(StructWithTimestamp structWithNestedTimestampMember); /** * Sets the value of the StructWithNestedTimestampMember property for this object. * * This is a convenience that creates an instance of the {@link StructWithTimestamp.Builder} avoiding the need * to create one manually via {@link StructWithTimestamp#builder()}. * * When the {@link Consumer} completes, {@link StructWithTimestamp.Builder#build()} is called immediately and * its result is passed to {@link #structWithNestedTimestampMember(StructWithTimestamp)}. * * @param structWithNestedTimestampMember * a consumer that will call methods on {@link StructWithTimestamp.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #structWithNestedTimestampMember(StructWithTimestamp) */ default Builder structWithNestedTimestampMember(Consumer<StructWithTimestamp.Builder> structWithNestedTimestampMember) { return structWithNestedTimestampMember(StructWithTimestamp.builder().applyMutation(structWithNestedTimestampMember) .build()); } /** * Sets the value of the BlobArg property for this object. * * @param blobArg * The new value for the BlobArg property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder blobArg(SdkBytes blobArg); /** * Sets the value of the StructWithNestedBlob property for this object. * * @param structWithNestedBlob * The new value for the StructWithNestedBlob property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder structWithNestedBlob(StructWithNestedBlobType structWithNestedBlob); /** * Sets the value of the StructWithNestedBlob property for this object. * * This is a convenience that creates an instance of the {@link StructWithNestedBlobType.Builder} avoiding the * need to create one manually via {@link StructWithNestedBlobType#builder()}. * * When the {@link Consumer} completes, {@link StructWithNestedBlobType.Builder#build()} is called immediately * and its result is passed to {@link #structWithNestedBlob(StructWithNestedBlobType)}. * * @param structWithNestedBlob * a consumer that will call methods on {@link StructWithNestedBlobType.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #structWithNestedBlob(StructWithNestedBlobType) */ default Builder structWithNestedBlob(Consumer<StructWithNestedBlobType.Builder> structWithNestedBlob) { return structWithNestedBlob(StructWithNestedBlobType.builder().applyMutation(structWithNestedBlob).build()); } /** * Sets the value of the BlobMap property for this object. * * @param blobMap * The new value for the BlobMap property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder blobMap(Map<String, SdkBytes> blobMap); /** * Sets the value of the ListOfBlobs property for this object. * * @param listOfBlobs * The new value for the ListOfBlobs property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfBlobs(Collection<SdkBytes> listOfBlobs); /** * Sets the value of the ListOfBlobs property for this object. * * @param listOfBlobs * The new value for the ListOfBlobs property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfBlobs(SdkBytes... listOfBlobs); /** * Sets the value of the RecursiveStruct property for this object. * * @param recursiveStruct * The new value for the RecursiveStruct property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder recursiveStruct(RecursiveStructType recursiveStruct); /** * Sets the value of the RecursiveStruct property for this object. * * This is a convenience that creates an instance of the {@link RecursiveStructType.Builder} avoiding the need * to create one manually via {@link RecursiveStructType#builder()}. * * When the {@link Consumer} completes, {@link RecursiveStructType.Builder#build()} is called immediately and * its result is passed to {@link #recursiveStruct(RecursiveStructType)}. * * @param recursiveStruct * a consumer that will call methods on {@link RecursiveStructType.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #recursiveStruct(RecursiveStructType) */ default Builder recursiveStruct(Consumer<RecursiveStructType.Builder> recursiveStruct) { return recursiveStruct(RecursiveStructType.builder().applyMutation(recursiveStruct).build()); } /** * Sets the value of the PolymorphicTypeWithSubTypes property for this object. * * @param polymorphicTypeWithSubTypes * The new value for the PolymorphicTypeWithSubTypes property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder polymorphicTypeWithSubTypes(BaseType polymorphicTypeWithSubTypes); /** * Sets the value of the PolymorphicTypeWithSubTypes property for this object. * * This is a convenience that creates an instance of the {@link BaseType.Builder} avoiding the need to create * one manually via {@link BaseType#builder()}. * * When the {@link Consumer} completes, {@link BaseType.Builder#build()} is called immediately and its result is * passed to {@link #polymorphicTypeWithSubTypes(BaseType)}. * * @param polymorphicTypeWithSubTypes * a consumer that will call methods on {@link BaseType.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #polymorphicTypeWithSubTypes(BaseType) */ default Builder polymorphicTypeWithSubTypes(Consumer<BaseType.Builder> polymorphicTypeWithSubTypes) { return polymorphicTypeWithSubTypes(BaseType.builder().applyMutation(polymorphicTypeWithSubTypes).build()); } /** * Sets the value of the PolymorphicTypeWithoutSubTypes property for this object. * * @param polymorphicTypeWithoutSubTypes * The new value for the PolymorphicTypeWithoutSubTypes property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWithoutSubTypes); /** * Sets the value of the PolymorphicTypeWithoutSubTypes property for this object. * * This is a convenience that creates an instance of the {@link SubTypeOne.Builder} avoiding the need to create * one manually via {@link SubTypeOne#builder()}. * * When the {@link Consumer} completes, {@link SubTypeOne.Builder#build()} is called immediately and its result * is passed to {@link #polymorphicTypeWithoutSubTypes(SubTypeOne)}. * * @param polymorphicTypeWithoutSubTypes * a consumer that will call methods on {@link SubTypeOne.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #polymorphicTypeWithoutSubTypes(SubTypeOne) */ default Builder polymorphicTypeWithoutSubTypes(Consumer<SubTypeOne.Builder> polymorphicTypeWithoutSubTypes) { return polymorphicTypeWithoutSubTypes(SubTypeOne.builder().applyMutation(polymorphicTypeWithoutSubTypes).build()); } /** * Sets the value of the EnumType property for this object. * * @param enumType * The new value for the EnumType property for this object. * @see EnumType * @return Returns a reference to this object so that method calls can be chained together. * @see EnumType */ Builder enumType(String enumType); /** * Sets the value of the EnumType property for this object. * * @param enumType * The new value for the EnumType property for this object. * @see EnumType * @return Returns a reference to this object so that method calls can be chained together. * @see EnumType */ Builder enumType(EnumType enumType); } static final class BuilderImpl extends JsonProtocolTestsResponse.BuilderImpl implements Builder { private String stringMember; private Integer integerMember; private Boolean booleanMember; private Float floatMember; private Double doubleMember; private Long longMember; private List<String> simpleList; private List<String> listOfEnums; private List<Map<String, String>> listOfMaps; private List<SimpleStruct> listOfStructs; private List<Map<String, String>> listOfMapOfEnumToString; private Map<String, List<Integer>> mapOfStringToIntegerList; private Map<String, String> mapOfStringToString; private Map<String, SimpleStruct> mapOfStringToSimpleStruct; private Map<String, String> mapOfEnumToEnum; private Map<String, String> mapOfEnumToString; private Map<String, String> mapOfStringToEnum; private Map<String, SimpleStruct> mapOfEnumToSimpleStruct; private Map<String, List<String>> mapOfEnumToListOfEnums; private Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum; private Instant timestampMember; private StructWithTimestamp structWithNestedTimestampMember; private SdkBytes blobArg; private StructWithNestedBlobType structWithNestedBlob; private Map<String, SdkBytes> blobMap; private List<SdkBytes> listOfBlobs; private RecursiveStructType recursiveStruct; private BaseType polymorphicTypeWithSubTypes; private SubTypeOne polymorphicTypeWithoutSubTypes; private String enumType; private BuilderImpl() { } private BuilderImpl(AllTypesResponse model) { super(model); stringMember(model.stringMember); integerMember(model.integerMember); booleanMember(model.booleanMember); floatMember(model.floatMember); doubleMember(model.doubleMember); longMember(model.longMember); simpleList(model.simpleList); listOfEnumsWithStrings(model.listOfEnums); listOfMaps(model.listOfMaps); listOfStructs(model.listOfStructs); listOfMapOfEnumToStringWithStrings(model.listOfMapOfEnumToString); mapOfStringToIntegerList(model.mapOfStringToIntegerList); mapOfStringToString(model.mapOfStringToString); mapOfStringToSimpleStruct(model.mapOfStringToSimpleStruct); mapOfEnumToEnumWithStrings(model.mapOfEnumToEnum); mapOfEnumToStringWithStrings(model.mapOfEnumToString); mapOfStringToEnumWithStrings(model.mapOfStringToEnum); mapOfEnumToSimpleStructWithStrings(model.mapOfEnumToSimpleStruct); mapOfEnumToListOfEnumsWithStrings(model.mapOfEnumToListOfEnums); mapOfEnumToMapOfStringToEnumWithStrings(model.mapOfEnumToMapOfStringToEnum); timestampMember(model.timestampMember); structWithNestedTimestampMember(model.structWithNestedTimestampMember); blobArg(model.blobArg); structWithNestedBlob(model.structWithNestedBlob); blobMap(model.blobMap); listOfBlobs(model.listOfBlobs); recursiveStruct(model.recursiveStruct); polymorphicTypeWithSubTypes(model.polymorphicTypeWithSubTypes); polymorphicTypeWithoutSubTypes(model.polymorphicTypeWithoutSubTypes); enumType(model.enumType); } public final String getStringMember() { return stringMember; } @Override public final Builder stringMember(String stringMember) { this.stringMember = stringMember; return this; } public final void setStringMember(String stringMember) { this.stringMember = stringMember; } public final Integer getIntegerMember() { return integerMember; } @Override public final Builder integerMember(Integer integerMember) { this.integerMember = integerMember; return this; } public final void setIntegerMember(Integer integerMember) { this.integerMember = integerMember; } public final Boolean getBooleanMember() { return booleanMember; } @Override public final Builder booleanMember(Boolean booleanMember) { this.booleanMember = booleanMember; return this; } public final void setBooleanMember(Boolean booleanMember) { this.booleanMember = booleanMember; } public final Float getFloatMember() { return floatMember; } @Override public final Builder floatMember(Float floatMember) { this.floatMember = floatMember; return this; } public final void setFloatMember(Float floatMember) { this.floatMember = floatMember; } public final Double getDoubleMember() { return doubleMember; } @Override public final Builder doubleMember(Double doubleMember) { this.doubleMember = doubleMember; return this; } public final void setDoubleMember(Double doubleMember) { this.doubleMember = doubleMember; } public final Long getLongMember() { return longMember; } @Override public final Builder longMember(Long longMember) { this.longMember = longMember; return this; } public final void setLongMember(Long longMember) { this.longMember = longMember; } public final Collection<String> getSimpleList() { return simpleList; } @Override public final Builder simpleList(Collection<String> simpleList) { this.simpleList = ListOfStringsCopier.copy(simpleList); return this; } @Override @SafeVarargs public final Builder simpleList(String... simpleList) { simpleList(Arrays.asList(simpleList)); return this; } public final void setSimpleList(Collection<String> simpleList) { this.simpleList = ListOfStringsCopier.copy(simpleList); } public final Collection<String> getListOfEnums() { return listOfEnums; } @Override public final Builder listOfEnumsWithStrings(Collection<String> listOfEnums) { this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums); return this; } @Override @SafeVarargs public final Builder listOfEnumsWithStrings(String... listOfEnums) { listOfEnumsWithStrings(Arrays.asList(listOfEnums)); return this; } @Override public final Builder listOfEnums(Collection<EnumType> listOfEnums) { this.listOfEnums = ListOfEnumsCopier.copyEnumToString(listOfEnums); return this; } @Override @SafeVarargs public final Builder listOfEnums(EnumType... listOfEnums) { listOfEnums(Arrays.asList(listOfEnums)); return this; } public final void setListOfEnums(Collection<String> listOfEnums) { this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums); } public final Collection<? extends Map<String, String>> getListOfMaps() { return listOfMaps; } @Override public final Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps) { this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps); return this; } @Override @SafeVarargs public final Builder listOfMaps(Map<String, String>... listOfMaps) { listOfMaps(Arrays.asList(listOfMaps)); return this; } public final void setListOfMaps(Collection<? extends Map<String, String>> listOfMaps) { this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps); } public final Collection<SimpleStruct.Builder> getListOfStructs() { return listOfStructs != null ? listOfStructs.stream().map(SimpleStruct::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder listOfStructs(Collection<SimpleStruct> listOfStructs) { this.listOfStructs = ListOfSimpleStructsCopier.copy(listOfStructs); return this; } @Override @SafeVarargs public final Builder listOfStructs(SimpleStruct... listOfStructs) { listOfStructs(Arrays.asList(listOfStructs)); return this; } @Override @SafeVarargs public final Builder listOfStructs(Consumer<SimpleStruct.Builder>... listOfStructs) { listOfStructs(Stream.of(listOfStructs).map(c -> SimpleStruct.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setListOfStructs(Collection<SimpleStruct.BuilderImpl> listOfStructs) { this.listOfStructs = ListOfSimpleStructsCopier.copyFromBuilder(listOfStructs); } public final Collection<? extends Map<String, String>> getListOfMapOfEnumToString() { return listOfMapOfEnumToString; } @Override public final Builder listOfMapOfEnumToStringWithStrings(Collection<? extends Map<String, String>> listOfMapOfEnumToString) { this.listOfMapOfEnumToString = ListOfMapOfEnumToStringCopier.copy(listOfMapOfEnumToString); return this; } @Override @SafeVarargs public final Builder listOfMapOfEnumToStringWithStrings(Map<String, String>... listOfMapOfEnumToString) { listOfMapOfEnumToStringWithStrings(Arrays.asList(listOfMapOfEnumToString)); return this; } public final void setListOfMapOfEnumToString(Collection<? extends Map<String, String>> listOfMapOfEnumToString) { this.listOfMapOfEnumToString = ListOfMapOfEnumToStringCopier.copy(listOfMapOfEnumToString); } public final Map<String, ? extends Collection<Integer>> getMapOfStringToIntegerList() { return mapOfStringToIntegerList; } @Override public final Builder mapOfStringToIntegerList(Map<String, ? extends Collection<Integer>> mapOfStringToIntegerList) { this.mapOfStringToIntegerList = MapOfStringToIntegerListCopier.copy(mapOfStringToIntegerList); return this; } public final void setMapOfStringToIntegerList(Map<String, ? extends Collection<Integer>> mapOfStringToIntegerList) { this.mapOfStringToIntegerList = MapOfStringToIntegerListCopier.copy(mapOfStringToIntegerList); } public final Map<String, String> getMapOfStringToString() { return mapOfStringToString; } @Override public final Builder mapOfStringToString(Map<String, String> mapOfStringToString) { this.mapOfStringToString = MapOfStringToStringCopier.copy(mapOfStringToString); return this; } public final void setMapOfStringToString(Map<String, String> mapOfStringToString) { this.mapOfStringToString = MapOfStringToStringCopier.copy(mapOfStringToString); } public final Map<String, SimpleStruct.Builder> getMapOfStringToSimpleStruct() { return mapOfStringToSimpleStruct != null ? CollectionUtils.mapValues(mapOfStringToSimpleStruct, SimpleStruct::toBuilder) : null; } @Override public final Builder mapOfStringToSimpleStruct(Map<String, SimpleStruct> mapOfStringToSimpleStruct) { this.mapOfStringToSimpleStruct = MapOfStringToSimpleStructCopier.copy(mapOfStringToSimpleStruct); return this; } public final void setMapOfStringToSimpleStruct(Map<String, SimpleStruct.BuilderImpl> mapOfStringToSimpleStruct) { this.mapOfStringToSimpleStruct = MapOfStringToSimpleStructCopier.copyFromBuilder(mapOfStringToSimpleStruct); } public final Map<String, String> getMapOfEnumToEnum() { return mapOfEnumToEnum; } @Override public final Builder mapOfEnumToEnumWithStrings(Map<String, String> mapOfEnumToEnum) { this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copy(mapOfEnumToEnum); return this; } @Override public final Builder mapOfEnumToEnum(Map<EnumType, EnumType> mapOfEnumToEnum) { this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copyEnumToString(mapOfEnumToEnum); return this; } public final void setMapOfEnumToEnum(Map<String, String> mapOfEnumToEnum) { this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copy(mapOfEnumToEnum); } public final Map<String, String> getMapOfEnumToString() { return mapOfEnumToString; } @Override public final Builder mapOfEnumToStringWithStrings(Map<String, String> mapOfEnumToString) { this.mapOfEnumToString = MapOfEnumToStringCopier.copy(mapOfEnumToString); return this; } @Override public final Builder mapOfEnumToString(Map<EnumType, String> mapOfEnumToString) { this.mapOfEnumToString = MapOfEnumToStringCopier.copyEnumToString(mapOfEnumToString); return this; } public final void setMapOfEnumToString(Map<String, String> mapOfEnumToString) { this.mapOfEnumToString = MapOfEnumToStringCopier.copy(mapOfEnumToString); } public final Map<String, String> getMapOfStringToEnum() { return mapOfStringToEnum; } @Override public final Builder mapOfStringToEnumWithStrings(Map<String, String> mapOfStringToEnum) { this.mapOfStringToEnum = MapOfStringToEnumCopier.copy(mapOfStringToEnum); return this; } @Override public final Builder mapOfStringToEnum(Map<String, EnumType> mapOfStringToEnum) { this.mapOfStringToEnum = MapOfStringToEnumCopier.copyEnumToString(mapOfStringToEnum); return this; } public final void setMapOfStringToEnum(Map<String, String> mapOfStringToEnum) { this.mapOfStringToEnum = MapOfStringToEnumCopier.copy(mapOfStringToEnum); } public final Map<String, SimpleStruct.Builder> getMapOfEnumToSimpleStruct() { return mapOfEnumToSimpleStruct != null ? CollectionUtils.mapValues(mapOfEnumToSimpleStruct, SimpleStruct::toBuilder) : null; } @Override public final Builder mapOfEnumToSimpleStructWithStrings(Map<String, SimpleStruct> mapOfEnumToSimpleStruct) { this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copy(mapOfEnumToSimpleStruct); return this; } @Override public final Builder mapOfEnumToSimpleStruct(Map<EnumType, SimpleStruct> mapOfEnumToSimpleStruct) { this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copyEnumToString(mapOfEnumToSimpleStruct); return this; } public final void setMapOfEnumToSimpleStruct(Map<String, SimpleStruct.BuilderImpl> mapOfEnumToSimpleStruct) { this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copyFromBuilder(mapOfEnumToSimpleStruct); } public final Map<String, ? extends Collection<String>> getMapOfEnumToListOfEnums() { return mapOfEnumToListOfEnums; } @Override public final Builder mapOfEnumToListOfEnumsWithStrings(Map<String, ? extends Collection<String>> mapOfEnumToListOfEnums) { this.mapOfEnumToListOfEnums = MapOfEnumToListOfEnumsCopier.copy(mapOfEnumToListOfEnums); return this; } @Override public final Builder mapOfEnumToListOfEnums(Map<EnumType, ? extends Collection<EnumType>> mapOfEnumToListOfEnums) { this.mapOfEnumToListOfEnums = MapOfEnumToListOfEnumsCopier.copyEnumToString(mapOfEnumToListOfEnums); return this; } public final void setMapOfEnumToListOfEnums(Map<String, ? extends Collection<String>> mapOfEnumToListOfEnums) { this.mapOfEnumToListOfEnums = MapOfEnumToListOfEnumsCopier.copy(mapOfEnumToListOfEnums); } public final Map<String, Map<String, String>> getMapOfEnumToMapOfStringToEnum() { return mapOfEnumToMapOfStringToEnum; } @Override public final Builder mapOfEnumToMapOfStringToEnumWithStrings(Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum) { this.mapOfEnumToMapOfStringToEnum = MapOfEnumToMapOfStringToEnumCopier.copy(mapOfEnumToMapOfStringToEnum); return this; } @Override public final Builder mapOfEnumToMapOfStringToEnum(Map<EnumType, Map<String, EnumType>> mapOfEnumToMapOfStringToEnum) { this.mapOfEnumToMapOfStringToEnum = MapOfEnumToMapOfStringToEnumCopier.copyEnumToString(mapOfEnumToMapOfStringToEnum); return this; } public final void setMapOfEnumToMapOfStringToEnum(Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum) { this.mapOfEnumToMapOfStringToEnum = MapOfEnumToMapOfStringToEnumCopier.copy(mapOfEnumToMapOfStringToEnum); } public final Instant getTimestampMember() { return timestampMember; } @Override public final Builder timestampMember(Instant timestampMember) { this.timestampMember = timestampMember; return this; } public final void setTimestampMember(Instant timestampMember) { this.timestampMember = timestampMember; } public final StructWithTimestamp.Builder getStructWithNestedTimestampMember() { return structWithNestedTimestampMember != null ? structWithNestedTimestampMember.toBuilder() : null; } @Override public final Builder structWithNestedTimestampMember(StructWithTimestamp structWithNestedTimestampMember) { this.structWithNestedTimestampMember = structWithNestedTimestampMember; return this; } public final void setStructWithNestedTimestampMember(StructWithTimestamp.BuilderImpl structWithNestedTimestampMember) { this.structWithNestedTimestampMember = structWithNestedTimestampMember != null ? structWithNestedTimestampMember .build() : null; } public final ByteBuffer getBlobArg() { return blobArg == null ? null : blobArg.asByteBuffer(); } @Override public final Builder blobArg(SdkBytes blobArg) { this.blobArg = StandardMemberCopier.copy(blobArg); return this; } public final void setBlobArg(ByteBuffer blobArg) { blobArg(blobArg == null ? null : SdkBytes.fromByteBuffer(blobArg)); } public final StructWithNestedBlobType.Builder getStructWithNestedBlob() { return structWithNestedBlob != null ? structWithNestedBlob.toBuilder() : null; } @Override public final Builder structWithNestedBlob(StructWithNestedBlobType structWithNestedBlob) { this.structWithNestedBlob = structWithNestedBlob; return this; } public final void setStructWithNestedBlob(StructWithNestedBlobType.BuilderImpl structWithNestedBlob) { this.structWithNestedBlob = structWithNestedBlob != null ? structWithNestedBlob.build() : null; } public final Map<String, ByteBuffer> getBlobMap() { return blobMap == null ? null : blobMap.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().asByteBuffer())); } @Override public final Builder blobMap(Map<String, SdkBytes> blobMap) { this.blobMap = BlobMapTypeCopier.copy(blobMap); return this; } public final void setBlobMap(Map<String, ByteBuffer> blobMap) { blobMap(blobMap == null ? null : blobMap.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> SdkBytes.fromByteBuffer(e.getValue())))); } public final List<ByteBuffer> getListOfBlobs() { return listOfBlobs == null ? null : listOfBlobs.stream().map(SdkBytes::asByteBuffer).collect(Collectors.toList()); } @Override public final Builder listOfBlobs(Collection<SdkBytes> listOfBlobs) { this.listOfBlobs = ListOfBlobsTypeCopier.copy(listOfBlobs); return this; } @Override @SafeVarargs public final Builder listOfBlobs(SdkBytes... listOfBlobs) { listOfBlobs(Arrays.asList(listOfBlobs)); return this; } public final void setListOfBlobs(Collection<ByteBuffer> listOfBlobs) { listOfBlobs(listOfBlobs == null ? null : listOfBlobs.stream().map(SdkBytes::fromByteBuffer) .collect(Collectors.toList())); } public final RecursiveStructType.Builder getRecursiveStruct() { return recursiveStruct != null ? recursiveStruct.toBuilder() : null; } @Override public final Builder recursiveStruct(RecursiveStructType recursiveStruct) { this.recursiveStruct = recursiveStruct; return this; } public final void setRecursiveStruct(RecursiveStructType.BuilderImpl recursiveStruct) { this.recursiveStruct = recursiveStruct != null ? recursiveStruct.build() : null; } public final BaseType.Builder getPolymorphicTypeWithSubTypes() { return polymorphicTypeWithSubTypes != null ? polymorphicTypeWithSubTypes.toBuilder() : null; } @Override public final Builder polymorphicTypeWithSubTypes(BaseType polymorphicTypeWithSubTypes) { this.polymorphicTypeWithSubTypes = polymorphicTypeWithSubTypes; return this; } public final void setPolymorphicTypeWithSubTypes(BaseType.BuilderImpl polymorphicTypeWithSubTypes) { this.polymorphicTypeWithSubTypes = polymorphicTypeWithSubTypes != null ? polymorphicTypeWithSubTypes.build() : null; } public final SubTypeOne.Builder getPolymorphicTypeWithoutSubTypes() { return polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.toBuilder() : null; } @Override public final Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWithoutSubTypes) { this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes; return this; } public final void setPolymorphicTypeWithoutSubTypes(SubTypeOne.BuilderImpl polymorphicTypeWithoutSubTypes) { this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.build() : null; } public final String getEnumType() { return enumType; } @Override public final Builder enumType(String enumType) { this.enumType = enumType; return this; } @Override public final Builder enumType(EnumType enumType) { this.enumType(enumType == null ? null : enumType.toString()); return this; } public final void setEnumType(String enumType) { this.enumType = enumType; } @Override public AllTypesResponse build() { return new AllTypesResponse(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,211
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/existencechecknamingrequest.java
package software.amazon.awssdk.services.jsonprotocoltests.model; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Function; 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.traits.MapTrait; import software.amazon.awssdk.core.util.SdkAutoConstructList; import software.amazon.awssdk.core.util.SdkAutoConstructMap; 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 ExistenceCheckNamingRequest extends JsonProtocolTestsRequest implements ToCopyableBuilder<ExistenceCheckNamingRequest.Builder, ExistenceCheckNamingRequest> { private static final SdkField<List<String>> BUILD_FIELD = SdkField .<List<String>> builder(MarshallingType.LIST) .memberName("Build") .getter(getter(ExistenceCheckNamingRequest::build)) .setter(setter(Builder::build)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Build").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<List<String>> SUPER_FIELD = SdkField .<List<String>> builder(MarshallingType.LIST) .memberName("super") .getter(getter(ExistenceCheckNamingRequest::superValue)) .setter(setter(Builder::superValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("super").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<Map<String, String>> TO_STRING_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("toString") .getter(getter(ExistenceCheckNamingRequest::toStringValue)) .setter(setter(Builder::toStringValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("toString").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, String>> EQUALS_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("equals") .getter(getter(ExistenceCheckNamingRequest::equalsValue)) .setter(setter(Builder::equalsValue)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("equals").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(BUILD_FIELD, SUPER_FIELD, TO_STRING_FIELD, EQUALS_FIELD)); private final List<String> build; private final List<String> superValue; private final Map<String, String> toStringValue; private final Map<String, String> equalsValue; private ExistenceCheckNamingRequest(BuilderImpl builder) { super(builder); this.build = builder.build; this.superValue = builder.superValue; this.toStringValue = builder.toStringValue; this.equalsValue = builder.equalsValue; } /** * Returns true if the Build property was specified by the sender (it may be empty), or false if the sender did not * specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasBuild() { return build != null && !(build instanceof SdkAutoConstructList); } /** * Returns the value of the Build property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasBuild()} to see if a value was sent in this field. * </p> * * @return The value of the Build property for this object. */ public final List<String> build() { return build; } /** * Returns true if the Super property was specified by the sender (it may be empty), or false if the sender did not * specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasSuperValue() { return superValue != null && !(superValue instanceof SdkAutoConstructList); } /** * Returns the value of the Super property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasSuperValue()} to see if a value was sent in this field. * </p> * * @return The value of the Super property for this object. */ public final List<String> superValue() { return superValue; } /** * Returns true if the ToString property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasToStringValue() { return toStringValue != null && !(toStringValue instanceof SdkAutoConstructMap); } /** * Returns the value of the ToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasToStringValue()} to see if a value was sent in this field. * </p> * * @return The value of the ToString property for this object. */ public final Map<String, String> toStringValue() { return toStringValue; } /** * Returns true if the Equals property was specified by the sender (it may be empty), or false if the sender did not * specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasEqualsValue() { return equalsValue != null && !(equalsValue instanceof SdkAutoConstructMap); } /** * Returns the value of the Equals property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasEqualsValue()} to see if a value was sent in this field. * </p> * * @return The value of the Equals property for this object. */ public final Map<String, String> equalsValue() { return equalsValue; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(build()); hashCode = 31 * hashCode + Objects.hashCode(superValue()); hashCode = 31 * hashCode + Objects.hashCode(toStringValue()); hashCode = 31 * hashCode + Objects.hashCode(equalsValue()); 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 ExistenceCheckNamingRequest)) { return false; } ExistenceCheckNamingRequest other = (ExistenceCheckNamingRequest) obj; return Objects.equals(build(), other.build()) && Objects.equals(superValue(), other.superValue()) && Objects.equals(toStringValue(), other.toStringValue()) && Objects.equals(equalsValue(), other.equalsValue()); } /** * 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("ExistenceCheckNamingRequest").add("Build", build()).add("Super", superValue()) .add("ToString", toStringValue()).add("Equals", equalsValue()).build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "Build": return Optional.ofNullable(clazz.cast(build())); case "super": return Optional.ofNullable(clazz.cast(superValue())); case "toString": return Optional.ofNullable(clazz.cast(toStringValue())); case "equals": return Optional.ofNullable(clazz.cast(equalsValue())); default: return Optional.empty(); } } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } private static <T> Function<Object, T> getter(Function<ExistenceCheckNamingRequest, T> g) { return obj -> g.apply((ExistenceCheckNamingRequest) obj); } private static <T> BiConsumer<Object, T> setter(BiConsumer<Builder, T> s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, CopyableBuilder<Builder, ExistenceCheckNamingRequest> { /** * Sets the value of the Build property for this object. * * @param build * The new value for the Build property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder build(Collection<String> build); /** * Sets the value of the Build property for this object. * * @param build * The new value for the Build property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder build(String... build); /** * Sets the value of the Super property for this object. * * @param superValue * The new value for the Super property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder superValue(Collection<String> superValue); /** * Sets the value of the Super property for this object. * * @param superValue * The new value for the Super property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder superValue(String... superValue); /** * Sets the value of the ToString property for this object. * * @param toStringValue * The new value for the ToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder toStringValue(Map<String, String> toStringValue); /** * Sets the value of the Equals property for this object. * * @param equalsValue * The new value for the Equals property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder equalsValue(Map<String, String> equalsValue); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer); } static final class BuilderImpl extends JsonProtocolTestsRequest.BuilderImpl implements Builder { private List<String> build; private List<String> superValue; private Map<String, String> toStringValue; private Map<String, String> equalsValue; private BuilderImpl() { } private BuilderImpl(ExistenceCheckNamingRequest model) { super(model); build(model.build); superValue(model.superValue); toStringValue(model.toStringValue); equalsValue(model.equalsValue); } public final Collection<String> getBuild() { return build; } @Override public final Builder build(Collection<String> build) { this.build = ListOfStringsCopier.copy(build); return this; } @Override @SafeVarargs public final Builder build(String... build) { build(Arrays.asList(build)); return this; } public final void setBuild(Collection<String> build) { this.build = ListOfStringsCopier.copy(build); } public final Collection<String> getSuperValue() { return superValue; } @Override public final Builder superValue(Collection<String> superValue) { this.superValue = ListOfStringsCopier.copy(superValue); return this; } @Override @SafeVarargs public final Builder superValue(String... superValue) { superValue(Arrays.asList(superValue)); return this; } public final void setSuperValue(Collection<String> superValue) { this.superValue = ListOfStringsCopier.copy(superValue); } public final Map<String, String> getToStringValue() { return toStringValue; } @Override public final Builder toStringValue(Map<String, String> toStringValue) { this.toStringValue = MapOfStringToStringCopier.copy(toStringValue); return this; } public final void setToStringValue(Map<String, String> toStringValue) { this.toStringValue = MapOfStringToStringCopier.copy(toStringValue); } public final Map<String, String> getEqualsValue() { return equalsValue; } @Override public final Builder equalsValue(Map<String, String> equalsValue) { this.equalsValue = MapOfStringToStringCopier.copy(equalsValue); return this; } public final void setEqualsValue(Map<String, String> equalsValue) { this.equalsValue = MapOfStringToStringCopier.copy(equalsValue); } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public ExistenceCheckNamingRequest build() { return new ExistenceCheckNamingRequest(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,212
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/model/nonautoconstructcontainers/alltypesrequest.java
package software.amazon.awssdk.services.jsonprotocoltests.model; import java.nio.ByteBuffer; import java.time.Instant; import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.List; import java.util.Map; 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.SdkBytes; import software.amazon.awssdk.core.SdkField; import software.amazon.awssdk.core.SdkPojo; import software.amazon.awssdk.core.adapter.StandardMemberCopier; 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.traits.MapTrait; import software.amazon.awssdk.core.util.SdkAutoConstructList; import software.amazon.awssdk.core.util.SdkAutoConstructMap; import software.amazon.awssdk.utils.CollectionUtils; 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 AllTypesRequest extends JsonProtocolTestsRequest implements ToCopyableBuilder<AllTypesRequest.Builder, AllTypesRequest> { private static final SdkField<String> STRING_MEMBER_FIELD = SdkField.<String> builder(MarshallingType.STRING) .memberName("StringMember").getter(getter(AllTypesRequest::stringMember)).setter(setter(Builder::stringMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StringMember").build()).build(); private static final SdkField<Integer> INTEGER_MEMBER_FIELD = SdkField.<Integer> builder(MarshallingType.INTEGER) .memberName("IntegerMember").getter(getter(AllTypesRequest::integerMember)).setter(setter(Builder::integerMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("IntegerMember").build()).build(); private static final SdkField<Boolean> BOOLEAN_MEMBER_FIELD = SdkField.<Boolean> builder(MarshallingType.BOOLEAN) .memberName("BooleanMember").getter(getter(AllTypesRequest::booleanMember)).setter(setter(Builder::booleanMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BooleanMember").build()).build(); private static final SdkField<Float> FLOAT_MEMBER_FIELD = SdkField.<Float> builder(MarshallingType.FLOAT) .memberName("FloatMember").getter(getter(AllTypesRequest::floatMember)).setter(setter(Builder::floatMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("FloatMember").build()).build(); private static final SdkField<Double> DOUBLE_MEMBER_FIELD = SdkField.<Double> builder(MarshallingType.DOUBLE) .memberName("DoubleMember").getter(getter(AllTypesRequest::doubleMember)).setter(setter(Builder::doubleMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("DoubleMember").build()).build(); private static final SdkField<Long> LONG_MEMBER_FIELD = SdkField.<Long> builder(MarshallingType.LONG) .memberName("LongMember").getter(getter(AllTypesRequest::longMember)).setter(setter(Builder::longMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("LongMember").build()).build(); private static final SdkField<List<String>> SIMPLE_LIST_FIELD = SdkField .<List<String>> builder(MarshallingType.LIST) .memberName("SimpleList") .getter(getter(AllTypesRequest::simpleList)) .setter(setter(Builder::simpleList)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SimpleList").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<List<String>> LIST_OF_ENUMS_FIELD = SdkField .<List<String>> builder(MarshallingType.LIST) .memberName("ListOfEnums") .getter(getter(AllTypesRequest::listOfEnumsAsStrings)) .setter(setter(Builder::listOfEnumsWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfEnums").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<List<Map<String, String>>> LIST_OF_MAPS_FIELD = SdkField .<List<Map<String, String>>> builder(MarshallingType.LIST) .memberName("ListOfMaps") .getter(getter(AllTypesRequest::listOfMaps)) .setter(setter(Builder::listOfMaps)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMaps").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<Map<String, String>> builder(MarshallingType.MAP) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()) .build()).build()).build()).build(); private static final SdkField<List<SimpleStruct>> LIST_OF_STRUCTS_FIELD = SdkField .<List<SimpleStruct>> builder(MarshallingType.LIST) .memberName("ListOfStructs") .getter(getter(AllTypesRequest::listOfStructs)) .setter(setter(Builder::listOfStructs)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfStructs").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<SimpleStruct> builder(MarshallingType.SDK_POJO) .constructor(SimpleStruct::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<List<Map<String, String>>> LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD = SdkField .<List<Map<String, String>>> builder(MarshallingType.LIST) .memberName("ListOfMapOfEnumToString") .getter(getter(AllTypesRequest::listOfMapOfEnumToStringAsStrings)) .setter(setter(Builder::listOfMapOfEnumToStringWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfMapOfEnumToString").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<Map<String, String>> builder(MarshallingType.MAP) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()) .build()).build()).build()).build(); private static final SdkField<Map<String, List<Integer>>> MAP_OF_STRING_TO_INTEGER_LIST_FIELD = SdkField .<Map<String, List<Integer>>> builder(MarshallingType.MAP) .memberName("MapOfStringToIntegerList") .getter(getter(AllTypesRequest::mapOfStringToIntegerList)) .setter(setter(Builder::mapOfStringToIntegerList)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToIntegerList").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<List<Integer>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<Integer> builder(MarshallingType.INTEGER) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()) .build()).build()).build()).build(); private static final SdkField<Map<String, String>> MAP_OF_STRING_TO_STRING_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("MapOfStringToString") .getter(getter(AllTypesRequest::mapOfStringToString)) .setter(setter(Builder::mapOfStringToString)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToString").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, SimpleStruct>> MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD = SdkField .<Map<String, SimpleStruct>> builder(MarshallingType.MAP) .memberName("MapOfStringToSimpleStruct") .getter(getter(AllTypesRequest::mapOfStringToSimpleStruct)) .setter(setter(Builder::mapOfStringToSimpleStruct)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToSimpleStruct").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<SimpleStruct> builder(MarshallingType.SDK_POJO) .constructor(SimpleStruct::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, String>> MAP_OF_ENUM_TO_ENUM_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("MapOfEnumToEnum") .getter(getter(AllTypesRequest::mapOfEnumToEnumAsStrings)) .setter(setter(Builder::mapOfEnumToEnumWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToEnum").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, String>> MAP_OF_ENUM_TO_STRING_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("MapOfEnumToString") .getter(getter(AllTypesRequest::mapOfEnumToStringAsStrings)) .setter(setter(Builder::mapOfEnumToStringWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToString").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, String>> MAP_OF_STRING_TO_ENUM_FIELD = SdkField .<Map<String, String>> builder(MarshallingType.MAP) .memberName("MapOfStringToEnum") .getter(getter(AllTypesRequest::mapOfStringToEnumAsStrings)) .setter(setter(Builder::mapOfStringToEnumWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfStringToEnum").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, SimpleStruct>> MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD = SdkField .<Map<String, SimpleStruct>> builder(MarshallingType.MAP) .memberName("MapOfEnumToSimpleStruct") .getter(getter(AllTypesRequest::mapOfEnumToSimpleStructAsStrings)) .setter(setter(Builder::mapOfEnumToSimpleStructWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToSimpleStruct").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<SimpleStruct> builder(MarshallingType.SDK_POJO) .constructor(SimpleStruct::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<Map<String, List<String>>> MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD = SdkField .<Map<String, List<String>>> builder(MarshallingType.MAP) .memberName("MapOfEnumToListOfEnums") .getter(getter(AllTypesRequest::mapOfEnumToListOfEnumsAsStrings)) .setter(setter(Builder::mapOfEnumToListOfEnumsWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToListOfEnums").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<List<String>> builder(MarshallingType.LIST) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()) .build()).build()).build()).build(); private static final SdkField<Map<String, Map<String, String>>> MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD = SdkField .<Map<String, Map<String, String>>> builder(MarshallingType.MAP) .memberName("MapOfEnumToMapOfStringToEnum") .getter(getter(AllTypesRequest::mapOfEnumToMapOfStringToEnumAsStrings)) .setter(setter(Builder::mapOfEnumToMapOfStringToEnumWithStrings)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("MapOfEnumToMapOfStringToEnum") .build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<Map<String, String>> builder(MarshallingType.MAP) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<String> builder(MarshallingType.STRING) .traits(LocationTrait.builder() .location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()) .build()).build()).build()).build(); private static final SdkField<Instant> TIMESTAMP_MEMBER_FIELD = SdkField.<Instant> builder(MarshallingType.INSTANT) .memberName("TimestampMember").getter(getter(AllTypesRequest::timestampMember)) .setter(setter(Builder::timestampMember)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TimestampMember").build()).build(); private static final SdkField<StructWithTimestamp> STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD = SdkField .<StructWithTimestamp> builder(MarshallingType.SDK_POJO) .memberName("StructWithNestedTimestampMember") .getter(getter(AllTypesRequest::structWithNestedTimestampMember)) .setter(setter(Builder::structWithNestedTimestampMember)) .constructor(StructWithTimestamp::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StructWithNestedTimestampMember") .build()).build(); private static final SdkField<SdkBytes> BLOB_ARG_FIELD = SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES) .memberName("BlobArg").getter(getter(AllTypesRequest::blobArg)).setter(setter(Builder::blobArg)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BlobArg").build()).build(); private static final SdkField<StructWithNestedBlobType> STRUCT_WITH_NESTED_BLOB_FIELD = SdkField .<StructWithNestedBlobType> builder(MarshallingType.SDK_POJO).memberName("StructWithNestedBlob") .getter(getter(AllTypesRequest::structWithNestedBlob)).setter(setter(Builder::structWithNestedBlob)) .constructor(StructWithNestedBlobType::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("StructWithNestedBlob").build()) .build(); private static final SdkField<Map<String, SdkBytes>> BLOB_MAP_FIELD = SdkField .<Map<String, SdkBytes>> builder(MarshallingType.MAP) .memberName("BlobMap") .getter(getter(AllTypesRequest::blobMap)) .setter(setter(Builder::blobMap)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("BlobMap").build(), MapTrait.builder() .keyLocationName("key") .valueLocationName("value") .valueFieldInfo( SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("value").build()).build()).build()).build(); private static final SdkField<List<SdkBytes>> LIST_OF_BLOBS_FIELD = SdkField .<List<SdkBytes>> builder(MarshallingType.LIST) .memberName("ListOfBlobs") .getter(getter(AllTypesRequest::listOfBlobs)) .setter(setter(Builder::listOfBlobs)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ListOfBlobs").build(), ListTrait .builder() .memberLocationName(null) .memberFieldInfo( SdkField.<SdkBytes> builder(MarshallingType.SDK_BYTES) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD) .locationName("member").build()).build()).build()).build(); private static final SdkField<RecursiveStructType> RECURSIVE_STRUCT_FIELD = SdkField .<RecursiveStructType> builder(MarshallingType.SDK_POJO).memberName("RecursiveStruct") .getter(getter(AllTypesRequest::recursiveStruct)).setter(setter(Builder::recursiveStruct)) .constructor(RecursiveStructType::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("RecursiveStruct").build()).build(); private static final SdkField<BaseType> POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD = SdkField .<BaseType> builder(MarshallingType.SDK_POJO) .memberName("PolymorphicTypeWithSubTypes") .getter(getter(AllTypesRequest::polymorphicTypeWithSubTypes)) .setter(setter(Builder::polymorphicTypeWithSubTypes)) .constructor(BaseType::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolymorphicTypeWithSubTypes") .build()).build(); private static final SdkField<SubTypeOne> POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD = SdkField .<SubTypeOne> builder(MarshallingType.SDK_POJO) .memberName("PolymorphicTypeWithoutSubTypes") .getter(getter(AllTypesRequest::polymorphicTypeWithoutSubTypes)) .setter(setter(Builder::polymorphicTypeWithoutSubTypes)) .constructor(SubTypeOne::builder) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("PolymorphicTypeWithoutSubTypes") .build()).build(); private static final SdkField<String> ENUM_TYPE_FIELD = SdkField.<String> builder(MarshallingType.STRING) .memberName("EnumType").getter(getter(AllTypesRequest::enumTypeAsString)).setter(setter(Builder::enumType)) .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("EnumType").build()).build(); private static final List<SdkField<?>> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(STRING_MEMBER_FIELD, INTEGER_MEMBER_FIELD, BOOLEAN_MEMBER_FIELD, FLOAT_MEMBER_FIELD, DOUBLE_MEMBER_FIELD, LONG_MEMBER_FIELD, SIMPLE_LIST_FIELD, LIST_OF_ENUMS_FIELD, LIST_OF_MAPS_FIELD, LIST_OF_STRUCTS_FIELD, LIST_OF_MAP_OF_ENUM_TO_STRING_FIELD, MAP_OF_STRING_TO_INTEGER_LIST_FIELD, MAP_OF_STRING_TO_STRING_FIELD, MAP_OF_STRING_TO_SIMPLE_STRUCT_FIELD, MAP_OF_ENUM_TO_ENUM_FIELD, MAP_OF_ENUM_TO_STRING_FIELD, MAP_OF_STRING_TO_ENUM_FIELD, MAP_OF_ENUM_TO_SIMPLE_STRUCT_FIELD, MAP_OF_ENUM_TO_LIST_OF_ENUMS_FIELD, MAP_OF_ENUM_TO_MAP_OF_STRING_TO_ENUM_FIELD, TIMESTAMP_MEMBER_FIELD, STRUCT_WITH_NESTED_TIMESTAMP_MEMBER_FIELD, BLOB_ARG_FIELD, STRUCT_WITH_NESTED_BLOB_FIELD, BLOB_MAP_FIELD, LIST_OF_BLOBS_FIELD, RECURSIVE_STRUCT_FIELD, POLYMORPHIC_TYPE_WITH_SUB_TYPES_FIELD, POLYMORPHIC_TYPE_WITHOUT_SUB_TYPES_FIELD, ENUM_TYPE_FIELD)); private final String stringMember; private final Integer integerMember; private final Boolean booleanMember; private final Float floatMember; private final Double doubleMember; private final Long longMember; private final List<String> simpleList; private final List<String> listOfEnums; private final List<Map<String, String>> listOfMaps; private final List<SimpleStruct> listOfStructs; private final List<Map<String, String>> listOfMapOfEnumToString; private final Map<String, List<Integer>> mapOfStringToIntegerList; private final Map<String, String> mapOfStringToString; private final Map<String, SimpleStruct> mapOfStringToSimpleStruct; private final Map<String, String> mapOfEnumToEnum; private final Map<String, String> mapOfEnumToString; private final Map<String, String> mapOfStringToEnum; private final Map<String, SimpleStruct> mapOfEnumToSimpleStruct; private final Map<String, List<String>> mapOfEnumToListOfEnums; private final Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum; private final Instant timestampMember; private final StructWithTimestamp structWithNestedTimestampMember; private final SdkBytes blobArg; private final StructWithNestedBlobType structWithNestedBlob; private final Map<String, SdkBytes> blobMap; private final List<SdkBytes> listOfBlobs; private final RecursiveStructType recursiveStruct; private final BaseType polymorphicTypeWithSubTypes; private final SubTypeOne polymorphicTypeWithoutSubTypes; private final String enumType; private AllTypesRequest(BuilderImpl builder) { super(builder); this.stringMember = builder.stringMember; this.integerMember = builder.integerMember; this.booleanMember = builder.booleanMember; this.floatMember = builder.floatMember; this.doubleMember = builder.doubleMember; this.longMember = builder.longMember; this.simpleList = builder.simpleList; this.listOfEnums = builder.listOfEnums; this.listOfMaps = builder.listOfMaps; this.listOfStructs = builder.listOfStructs; this.listOfMapOfEnumToString = builder.listOfMapOfEnumToString; this.mapOfStringToIntegerList = builder.mapOfStringToIntegerList; this.mapOfStringToString = builder.mapOfStringToString; this.mapOfStringToSimpleStruct = builder.mapOfStringToSimpleStruct; this.mapOfEnumToEnum = builder.mapOfEnumToEnum; this.mapOfEnumToString = builder.mapOfEnumToString; this.mapOfStringToEnum = builder.mapOfStringToEnum; this.mapOfEnumToSimpleStruct = builder.mapOfEnumToSimpleStruct; this.mapOfEnumToListOfEnums = builder.mapOfEnumToListOfEnums; this.mapOfEnumToMapOfStringToEnum = builder.mapOfEnumToMapOfStringToEnum; this.timestampMember = builder.timestampMember; this.structWithNestedTimestampMember = builder.structWithNestedTimestampMember; this.blobArg = builder.blobArg; this.structWithNestedBlob = builder.structWithNestedBlob; this.blobMap = builder.blobMap; this.listOfBlobs = builder.listOfBlobs; this.recursiveStruct = builder.recursiveStruct; this.polymorphicTypeWithSubTypes = builder.polymorphicTypeWithSubTypes; this.polymorphicTypeWithoutSubTypes = builder.polymorphicTypeWithoutSubTypes; this.enumType = builder.enumType; } /** * Returns the value of the StringMember property for this object. * * @return The value of the StringMember property for this object. */ public final String stringMember() { return stringMember; } /** * Returns the value of the IntegerMember property for this object. * * @return The value of the IntegerMember property for this object. */ public final Integer integerMember() { return integerMember; } /** * Returns the value of the BooleanMember property for this object. * * @return The value of the BooleanMember property for this object. */ public final Boolean booleanMember() { return booleanMember; } /** * Returns the value of the FloatMember property for this object. * * @return The value of the FloatMember property for this object. */ public final Float floatMember() { return floatMember; } /** * Returns the value of the DoubleMember property for this object. * * @return The value of the DoubleMember property for this object. */ public final Double doubleMember() { return doubleMember; } /** * Returns the value of the LongMember property for this object. * * @return The value of the LongMember property for this object. */ public final Long longMember() { return longMember; } /** * Returns true if the SimpleList property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasSimpleList() { return simpleList != null && !(simpleList instanceof SdkAutoConstructList); } /** * Returns the value of the SimpleList property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasSimpleList()} to see if a value was sent in this field. * </p> * * @return The value of the SimpleList property for this object. */ public final List<String> simpleList() { return simpleList; } /** * Returns the value of the ListOfEnums property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfEnums()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfEnums property for this object. */ public final List<EnumType> listOfEnums() { return ListOfEnumsCopier.copyStringToEnum(listOfEnums); } /** * Returns true if the ListOfEnums property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasListOfEnums() { return listOfEnums != null && !(listOfEnums instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfEnums property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfEnums()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfEnums property for this object. */ public final List<String> listOfEnumsAsStrings() { return listOfEnums; } /** * Returns true if the ListOfMaps property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasListOfMaps() { return listOfMaps != null && !(listOfMaps instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfMaps property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfMaps()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfMaps property for this object. */ public final List<Map<String, String>> listOfMaps() { return listOfMaps; } /** * Returns true if the ListOfStructs property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasListOfStructs() { return listOfStructs != null && !(listOfStructs instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfStructs property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfStructs()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfStructs property for this object. */ public final List<SimpleStruct> listOfStructs() { return listOfStructs; } /** * Returns the value of the ListOfMapOfEnumToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfMapOfEnumToString()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfMapOfEnumToString property for this object. */ public final List<Map<EnumType, String>> listOfMapOfEnumToString() { return ListOfMapOfEnumToStringCopier.copyStringToEnum(listOfMapOfEnumToString); } /** * Returns true if the ListOfMapOfEnumToString property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasListOfMapOfEnumToString() { return listOfMapOfEnumToString != null && !(listOfMapOfEnumToString instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfMapOfEnumToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfMapOfEnumToString()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfMapOfEnumToString property for this object. */ public final List<Map<String, String>> listOfMapOfEnumToStringAsStrings() { return listOfMapOfEnumToString; } /** * Returns true if the MapOfStringToIntegerList property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfStringToIntegerList() { return mapOfStringToIntegerList != null && !(mapOfStringToIntegerList instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToIntegerList property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToIntegerList()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToIntegerList property for this object. */ public final Map<String, List<Integer>> mapOfStringToIntegerList() { return mapOfStringToIntegerList; } /** * Returns true if the MapOfStringToString property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfStringToString() { return mapOfStringToString != null && !(mapOfStringToString instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToString()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToString property for this object. */ public final Map<String, String> mapOfStringToString() { return mapOfStringToString; } /** * Returns true if the MapOfStringToSimpleStruct property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfStringToSimpleStruct() { return mapOfStringToSimpleStruct != null && !(mapOfStringToSimpleStruct instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToSimpleStruct property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToSimpleStruct()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToSimpleStruct property for this object. */ public final Map<String, SimpleStruct> mapOfStringToSimpleStruct() { return mapOfStringToSimpleStruct; } /** * Returns the value of the MapOfEnumToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToEnum property for this object. */ public final Map<EnumType, EnumType> mapOfEnumToEnum() { return MapOfEnumToEnumCopier.copyStringToEnum(mapOfEnumToEnum); } /** * Returns true if the MapOfEnumToEnum property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfEnumToEnum() { return mapOfEnumToEnum != null && !(mapOfEnumToEnum instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToEnum property for this object. */ public final Map<String, String> mapOfEnumToEnumAsStrings() { return mapOfEnumToEnum; } /** * Returns the value of the MapOfEnumToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToString()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToString property for this object. */ public final Map<EnumType, String> mapOfEnumToString() { return MapOfEnumToStringCopier.copyStringToEnum(mapOfEnumToString); } /** * Returns true if the MapOfEnumToString property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfEnumToString() { return mapOfEnumToString != null && !(mapOfEnumToString instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToString property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToString()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToString property for this object. */ public final Map<String, String> mapOfEnumToStringAsStrings() { return mapOfEnumToString; } /** * Returns the value of the MapOfStringToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToEnum property for this object. */ public final Map<String, EnumType> mapOfStringToEnum() { return MapOfStringToEnumCopier.copyStringToEnum(mapOfStringToEnum); } /** * Returns true if the MapOfStringToEnum property was specified by the sender (it may be empty), or false if the * sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfStringToEnum() { return mapOfStringToEnum != null && !(mapOfStringToEnum instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfStringToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfStringToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfStringToEnum property for this object. */ public final Map<String, String> mapOfStringToEnumAsStrings() { return mapOfStringToEnum; } /** * Returns the value of the MapOfEnumToSimpleStruct property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToSimpleStruct()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToSimpleStruct property for this object. */ public final Map<EnumType, SimpleStruct> mapOfEnumToSimpleStruct() { return MapOfEnumToSimpleStructCopier.copyStringToEnum(mapOfEnumToSimpleStruct); } /** * Returns true if the MapOfEnumToSimpleStruct property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfEnumToSimpleStruct() { return mapOfEnumToSimpleStruct != null && !(mapOfEnumToSimpleStruct instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToSimpleStruct property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToSimpleStruct()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToSimpleStruct property for this object. */ public final Map<String, SimpleStruct> mapOfEnumToSimpleStructAsStrings() { return mapOfEnumToSimpleStruct; } /** * Returns the value of the MapOfEnumToListOfEnums property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToListOfEnums()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToListOfEnums property for this object. */ public final Map<EnumType, List<EnumType>> mapOfEnumToListOfEnums() { return MapOfEnumToListOfEnumsCopier.copyStringToEnum(mapOfEnumToListOfEnums); } /** * Returns true if the MapOfEnumToListOfEnums property was specified by the sender (it may be empty), or false if * the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS * service. */ public final boolean hasMapOfEnumToListOfEnums() { return mapOfEnumToListOfEnums != null && !(mapOfEnumToListOfEnums instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToListOfEnums property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToListOfEnums()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToListOfEnums property for this object. */ public final Map<String, List<String>> mapOfEnumToListOfEnumsAsStrings() { return mapOfEnumToListOfEnums; } /** * Returns the value of the MapOfEnumToMapOfStringToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToMapOfStringToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToMapOfStringToEnum property for this object. */ public final Map<EnumType, Map<String, EnumType>> mapOfEnumToMapOfStringToEnum() { return MapOfEnumToMapOfStringToEnumCopier.copyStringToEnum(mapOfEnumToMapOfStringToEnum); } /** * Returns true if the MapOfEnumToMapOfStringToEnum property was specified by the sender (it may be empty), or false * if the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender is the * AWS service. */ public final boolean hasMapOfEnumToMapOfStringToEnum() { return mapOfEnumToMapOfStringToEnum != null && !(mapOfEnumToMapOfStringToEnum instanceof SdkAutoConstructMap); } /** * Returns the value of the MapOfEnumToMapOfStringToEnum property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasMapOfEnumToMapOfStringToEnum()} to see if a value was sent in this field. * </p> * * @return The value of the MapOfEnumToMapOfStringToEnum property for this object. */ public final Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnumAsStrings() { return mapOfEnumToMapOfStringToEnum; } /** * Returns the value of the TimestampMember property for this object. * * @return The value of the TimestampMember property for this object. */ public final Instant timestampMember() { return timestampMember; } /** * Returns the value of the StructWithNestedTimestampMember property for this object. * * @return The value of the StructWithNestedTimestampMember property for this object. */ public final StructWithTimestamp structWithNestedTimestampMember() { return structWithNestedTimestampMember; } /** * Returns the value of the BlobArg property for this object. * * @return The value of the BlobArg property for this object. */ public final SdkBytes blobArg() { return blobArg; } /** * Returns the value of the StructWithNestedBlob property for this object. * * @return The value of the StructWithNestedBlob property for this object. */ public final StructWithNestedBlobType structWithNestedBlob() { return structWithNestedBlob; } /** * Returns true if the BlobMap property was specified by the sender (it may be empty), or false if the sender did * not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasBlobMap() { return blobMap != null && !(blobMap instanceof SdkAutoConstructMap); } /** * Returns the value of the BlobMap property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasBlobMap()} to see if a value was sent in this field. * </p> * * @return The value of the BlobMap property for this object. */ public final Map<String, SdkBytes> blobMap() { return blobMap; } /** * Returns true if the ListOfBlobs property was specified by the sender (it may be empty), or false if the sender * did not specify the value (it will be empty). For responses returned by the SDK, the sender is the AWS service. */ public final boolean hasListOfBlobs() { return listOfBlobs != null && !(listOfBlobs instanceof SdkAutoConstructList); } /** * Returns the value of the ListOfBlobs property for this object. * <p> * Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. * </p> * <p> * You can use {@link #hasListOfBlobs()} to see if a value was sent in this field. * </p> * * @return The value of the ListOfBlobs property for this object. */ public final List<SdkBytes> listOfBlobs() { return listOfBlobs; } /** * Returns the value of the RecursiveStruct property for this object. * * @return The value of the RecursiveStruct property for this object. */ public final RecursiveStructType recursiveStruct() { return recursiveStruct; } /** * Returns the value of the PolymorphicTypeWithSubTypes property for this object. * * @return The value of the PolymorphicTypeWithSubTypes property for this object. */ public final BaseType polymorphicTypeWithSubTypes() { return polymorphicTypeWithSubTypes; } /** * Returns the value of the PolymorphicTypeWithoutSubTypes property for this object. * * @return The value of the PolymorphicTypeWithoutSubTypes property for this object. */ public final SubTypeOne polymorphicTypeWithoutSubTypes() { return polymorphicTypeWithoutSubTypes; } /** * Returns the value of the EnumType property for this object. * <p> * If the service returns an enum value that is not available in the current SDK version, {@link #enumType} will * return {@link EnumType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #enumTypeAsString}. * </p> * * @return The value of the EnumType property for this object. * @see EnumType */ public final EnumType enumType() { return EnumType.fromValue(enumType); } /** * Returns the value of the EnumType property for this object. * <p> * If the service returns an enum value that is not available in the current SDK version, {@link #enumType} will * return {@link EnumType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from * {@link #enumTypeAsString}. * </p> * * @return The value of the EnumType property for this object. * @see EnumType */ public final String enumTypeAsString() { return enumType; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class<? extends Builder> serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(stringMember()); hashCode = 31 * hashCode + Objects.hashCode(integerMember()); hashCode = 31 * hashCode + Objects.hashCode(booleanMember()); hashCode = 31 * hashCode + Objects.hashCode(floatMember()); hashCode = 31 * hashCode + Objects.hashCode(doubleMember()); hashCode = 31 * hashCode + Objects.hashCode(longMember()); hashCode = 31 * hashCode + Objects.hashCode(simpleList()); hashCode = 31 * hashCode + Objects.hashCode(listOfEnumsAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(listOfMaps()); hashCode = 31 * hashCode + Objects.hashCode(listOfStructs()); hashCode = 31 * hashCode + Objects.hashCode(listOfMapOfEnumToStringAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToIntegerList()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToString()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToSimpleStruct()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToEnumAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToStringAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfStringToEnumAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToSimpleStructAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToListOfEnumsAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(mapOfEnumToMapOfStringToEnumAsStrings()); hashCode = 31 * hashCode + Objects.hashCode(timestampMember()); hashCode = 31 * hashCode + Objects.hashCode(structWithNestedTimestampMember()); hashCode = 31 * hashCode + Objects.hashCode(blobArg()); hashCode = 31 * hashCode + Objects.hashCode(structWithNestedBlob()); hashCode = 31 * hashCode + Objects.hashCode(blobMap()); hashCode = 31 * hashCode + Objects.hashCode(listOfBlobs()); hashCode = 31 * hashCode + Objects.hashCode(recursiveStruct()); hashCode = 31 * hashCode + Objects.hashCode(polymorphicTypeWithSubTypes()); hashCode = 31 * hashCode + Objects.hashCode(polymorphicTypeWithoutSubTypes()); hashCode = 31 * hashCode + Objects.hashCode(enumTypeAsString()); 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 AllTypesRequest)) { return false; } AllTypesRequest other = (AllTypesRequest) obj; return Objects.equals(stringMember(), other.stringMember()) && Objects.equals(integerMember(), other.integerMember()) && Objects.equals(booleanMember(), other.booleanMember()) && Objects.equals(floatMember(), other.floatMember()) && Objects.equals(doubleMember(), other.doubleMember()) && Objects.equals(longMember(), other.longMember()) && Objects.equals(simpleList(), other.simpleList()) && Objects.equals(listOfEnumsAsStrings(), other.listOfEnumsAsStrings()) && Objects.equals(listOfMaps(), other.listOfMaps()) && Objects.equals(listOfStructs(), other.listOfStructs()) && Objects.equals(listOfMapOfEnumToStringAsStrings(), other.listOfMapOfEnumToStringAsStrings()) && Objects.equals(mapOfStringToIntegerList(), other.mapOfStringToIntegerList()) && Objects.equals(mapOfStringToString(), other.mapOfStringToString()) && Objects.equals(mapOfStringToSimpleStruct(), other.mapOfStringToSimpleStruct()) && Objects.equals(mapOfEnumToEnumAsStrings(), other.mapOfEnumToEnumAsStrings()) && Objects.equals(mapOfEnumToStringAsStrings(), other.mapOfEnumToStringAsStrings()) && Objects.equals(mapOfStringToEnumAsStrings(), other.mapOfStringToEnumAsStrings()) && Objects.equals(mapOfEnumToSimpleStructAsStrings(), other.mapOfEnumToSimpleStructAsStrings()) && Objects.equals(mapOfEnumToListOfEnumsAsStrings(), other.mapOfEnumToListOfEnumsAsStrings()) && Objects.equals(mapOfEnumToMapOfStringToEnumAsStrings(), other.mapOfEnumToMapOfStringToEnumAsStrings()) && Objects.equals(timestampMember(), other.timestampMember()) && Objects.equals(structWithNestedTimestampMember(), other.structWithNestedTimestampMember()) && Objects.equals(blobArg(), other.blobArg()) && Objects.equals(structWithNestedBlob(), other.structWithNestedBlob()) && Objects.equals(blobMap(), other.blobMap()) && Objects.equals(listOfBlobs(), other.listOfBlobs()) && Objects.equals(recursiveStruct(), other.recursiveStruct()) && Objects.equals(polymorphicTypeWithSubTypes(), other.polymorphicTypeWithSubTypes()) && Objects.equals(polymorphicTypeWithoutSubTypes(), other.polymorphicTypeWithoutSubTypes()) && Objects.equals(enumTypeAsString(), other.enumTypeAsString()); } /** * 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("AllTypesRequest").add("StringMember", stringMember()).add("IntegerMember", integerMember()) .add("BooleanMember", booleanMember()).add("FloatMember", floatMember()).add("DoubleMember", doubleMember()) .add("LongMember", longMember()).add("SimpleList", simpleList()).add("ListOfEnums", listOfEnumsAsStrings()) .add("ListOfMaps", listOfMaps()).add("ListOfStructs", listOfStructs()) .add("ListOfMapOfEnumToString", listOfMapOfEnumToStringAsStrings()) .add("MapOfStringToIntegerList", mapOfStringToIntegerList()).add("MapOfStringToString", mapOfStringToString()) .add("MapOfStringToSimpleStruct", mapOfStringToSimpleStruct()).add("MapOfEnumToEnum", mapOfEnumToEnumAsStrings()) .add("MapOfEnumToString", mapOfEnumToStringAsStrings()).add("MapOfStringToEnum", mapOfStringToEnumAsStrings()) .add("MapOfEnumToSimpleStruct", mapOfEnumToSimpleStructAsStrings()) .add("MapOfEnumToListOfEnums", mapOfEnumToListOfEnumsAsStrings()) .add("MapOfEnumToMapOfStringToEnum", mapOfEnumToMapOfStringToEnumAsStrings()) .add("TimestampMember", timestampMember()) .add("StructWithNestedTimestampMember", structWithNestedTimestampMember()).add("BlobArg", blobArg()) .add("StructWithNestedBlob", structWithNestedBlob()).add("BlobMap", blobMap()).add("ListOfBlobs", listOfBlobs()) .add("RecursiveStruct", recursiveStruct()).add("PolymorphicTypeWithSubTypes", polymorphicTypeWithSubTypes()) .add("PolymorphicTypeWithoutSubTypes", polymorphicTypeWithoutSubTypes()).add("EnumType", enumTypeAsString()) .build(); } public final <T> Optional<T> getValueForField(String fieldName, Class<T> clazz) { switch (fieldName) { case "StringMember": return Optional.ofNullable(clazz.cast(stringMember())); case "IntegerMember": return Optional.ofNullable(clazz.cast(integerMember())); case "BooleanMember": return Optional.ofNullable(clazz.cast(booleanMember())); case "FloatMember": return Optional.ofNullable(clazz.cast(floatMember())); case "DoubleMember": return Optional.ofNullable(clazz.cast(doubleMember())); case "LongMember": return Optional.ofNullable(clazz.cast(longMember())); case "SimpleList": return Optional.ofNullable(clazz.cast(simpleList())); case "ListOfEnums": return Optional.ofNullable(clazz.cast(listOfEnumsAsStrings())); case "ListOfMaps": return Optional.ofNullable(clazz.cast(listOfMaps())); case "ListOfStructs": return Optional.ofNullable(clazz.cast(listOfStructs())); case "ListOfMapOfEnumToString": return Optional.ofNullable(clazz.cast(listOfMapOfEnumToStringAsStrings())); case "MapOfStringToIntegerList": return Optional.ofNullable(clazz.cast(mapOfStringToIntegerList())); case "MapOfStringToString": return Optional.ofNullable(clazz.cast(mapOfStringToString())); case "MapOfStringToSimpleStruct": return Optional.ofNullable(clazz.cast(mapOfStringToSimpleStruct())); case "MapOfEnumToEnum": return Optional.ofNullable(clazz.cast(mapOfEnumToEnumAsStrings())); case "MapOfEnumToString": return Optional.ofNullable(clazz.cast(mapOfEnumToStringAsStrings())); case "MapOfStringToEnum": return Optional.ofNullable(clazz.cast(mapOfStringToEnumAsStrings())); case "MapOfEnumToSimpleStruct": return Optional.ofNullable(clazz.cast(mapOfEnumToSimpleStructAsStrings())); case "MapOfEnumToListOfEnums": return Optional.ofNullable(clazz.cast(mapOfEnumToListOfEnumsAsStrings())); case "MapOfEnumToMapOfStringToEnum": return Optional.ofNullable(clazz.cast(mapOfEnumToMapOfStringToEnumAsStrings())); case "TimestampMember": return Optional.ofNullable(clazz.cast(timestampMember())); case "StructWithNestedTimestampMember": return Optional.ofNullable(clazz.cast(structWithNestedTimestampMember())); case "BlobArg": return Optional.ofNullable(clazz.cast(blobArg())); case "StructWithNestedBlob": return Optional.ofNullable(clazz.cast(structWithNestedBlob())); case "BlobMap": return Optional.ofNullable(clazz.cast(blobMap())); case "ListOfBlobs": return Optional.ofNullable(clazz.cast(listOfBlobs())); case "RecursiveStruct": return Optional.ofNullable(clazz.cast(recursiveStruct())); case "PolymorphicTypeWithSubTypes": return Optional.ofNullable(clazz.cast(polymorphicTypeWithSubTypes())); case "PolymorphicTypeWithoutSubTypes": return Optional.ofNullable(clazz.cast(polymorphicTypeWithoutSubTypes())); case "EnumType": return Optional.ofNullable(clazz.cast(enumTypeAsString())); default: return Optional.empty(); } } @Override public final List<SdkField<?>> sdkFields() { return SDK_FIELDS; } private static <T> Function<Object, T> getter(Function<AllTypesRequest, T> g) { return obj -> g.apply((AllTypesRequest) obj); } private static <T> BiConsumer<Object, T> setter(BiConsumer<Builder, T> s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends JsonProtocolTestsRequest.Builder, SdkPojo, CopyableBuilder<Builder, AllTypesRequest> { /** * Sets the value of the StringMember property for this object. * * @param stringMember * The new value for the StringMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder stringMember(String stringMember); /** * Sets the value of the IntegerMember property for this object. * * @param integerMember * The new value for the IntegerMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder integerMember(Integer integerMember); /** * Sets the value of the BooleanMember property for this object. * * @param booleanMember * The new value for the BooleanMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder booleanMember(Boolean booleanMember); /** * Sets the value of the FloatMember property for this object. * * @param floatMember * The new value for the FloatMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder floatMember(Float floatMember); /** * Sets the value of the DoubleMember property for this object. * * @param doubleMember * The new value for the DoubleMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder doubleMember(Double doubleMember); /** * Sets the value of the LongMember property for this object. * * @param longMember * The new value for the LongMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder longMember(Long longMember); /** * Sets the value of the SimpleList property for this object. * * @param simpleList * The new value for the SimpleList property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder simpleList(Collection<String> simpleList); /** * Sets the value of the SimpleList property for this object. * * @param simpleList * The new value for the SimpleList property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder simpleList(String... simpleList); /** * Sets the value of the ListOfEnums property for this object. * * @param listOfEnums * The new value for the ListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfEnumsWithStrings(Collection<String> listOfEnums); /** * Sets the value of the ListOfEnums property for this object. * * @param listOfEnums * The new value for the ListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfEnumsWithStrings(String... listOfEnums); /** * Sets the value of the ListOfEnums property for this object. * * @param listOfEnums * The new value for the ListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfEnums(Collection<EnumType> listOfEnums); /** * Sets the value of the ListOfEnums property for this object. * * @param listOfEnums * The new value for the ListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfEnums(EnumType... listOfEnums); /** * Sets the value of the ListOfMaps property for this object. * * @param listOfMaps * The new value for the ListOfMaps property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps); /** * Sets the value of the ListOfMaps property for this object. * * @param listOfMaps * The new value for the ListOfMaps property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfMaps(Map<String, String>... listOfMaps); /** * Sets the value of the ListOfStructs property for this object. * * @param listOfStructs * The new value for the ListOfStructs property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfStructs(Collection<SimpleStruct> listOfStructs); /** * Sets the value of the ListOfStructs property for this object. * * @param listOfStructs * The new value for the ListOfStructs property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfStructs(SimpleStruct... listOfStructs); /** * Sets the value of the ListOfStructs property for this object. * * This is a convenience that creates an instance of the {@link List<SimpleStruct>.Builder} avoiding the need to * create one manually via {@link List<SimpleStruct>#builder()}. * * When the {@link Consumer} completes, {@link List<SimpleStruct>.Builder#build()} is called immediately and its * result is passed to {@link #listOfStructs(List<SimpleStruct>)}. * * @param listOfStructs * a consumer that will call methods on {@link List<SimpleStruct>.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #listOfStructs(List<SimpleStruct>) */ Builder listOfStructs(Consumer<SimpleStruct.Builder>... listOfStructs); /** * Sets the value of the ListOfMapOfEnumToString property for this object. * * @param listOfMapOfEnumToString * The new value for the ListOfMapOfEnumToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfMapOfEnumToStringWithStrings(Collection<? extends Map<String, String>> listOfMapOfEnumToString); /** * Sets the value of the ListOfMapOfEnumToString property for this object. * * @param listOfMapOfEnumToString * The new value for the ListOfMapOfEnumToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfMapOfEnumToStringWithStrings(Map<String, String>... listOfMapOfEnumToString); /** * Sets the value of the MapOfStringToIntegerList property for this object. * * @param mapOfStringToIntegerList * The new value for the MapOfStringToIntegerList property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToIntegerList(Map<String, ? extends Collection<Integer>> mapOfStringToIntegerList); /** * Sets the value of the MapOfStringToString property for this object. * * @param mapOfStringToString * The new value for the MapOfStringToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToString(Map<String, String> mapOfStringToString); /** * Sets the value of the MapOfStringToSimpleStruct property for this object. * * @param mapOfStringToSimpleStruct * The new value for the MapOfStringToSimpleStruct property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToSimpleStruct(Map<String, SimpleStruct> mapOfStringToSimpleStruct); /** * Sets the value of the MapOfEnumToEnum property for this object. * * @param mapOfEnumToEnum * The new value for the MapOfEnumToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToEnumWithStrings(Map<String, String> mapOfEnumToEnum); /** * Sets the value of the MapOfEnumToEnum property for this object. * * @param mapOfEnumToEnum * The new value for the MapOfEnumToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToEnum(Map<EnumType, EnumType> mapOfEnumToEnum); /** * Sets the value of the MapOfEnumToString property for this object. * * @param mapOfEnumToString * The new value for the MapOfEnumToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToStringWithStrings(Map<String, String> mapOfEnumToString); /** * Sets the value of the MapOfEnumToString property for this object. * * @param mapOfEnumToString * The new value for the MapOfEnumToString property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToString(Map<EnumType, String> mapOfEnumToString); /** * Sets the value of the MapOfStringToEnum property for this object. * * @param mapOfStringToEnum * The new value for the MapOfStringToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToEnumWithStrings(Map<String, String> mapOfStringToEnum); /** * Sets the value of the MapOfStringToEnum property for this object. * * @param mapOfStringToEnum * The new value for the MapOfStringToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfStringToEnum(Map<String, EnumType> mapOfStringToEnum); /** * Sets the value of the MapOfEnumToSimpleStruct property for this object. * * @param mapOfEnumToSimpleStruct * The new value for the MapOfEnumToSimpleStruct property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToSimpleStructWithStrings(Map<String, SimpleStruct> mapOfEnumToSimpleStruct); /** * Sets the value of the MapOfEnumToSimpleStruct property for this object. * * @param mapOfEnumToSimpleStruct * The new value for the MapOfEnumToSimpleStruct property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToSimpleStruct(Map<EnumType, SimpleStruct> mapOfEnumToSimpleStruct); /** * Sets the value of the MapOfEnumToListOfEnums property for this object. * * @param mapOfEnumToListOfEnums * The new value for the MapOfEnumToListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToListOfEnumsWithStrings(Map<String, ? extends Collection<String>> mapOfEnumToListOfEnums); /** * Sets the value of the MapOfEnumToListOfEnums property for this object. * * @param mapOfEnumToListOfEnums * The new value for the MapOfEnumToListOfEnums property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToListOfEnums(Map<EnumType, ? extends Collection<EnumType>> mapOfEnumToListOfEnums); /** * Sets the value of the MapOfEnumToMapOfStringToEnum property for this object. * * @param mapOfEnumToMapOfStringToEnum * The new value for the MapOfEnumToMapOfStringToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToMapOfStringToEnumWithStrings(Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum); /** * Sets the value of the MapOfEnumToMapOfStringToEnum property for this object. * * @param mapOfEnumToMapOfStringToEnum * The new value for the MapOfEnumToMapOfStringToEnum property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder mapOfEnumToMapOfStringToEnum(Map<EnumType, Map<String, EnumType>> mapOfEnumToMapOfStringToEnum); /** * Sets the value of the TimestampMember property for this object. * * @param timestampMember * The new value for the TimestampMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder timestampMember(Instant timestampMember); /** * Sets the value of the StructWithNestedTimestampMember property for this object. * * @param structWithNestedTimestampMember * The new value for the StructWithNestedTimestampMember property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder structWithNestedTimestampMember(StructWithTimestamp structWithNestedTimestampMember); /** * Sets the value of the StructWithNestedTimestampMember property for this object. * * This is a convenience that creates an instance of the {@link StructWithTimestamp.Builder} avoiding the need * to create one manually via {@link StructWithTimestamp#builder()}. * * When the {@link Consumer} completes, {@link StructWithTimestamp.Builder#build()} is called immediately and * its result is passed to {@link #structWithNestedTimestampMember(StructWithTimestamp)}. * * @param structWithNestedTimestampMember * a consumer that will call methods on {@link StructWithTimestamp.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #structWithNestedTimestampMember(StructWithTimestamp) */ default Builder structWithNestedTimestampMember(Consumer<StructWithTimestamp.Builder> structWithNestedTimestampMember) { return structWithNestedTimestampMember(StructWithTimestamp.builder().applyMutation(structWithNestedTimestampMember) .build()); } /** * Sets the value of the BlobArg property for this object. * * @param blobArg * The new value for the BlobArg property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder blobArg(SdkBytes blobArg); /** * Sets the value of the StructWithNestedBlob property for this object. * * @param structWithNestedBlob * The new value for the StructWithNestedBlob property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder structWithNestedBlob(StructWithNestedBlobType structWithNestedBlob); /** * Sets the value of the StructWithNestedBlob property for this object. * * This is a convenience that creates an instance of the {@link StructWithNestedBlobType.Builder} avoiding the * need to create one manually via {@link StructWithNestedBlobType#builder()}. * * When the {@link Consumer} completes, {@link StructWithNestedBlobType.Builder#build()} is called immediately * and its result is passed to {@link #structWithNestedBlob(StructWithNestedBlobType)}. * * @param structWithNestedBlob * a consumer that will call methods on {@link StructWithNestedBlobType.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #structWithNestedBlob(StructWithNestedBlobType) */ default Builder structWithNestedBlob(Consumer<StructWithNestedBlobType.Builder> structWithNestedBlob) { return structWithNestedBlob(StructWithNestedBlobType.builder().applyMutation(structWithNestedBlob).build()); } /** * Sets the value of the BlobMap property for this object. * * @param blobMap * The new value for the BlobMap property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder blobMap(Map<String, SdkBytes> blobMap); /** * Sets the value of the ListOfBlobs property for this object. * * @param listOfBlobs * The new value for the ListOfBlobs property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfBlobs(Collection<SdkBytes> listOfBlobs); /** * Sets the value of the ListOfBlobs property for this object. * * @param listOfBlobs * The new value for the ListOfBlobs property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder listOfBlobs(SdkBytes... listOfBlobs); /** * Sets the value of the RecursiveStruct property for this object. * * @param recursiveStruct * The new value for the RecursiveStruct property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder recursiveStruct(RecursiveStructType recursiveStruct); /** * Sets the value of the RecursiveStruct property for this object. * * This is a convenience that creates an instance of the {@link RecursiveStructType.Builder} avoiding the need * to create one manually via {@link RecursiveStructType#builder()}. * * When the {@link Consumer} completes, {@link RecursiveStructType.Builder#build()} is called immediately and * its result is passed to {@link #recursiveStruct(RecursiveStructType)}. * * @param recursiveStruct * a consumer that will call methods on {@link RecursiveStructType.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #recursiveStruct(RecursiveStructType) */ default Builder recursiveStruct(Consumer<RecursiveStructType.Builder> recursiveStruct) { return recursiveStruct(RecursiveStructType.builder().applyMutation(recursiveStruct).build()); } /** * Sets the value of the PolymorphicTypeWithSubTypes property for this object. * * @param polymorphicTypeWithSubTypes * The new value for the PolymorphicTypeWithSubTypes property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder polymorphicTypeWithSubTypes(BaseType polymorphicTypeWithSubTypes); /** * Sets the value of the PolymorphicTypeWithSubTypes property for this object. * * This is a convenience that creates an instance of the {@link BaseType.Builder} avoiding the need to create * one manually via {@link BaseType#builder()}. * * When the {@link Consumer} completes, {@link BaseType.Builder#build()} is called immediately and its result is * passed to {@link #polymorphicTypeWithSubTypes(BaseType)}. * * @param polymorphicTypeWithSubTypes * a consumer that will call methods on {@link BaseType.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #polymorphicTypeWithSubTypes(BaseType) */ default Builder polymorphicTypeWithSubTypes(Consumer<BaseType.Builder> polymorphicTypeWithSubTypes) { return polymorphicTypeWithSubTypes(BaseType.builder().applyMutation(polymorphicTypeWithSubTypes).build()); } /** * Sets the value of the PolymorphicTypeWithoutSubTypes property for this object. * * @param polymorphicTypeWithoutSubTypes * The new value for the PolymorphicTypeWithoutSubTypes property for this object. * @return Returns a reference to this object so that method calls can be chained together. */ Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWithoutSubTypes); /** * Sets the value of the PolymorphicTypeWithoutSubTypes property for this object. * * This is a convenience that creates an instance of the {@link SubTypeOne.Builder} avoiding the need to create * one manually via {@link SubTypeOne#builder()}. * * When the {@link Consumer} completes, {@link SubTypeOne.Builder#build()} is called immediately and its result * is passed to {@link #polymorphicTypeWithoutSubTypes(SubTypeOne)}. * * @param polymorphicTypeWithoutSubTypes * a consumer that will call methods on {@link SubTypeOne.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #polymorphicTypeWithoutSubTypes(SubTypeOne) */ default Builder polymorphicTypeWithoutSubTypes(Consumer<SubTypeOne.Builder> polymorphicTypeWithoutSubTypes) { return polymorphicTypeWithoutSubTypes(SubTypeOne.builder().applyMutation(polymorphicTypeWithoutSubTypes).build()); } /** * Sets the value of the EnumType property for this object. * * @param enumType * The new value for the EnumType property for this object. * @see EnumType * @return Returns a reference to this object so that method calls can be chained together. * @see EnumType */ Builder enumType(String enumType); /** * Sets the value of the EnumType property for this object. * * @param enumType * The new value for the EnumType property for this object. * @see EnumType * @return Returns a reference to this object so that method calls can be chained together. * @see EnumType */ Builder enumType(EnumType enumType); @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer); } static final class BuilderImpl extends JsonProtocolTestsRequest.BuilderImpl implements Builder { private String stringMember; private Integer integerMember; private Boolean booleanMember; private Float floatMember; private Double doubleMember; private Long longMember; private List<String> simpleList; private List<String> listOfEnums; private List<Map<String, String>> listOfMaps; private List<SimpleStruct> listOfStructs; private List<Map<String, String>> listOfMapOfEnumToString; private Map<String, List<Integer>> mapOfStringToIntegerList; private Map<String, String> mapOfStringToString; private Map<String, SimpleStruct> mapOfStringToSimpleStruct; private Map<String, String> mapOfEnumToEnum; private Map<String, String> mapOfEnumToString; private Map<String, String> mapOfStringToEnum; private Map<String, SimpleStruct> mapOfEnumToSimpleStruct; private Map<String, List<String>> mapOfEnumToListOfEnums; private Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum; private Instant timestampMember; private StructWithTimestamp structWithNestedTimestampMember; private SdkBytes blobArg; private StructWithNestedBlobType structWithNestedBlob; private Map<String, SdkBytes> blobMap; private List<SdkBytes> listOfBlobs; private RecursiveStructType recursiveStruct; private BaseType polymorphicTypeWithSubTypes; private SubTypeOne polymorphicTypeWithoutSubTypes; private String enumType; private BuilderImpl() { } private BuilderImpl(AllTypesRequest model) { super(model); stringMember(model.stringMember); integerMember(model.integerMember); booleanMember(model.booleanMember); floatMember(model.floatMember); doubleMember(model.doubleMember); longMember(model.longMember); simpleList(model.simpleList); listOfEnumsWithStrings(model.listOfEnums); listOfMaps(model.listOfMaps); listOfStructs(model.listOfStructs); listOfMapOfEnumToStringWithStrings(model.listOfMapOfEnumToString); mapOfStringToIntegerList(model.mapOfStringToIntegerList); mapOfStringToString(model.mapOfStringToString); mapOfStringToSimpleStruct(model.mapOfStringToSimpleStruct); mapOfEnumToEnumWithStrings(model.mapOfEnumToEnum); mapOfEnumToStringWithStrings(model.mapOfEnumToString); mapOfStringToEnumWithStrings(model.mapOfStringToEnum); mapOfEnumToSimpleStructWithStrings(model.mapOfEnumToSimpleStruct); mapOfEnumToListOfEnumsWithStrings(model.mapOfEnumToListOfEnums); mapOfEnumToMapOfStringToEnumWithStrings(model.mapOfEnumToMapOfStringToEnum); timestampMember(model.timestampMember); structWithNestedTimestampMember(model.structWithNestedTimestampMember); blobArg(model.blobArg); structWithNestedBlob(model.structWithNestedBlob); blobMap(model.blobMap); listOfBlobs(model.listOfBlobs); recursiveStruct(model.recursiveStruct); polymorphicTypeWithSubTypes(model.polymorphicTypeWithSubTypes); polymorphicTypeWithoutSubTypes(model.polymorphicTypeWithoutSubTypes); enumType(model.enumType); } public final String getStringMember() { return stringMember; } @Override public final Builder stringMember(String stringMember) { this.stringMember = stringMember; return this; } public final void setStringMember(String stringMember) { this.stringMember = stringMember; } public final Integer getIntegerMember() { return integerMember; } @Override public final Builder integerMember(Integer integerMember) { this.integerMember = integerMember; return this; } public final void setIntegerMember(Integer integerMember) { this.integerMember = integerMember; } public final Boolean getBooleanMember() { return booleanMember; } @Override public final Builder booleanMember(Boolean booleanMember) { this.booleanMember = booleanMember; return this; } public final void setBooleanMember(Boolean booleanMember) { this.booleanMember = booleanMember; } public final Float getFloatMember() { return floatMember; } @Override public final Builder floatMember(Float floatMember) { this.floatMember = floatMember; return this; } public final void setFloatMember(Float floatMember) { this.floatMember = floatMember; } public final Double getDoubleMember() { return doubleMember; } @Override public final Builder doubleMember(Double doubleMember) { this.doubleMember = doubleMember; return this; } public final void setDoubleMember(Double doubleMember) { this.doubleMember = doubleMember; } public final Long getLongMember() { return longMember; } @Override public final Builder longMember(Long longMember) { this.longMember = longMember; return this; } public final void setLongMember(Long longMember) { this.longMember = longMember; } public final Collection<String> getSimpleList() { return simpleList; } @Override public final Builder simpleList(Collection<String> simpleList) { this.simpleList = ListOfStringsCopier.copy(simpleList); return this; } @Override @SafeVarargs public final Builder simpleList(String... simpleList) { simpleList(Arrays.asList(simpleList)); return this; } public final void setSimpleList(Collection<String> simpleList) { this.simpleList = ListOfStringsCopier.copy(simpleList); } public final Collection<String> getListOfEnums() { return listOfEnums; } @Override public final Builder listOfEnumsWithStrings(Collection<String> listOfEnums) { this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums); return this; } @Override @SafeVarargs public final Builder listOfEnumsWithStrings(String... listOfEnums) { listOfEnumsWithStrings(Arrays.asList(listOfEnums)); return this; } @Override public final Builder listOfEnums(Collection<EnumType> listOfEnums) { this.listOfEnums = ListOfEnumsCopier.copyEnumToString(listOfEnums); return this; } @Override @SafeVarargs public final Builder listOfEnums(EnumType... listOfEnums) { listOfEnums(Arrays.asList(listOfEnums)); return this; } public final void setListOfEnums(Collection<String> listOfEnums) { this.listOfEnums = ListOfEnumsCopier.copy(listOfEnums); } public final Collection<? extends Map<String, String>> getListOfMaps() { return listOfMaps; } @Override public final Builder listOfMaps(Collection<? extends Map<String, String>> listOfMaps) { this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps); return this; } @Override @SafeVarargs public final Builder listOfMaps(Map<String, String>... listOfMaps) { listOfMaps(Arrays.asList(listOfMaps)); return this; } public final void setListOfMaps(Collection<? extends Map<String, String>> listOfMaps) { this.listOfMaps = ListOfMapStringToStringCopier.copy(listOfMaps); } public final Collection<SimpleStruct.Builder> getListOfStructs() { return listOfStructs != null ? listOfStructs.stream().map(SimpleStruct::toBuilder).collect(Collectors.toList()) : null; } @Override public final Builder listOfStructs(Collection<SimpleStruct> listOfStructs) { this.listOfStructs = ListOfSimpleStructsCopier.copy(listOfStructs); return this; } @Override @SafeVarargs public final Builder listOfStructs(SimpleStruct... listOfStructs) { listOfStructs(Arrays.asList(listOfStructs)); return this; } @Override @SafeVarargs public final Builder listOfStructs(Consumer<SimpleStruct.Builder>... listOfStructs) { listOfStructs(Stream.of(listOfStructs).map(c -> SimpleStruct.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final void setListOfStructs(Collection<SimpleStruct.BuilderImpl> listOfStructs) { this.listOfStructs = ListOfSimpleStructsCopier.copyFromBuilder(listOfStructs); } public final Collection<? extends Map<String, String>> getListOfMapOfEnumToString() { return listOfMapOfEnumToString; } @Override public final Builder listOfMapOfEnumToStringWithStrings(Collection<? extends Map<String, String>> listOfMapOfEnumToString) { this.listOfMapOfEnumToString = ListOfMapOfEnumToStringCopier.copy(listOfMapOfEnumToString); return this; } @Override @SafeVarargs public final Builder listOfMapOfEnumToStringWithStrings(Map<String, String>... listOfMapOfEnumToString) { listOfMapOfEnumToStringWithStrings(Arrays.asList(listOfMapOfEnumToString)); return this; } public final void setListOfMapOfEnumToString(Collection<? extends Map<String, String>> listOfMapOfEnumToString) { this.listOfMapOfEnumToString = ListOfMapOfEnumToStringCopier.copy(listOfMapOfEnumToString); } public final Map<String, ? extends Collection<Integer>> getMapOfStringToIntegerList() { return mapOfStringToIntegerList; } @Override public final Builder mapOfStringToIntegerList(Map<String, ? extends Collection<Integer>> mapOfStringToIntegerList) { this.mapOfStringToIntegerList = MapOfStringToIntegerListCopier.copy(mapOfStringToIntegerList); return this; } public final void setMapOfStringToIntegerList(Map<String, ? extends Collection<Integer>> mapOfStringToIntegerList) { this.mapOfStringToIntegerList = MapOfStringToIntegerListCopier.copy(mapOfStringToIntegerList); } public final Map<String, String> getMapOfStringToString() { return mapOfStringToString; } @Override public final Builder mapOfStringToString(Map<String, String> mapOfStringToString) { this.mapOfStringToString = MapOfStringToStringCopier.copy(mapOfStringToString); return this; } public final void setMapOfStringToString(Map<String, String> mapOfStringToString) { this.mapOfStringToString = MapOfStringToStringCopier.copy(mapOfStringToString); } public final Map<String, SimpleStruct.Builder> getMapOfStringToSimpleStruct() { return mapOfStringToSimpleStruct != null ? CollectionUtils.mapValues(mapOfStringToSimpleStruct, SimpleStruct::toBuilder) : null; } @Override public final Builder mapOfStringToSimpleStruct(Map<String, SimpleStruct> mapOfStringToSimpleStruct) { this.mapOfStringToSimpleStruct = MapOfStringToSimpleStructCopier.copy(mapOfStringToSimpleStruct); return this; } public final void setMapOfStringToSimpleStruct(Map<String, SimpleStruct.BuilderImpl> mapOfStringToSimpleStruct) { this.mapOfStringToSimpleStruct = MapOfStringToSimpleStructCopier.copyFromBuilder(mapOfStringToSimpleStruct); } public final Map<String, String> getMapOfEnumToEnum() { return mapOfEnumToEnum; } @Override public final Builder mapOfEnumToEnumWithStrings(Map<String, String> mapOfEnumToEnum) { this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copy(mapOfEnumToEnum); return this; } @Override public final Builder mapOfEnumToEnum(Map<EnumType, EnumType> mapOfEnumToEnum) { this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copyEnumToString(mapOfEnumToEnum); return this; } public final void setMapOfEnumToEnum(Map<String, String> mapOfEnumToEnum) { this.mapOfEnumToEnum = MapOfEnumToEnumCopier.copy(mapOfEnumToEnum); } public final Map<String, String> getMapOfEnumToString() { return mapOfEnumToString; } @Override public final Builder mapOfEnumToStringWithStrings(Map<String, String> mapOfEnumToString) { this.mapOfEnumToString = MapOfEnumToStringCopier.copy(mapOfEnumToString); return this; } @Override public final Builder mapOfEnumToString(Map<EnumType, String> mapOfEnumToString) { this.mapOfEnumToString = MapOfEnumToStringCopier.copyEnumToString(mapOfEnumToString); return this; } public final void setMapOfEnumToString(Map<String, String> mapOfEnumToString) { this.mapOfEnumToString = MapOfEnumToStringCopier.copy(mapOfEnumToString); } public final Map<String, String> getMapOfStringToEnum() { return mapOfStringToEnum; } @Override public final Builder mapOfStringToEnumWithStrings(Map<String, String> mapOfStringToEnum) { this.mapOfStringToEnum = MapOfStringToEnumCopier.copy(mapOfStringToEnum); return this; } @Override public final Builder mapOfStringToEnum(Map<String, EnumType> mapOfStringToEnum) { this.mapOfStringToEnum = MapOfStringToEnumCopier.copyEnumToString(mapOfStringToEnum); return this; } public final void setMapOfStringToEnum(Map<String, String> mapOfStringToEnum) { this.mapOfStringToEnum = MapOfStringToEnumCopier.copy(mapOfStringToEnum); } public final Map<String, SimpleStruct.Builder> getMapOfEnumToSimpleStruct() { return mapOfEnumToSimpleStruct != null ? CollectionUtils.mapValues(mapOfEnumToSimpleStruct, SimpleStruct::toBuilder) : null; } @Override public final Builder mapOfEnumToSimpleStructWithStrings(Map<String, SimpleStruct> mapOfEnumToSimpleStruct) { this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copy(mapOfEnumToSimpleStruct); return this; } @Override public final Builder mapOfEnumToSimpleStruct(Map<EnumType, SimpleStruct> mapOfEnumToSimpleStruct) { this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copyEnumToString(mapOfEnumToSimpleStruct); return this; } public final void setMapOfEnumToSimpleStruct(Map<String, SimpleStruct.BuilderImpl> mapOfEnumToSimpleStruct) { this.mapOfEnumToSimpleStruct = MapOfEnumToSimpleStructCopier.copyFromBuilder(mapOfEnumToSimpleStruct); } public final Map<String, ? extends Collection<String>> getMapOfEnumToListOfEnums() { return mapOfEnumToListOfEnums; } @Override public final Builder mapOfEnumToListOfEnumsWithStrings(Map<String, ? extends Collection<String>> mapOfEnumToListOfEnums) { this.mapOfEnumToListOfEnums = MapOfEnumToListOfEnumsCopier.copy(mapOfEnumToListOfEnums); return this; } @Override public final Builder mapOfEnumToListOfEnums(Map<EnumType, ? extends Collection<EnumType>> mapOfEnumToListOfEnums) { this.mapOfEnumToListOfEnums = MapOfEnumToListOfEnumsCopier.copyEnumToString(mapOfEnumToListOfEnums); return this; } public final void setMapOfEnumToListOfEnums(Map<String, ? extends Collection<String>> mapOfEnumToListOfEnums) { this.mapOfEnumToListOfEnums = MapOfEnumToListOfEnumsCopier.copy(mapOfEnumToListOfEnums); } public final Map<String, Map<String, String>> getMapOfEnumToMapOfStringToEnum() { return mapOfEnumToMapOfStringToEnum; } @Override public final Builder mapOfEnumToMapOfStringToEnumWithStrings(Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum) { this.mapOfEnumToMapOfStringToEnum = MapOfEnumToMapOfStringToEnumCopier.copy(mapOfEnumToMapOfStringToEnum); return this; } @Override public final Builder mapOfEnumToMapOfStringToEnum(Map<EnumType, Map<String, EnumType>> mapOfEnumToMapOfStringToEnum) { this.mapOfEnumToMapOfStringToEnum = MapOfEnumToMapOfStringToEnumCopier.copyEnumToString(mapOfEnumToMapOfStringToEnum); return this; } public final void setMapOfEnumToMapOfStringToEnum(Map<String, Map<String, String>> mapOfEnumToMapOfStringToEnum) { this.mapOfEnumToMapOfStringToEnum = MapOfEnumToMapOfStringToEnumCopier.copy(mapOfEnumToMapOfStringToEnum); } public final Instant getTimestampMember() { return timestampMember; } @Override public final Builder timestampMember(Instant timestampMember) { this.timestampMember = timestampMember; return this; } public final void setTimestampMember(Instant timestampMember) { this.timestampMember = timestampMember; } public final StructWithTimestamp.Builder getStructWithNestedTimestampMember() { return structWithNestedTimestampMember != null ? structWithNestedTimestampMember.toBuilder() : null; } @Override public final Builder structWithNestedTimestampMember(StructWithTimestamp structWithNestedTimestampMember) { this.structWithNestedTimestampMember = structWithNestedTimestampMember; return this; } public final void setStructWithNestedTimestampMember(StructWithTimestamp.BuilderImpl structWithNestedTimestampMember) { this.structWithNestedTimestampMember = structWithNestedTimestampMember != null ? structWithNestedTimestampMember .build() : null; } public final ByteBuffer getBlobArg() { return blobArg == null ? null : blobArg.asByteBuffer(); } @Override public final Builder blobArg(SdkBytes blobArg) { this.blobArg = StandardMemberCopier.copy(blobArg); return this; } public final void setBlobArg(ByteBuffer blobArg) { blobArg(blobArg == null ? null : SdkBytes.fromByteBuffer(blobArg)); } public final StructWithNestedBlobType.Builder getStructWithNestedBlob() { return structWithNestedBlob != null ? structWithNestedBlob.toBuilder() : null; } @Override public final Builder structWithNestedBlob(StructWithNestedBlobType structWithNestedBlob) { this.structWithNestedBlob = structWithNestedBlob; return this; } public final void setStructWithNestedBlob(StructWithNestedBlobType.BuilderImpl structWithNestedBlob) { this.structWithNestedBlob = structWithNestedBlob != null ? structWithNestedBlob.build() : null; } public final Map<String, ByteBuffer> getBlobMap() { return blobMap == null ? null : blobMap.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue().asByteBuffer())); } @Override public final Builder blobMap(Map<String, SdkBytes> blobMap) { this.blobMap = BlobMapTypeCopier.copy(blobMap); return this; } public final void setBlobMap(Map<String, ByteBuffer> blobMap) { blobMap(blobMap == null ? null : blobMap.entrySet().stream() .collect(Collectors.toMap(e -> e.getKey(), e -> SdkBytes.fromByteBuffer(e.getValue())))); } public final List<ByteBuffer> getListOfBlobs() { return listOfBlobs == null ? null : listOfBlobs.stream().map(SdkBytes::asByteBuffer).collect(Collectors.toList()); } @Override public final Builder listOfBlobs(Collection<SdkBytes> listOfBlobs) { this.listOfBlobs = ListOfBlobsTypeCopier.copy(listOfBlobs); return this; } @Override @SafeVarargs public final Builder listOfBlobs(SdkBytes... listOfBlobs) { listOfBlobs(Arrays.asList(listOfBlobs)); return this; } public final void setListOfBlobs(Collection<ByteBuffer> listOfBlobs) { listOfBlobs(listOfBlobs == null ? null : listOfBlobs.stream().map(SdkBytes::fromByteBuffer) .collect(Collectors.toList())); } public final RecursiveStructType.Builder getRecursiveStruct() { return recursiveStruct != null ? recursiveStruct.toBuilder() : null; } @Override public final Builder recursiveStruct(RecursiveStructType recursiveStruct) { this.recursiveStruct = recursiveStruct; return this; } public final void setRecursiveStruct(RecursiveStructType.BuilderImpl recursiveStruct) { this.recursiveStruct = recursiveStruct != null ? recursiveStruct.build() : null; } public final BaseType.Builder getPolymorphicTypeWithSubTypes() { return polymorphicTypeWithSubTypes != null ? polymorphicTypeWithSubTypes.toBuilder() : null; } @Override public final Builder polymorphicTypeWithSubTypes(BaseType polymorphicTypeWithSubTypes) { this.polymorphicTypeWithSubTypes = polymorphicTypeWithSubTypes; return this; } public final void setPolymorphicTypeWithSubTypes(BaseType.BuilderImpl polymorphicTypeWithSubTypes) { this.polymorphicTypeWithSubTypes = polymorphicTypeWithSubTypes != null ? polymorphicTypeWithSubTypes.build() : null; } public final SubTypeOne.Builder getPolymorphicTypeWithoutSubTypes() { return polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.toBuilder() : null; } @Override public final Builder polymorphicTypeWithoutSubTypes(SubTypeOne polymorphicTypeWithoutSubTypes) { this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes; return this; } public final void setPolymorphicTypeWithoutSubTypes(SubTypeOne.BuilderImpl polymorphicTypeWithoutSubTypes) { this.polymorphicTypeWithoutSubTypes = polymorphicTypeWithoutSubTypes != null ? polymorphicTypeWithoutSubTypes.build() : null; } public final String getEnumType() { return enumType; } @Override public final Builder enumType(String enumType) { this.enumType = enumType; return this; } @Override public final Builder enumType(EnumType enumType) { this.enumType(enumType == null ? null : enumType.toString()); return this; } public final void setEnumType(String enumType) { this.enumType = enumType; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer<AwsRequestOverrideConfiguration.Builder> builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public AllTypesRequest build() { return new AllTypesRequest(this); } @Override public List<SdkField<?>> sdkFields() { return SDK_FIELDS; } } }
3,213
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/rules/endpoint-resolve-interceptor.java
package software.amazon.awssdk.services.query.endpoints.internal; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletionException; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.AwsExecutionAttribute; import software.amazon.awssdk.awscore.endpoints.AwsEndpointAttribute; import software.amazon.awssdk.awscore.endpoints.authscheme.EndpointAuthScheme; import software.amazon.awssdk.awscore.endpoints.authscheme.SigV4AuthScheme; import software.amazon.awssdk.awscore.endpoints.authscheme.SigV4aAuthScheme; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.SelectedAuthScheme; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.interceptor.Context; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.SdkHttpRequest; import software.amazon.awssdk.http.auth.aws.signer.AwsV4HttpSigner; import software.amazon.awssdk.http.auth.aws.signer.AwsV4aHttpSigner; import software.amazon.awssdk.http.auth.aws.signer.RegionSet; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.identity.spi.Identity; import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams; import software.amazon.awssdk.services.query.endpoints.QueryEndpointParams; import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest; import software.amazon.awssdk.utils.AttributeMap; @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public final class QueryResolveEndpointInterceptor implements ExecutionInterceptor { @Override public SdkRequest modifyRequest(Context.ModifyRequest context, ExecutionAttributes executionAttributes) { SdkRequest result = context.request(); if (AwsEndpointProviderUtils.endpointIsDiscovered(executionAttributes)) { return result; } QueryEndpointProvider provider = (QueryEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { Endpoint endpoint = provider.resolveEndpoint(ruleParams(result, executionAttributes)).join(); if (!AwsEndpointProviderUtils.disableHostPrefixInjection(executionAttributes)) { Optional<String> hostPrefix = hostPrefix(executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME), result); if (hostPrefix.isPresent()) { endpoint = AwsEndpointProviderUtils.addHostPrefix(endpoint, hostPrefix.get()); } } List<EndpointAuthScheme> endpointAuthSchemes = endpoint.attribute(AwsEndpointAttribute.AUTH_SCHEMES); SelectedAuthScheme<?> selectedAuthScheme = executionAttributes .getAttribute(SdkInternalExecutionAttribute.SELECTED_AUTH_SCHEME); if (endpointAuthSchemes != null && selectedAuthScheme != null) { selectedAuthScheme = authSchemeWithEndpointSignerProperties(endpointAuthSchemes, selectedAuthScheme); executionAttributes.putAttribute(SdkInternalExecutionAttribute.SELECTED_AUTH_SCHEME, selectedAuthScheme); } executionAttributes.putAttribute(SdkInternalExecutionAttribute.RESOLVED_ENDPOINT, endpoint); return result; } catch (CompletionException e) { Throwable cause = e.getCause(); if (cause instanceof SdkClientException) { throw (SdkClientException) cause; } else { throw SdkClientException.create("Endpoint resolution failed", cause); } } } @Override public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) { Endpoint resolvedEndpoint = executionAttributes.getAttribute(SdkInternalExecutionAttribute.RESOLVED_ENDPOINT); if (resolvedEndpoint.headers().isEmpty()) { return context.httpRequest(); } SdkHttpRequest.Builder httpRequestBuilder = context.httpRequest().toBuilder(); resolvedEndpoint.headers().forEach((name, values) -> { values.forEach(v -> httpRequestBuilder.appendHeader(name, v)); }); return httpRequestBuilder.build(); } public static QueryEndpointParams ruleParams(SdkRequest request, ExecutionAttributes executionAttributes) { QueryEndpointParams.Builder builder = QueryEndpointParams.builder(); builder.region(AwsEndpointProviderUtils.regionBuiltIn(executionAttributes)); builder.useDualStackEndpoint(AwsEndpointProviderUtils.dualStackEnabledBuiltIn(executionAttributes)); builder.useFipsEndpoint(AwsEndpointProviderUtils.fipsEnabledBuiltIn(executionAttributes)); setClientContextParams(builder, executionAttributes); setContextParams(builder, executionAttributes.getAttribute(AwsExecutionAttribute.OPERATION_NAME), request); setStaticContextParams(builder, executionAttributes.getAttribute(AwsExecutionAttribute.OPERATION_NAME)); return builder.build(); } private static void setContextParams(QueryEndpointParams.Builder params, String operationName, SdkRequest request) { switch (operationName) { case "OperationWithContextParam": setContextParams(params, (OperationWithContextParamRequest) request); break; default: break; } } private static void setContextParams(QueryEndpointParams.Builder params, OperationWithContextParamRequest request) { params.operationContextParam(request.stringMember()); } private static void setStaticContextParams(QueryEndpointParams.Builder params, String operationName) { switch (operationName) { case "OperationWithStaticContextParams": operationWithStaticContextParamsStaticContextParams(params); break; default: break; } } private static void operationWithStaticContextParamsStaticContextParams(QueryEndpointParams.Builder params) { params.staticStringParam("hello"); } private <T extends Identity> SelectedAuthScheme<T> authSchemeWithEndpointSignerProperties( List<EndpointAuthScheme> endpointAuthSchemes, SelectedAuthScheme<T> selectedAuthScheme) { for (EndpointAuthScheme endpointAuthScheme : endpointAuthSchemes) { if (!endpointAuthScheme.schemeId().equals(selectedAuthScheme.authSchemeOption().schemeId())) { continue; } AuthSchemeOption.Builder option = selectedAuthScheme.authSchemeOption().toBuilder(); if (endpointAuthScheme instanceof SigV4AuthScheme) { SigV4AuthScheme v4AuthScheme = (SigV4AuthScheme) endpointAuthScheme; if (v4AuthScheme.isDisableDoubleEncodingSet()) { option.putSignerProperty(AwsV4HttpSigner.DOUBLE_URL_ENCODE, !v4AuthScheme.disableDoubleEncoding()); } if (v4AuthScheme.signingRegion() != null) { option.putSignerProperty(AwsV4HttpSigner.REGION_NAME, v4AuthScheme.signingRegion()); } if (v4AuthScheme.signingName() != null) { option.putSignerProperty(AwsV4HttpSigner.SERVICE_SIGNING_NAME, v4AuthScheme.signingName()); } return new SelectedAuthScheme<>(selectedAuthScheme.identity(), selectedAuthScheme.signer(), option.build()); } if (endpointAuthScheme instanceof SigV4aAuthScheme) { SigV4aAuthScheme v4aAuthScheme = (SigV4aAuthScheme) endpointAuthScheme; if (v4aAuthScheme.isDisableDoubleEncodingSet()) { option.putSignerProperty(AwsV4aHttpSigner.DOUBLE_URL_ENCODE, !v4aAuthScheme.disableDoubleEncoding()); } if (v4aAuthScheme.signingRegionSet() != null) { RegionSet regionSet = RegionSet.create(v4aAuthScheme.signingRegionSet()); option.putSignerProperty(AwsV4aHttpSigner.REGION_SET, regionSet); } if (v4aAuthScheme.signingName() != null) { option.putSignerProperty(AwsV4aHttpSigner.SERVICE_SIGNING_NAME, v4aAuthScheme.signingName()); } return new SelectedAuthScheme<>(selectedAuthScheme.identity(), selectedAuthScheme.signer(), option.build()); } throw new IllegalArgumentException("Endpoint auth scheme '" + endpointAuthScheme.name() + "' cannot be mapped to the SDK auth scheme. Was it declared in the service's model?"); } return selectedAuthScheme; } private static void setClientContextParams(QueryEndpointParams.Builder params, ExecutionAttributes executionAttributes) { AttributeMap clientContextParams = executionAttributes.getAttribute(SdkInternalExecutionAttribute.CLIENT_CONTEXT_PARAMS); Optional.ofNullable(clientContextParams.get(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM)).ifPresent( params::booleanContextParam); Optional.ofNullable(clientContextParams.get(QueryClientContextParams.STRING_CONTEXT_PARAM)).ifPresent( params::stringContextParam); } private static Optional<String> hostPrefix(String operationName, SdkRequest request) { switch (operationName) { case "APostOperation": { return Optional.of("foo-"); } default: return Optional.empty(); } } }
3,214
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/rules/endpoint-resolve-interceptor-preSra.java
package software.amazon.awssdk.services.query.endpoints.internal; import java.util.List; import java.util.Optional; import java.util.concurrent.CompletionException; import java.util.function.Supplier; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.signer.Aws4Signer; import software.amazon.awssdk.auth.signer.SignerLoader; import software.amazon.awssdk.awscore.AwsExecutionAttribute; import software.amazon.awssdk.awscore.endpoints.AwsEndpointAttribute; import software.amazon.awssdk.awscore.endpoints.authscheme.EndpointAuthScheme; import software.amazon.awssdk.awscore.endpoints.authscheme.SigV4AuthScheme; import software.amazon.awssdk.awscore.endpoints.authscheme.SigV4aAuthScheme; import software.amazon.awssdk.awscore.util.SignerOverrideUtils; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.SelectedAuthScheme; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.interceptor.Context; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.SdkHttpRequest; import software.amazon.awssdk.http.auth.aws.signer.AwsV4HttpSigner; import software.amazon.awssdk.http.auth.aws.signer.AwsV4aHttpSigner; import software.amazon.awssdk.http.auth.aws.signer.RegionSet; import software.amazon.awssdk.http.auth.spi.scheme.AuthSchemeOption; import software.amazon.awssdk.identity.spi.Identity; import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams; import software.amazon.awssdk.services.query.endpoints.QueryEndpointParams; import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest; import software.amazon.awssdk.utils.AttributeMap; @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public final class QueryResolveEndpointInterceptor implements ExecutionInterceptor { @Override public SdkRequest modifyRequest(Context.ModifyRequest context, ExecutionAttributes executionAttributes) { SdkRequest result = context.request(); if (AwsEndpointProviderUtils.endpointIsDiscovered(executionAttributes)) { return result; } QueryEndpointProvider provider = (QueryEndpointProvider) executionAttributes .getAttribute(SdkInternalExecutionAttribute.ENDPOINT_PROVIDER); try { Endpoint endpoint = provider.resolveEndpoint(ruleParams(result, executionAttributes)).join(); if (!AwsEndpointProviderUtils.disableHostPrefixInjection(executionAttributes)) { Optional<String> hostPrefix = hostPrefix(executionAttributes.getAttribute(SdkExecutionAttribute.OPERATION_NAME), result); if (hostPrefix.isPresent()) { endpoint = AwsEndpointProviderUtils.addHostPrefix(endpoint, hostPrefix.get()); } } List<EndpointAuthScheme> endpointAuthSchemes = endpoint.attribute(AwsEndpointAttribute.AUTH_SCHEMES); SelectedAuthScheme<?> selectedAuthScheme = executionAttributes .getAttribute(SdkInternalExecutionAttribute.SELECTED_AUTH_SCHEME); if (endpointAuthSchemes != null && selectedAuthScheme != null) { selectedAuthScheme = authSchemeWithEndpointSignerProperties(endpointAuthSchemes, selectedAuthScheme); executionAttributes.putAttribute(SdkInternalExecutionAttribute.SELECTED_AUTH_SCHEME, selectedAuthScheme); } if (endpointAuthSchemes != null) { EndpointAuthScheme chosenAuthScheme = AuthSchemeUtils.chooseAuthScheme(endpointAuthSchemes); Supplier<Signer> signerProvider = signerProvider(chosenAuthScheme); result = SignerOverrideUtils.overrideSignerIfNotOverridden(result, executionAttributes, signerProvider); } executionAttributes.putAttribute(SdkInternalExecutionAttribute.RESOLVED_ENDPOINT, endpoint); return result; } catch (CompletionException e) { Throwable cause = e.getCause(); if (cause instanceof SdkClientException) { throw (SdkClientException) cause; } else { throw SdkClientException.create("Endpoint resolution failed", cause); } } } @Override public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) { Endpoint resolvedEndpoint = executionAttributes.getAttribute(SdkInternalExecutionAttribute.RESOLVED_ENDPOINT); if (resolvedEndpoint.headers().isEmpty()) { return context.httpRequest(); } SdkHttpRequest.Builder httpRequestBuilder = context.httpRequest().toBuilder(); resolvedEndpoint.headers().forEach((name, values) -> { values.forEach(v -> httpRequestBuilder.appendHeader(name, v)); }); return httpRequestBuilder.build(); } public static QueryEndpointParams ruleParams(SdkRequest request, ExecutionAttributes executionAttributes) { QueryEndpointParams.Builder builder = QueryEndpointParams.builder(); builder.region(AwsEndpointProviderUtils.regionBuiltIn(executionAttributes)); builder.useDualStackEndpoint(AwsEndpointProviderUtils.dualStackEnabledBuiltIn(executionAttributes)); builder.useFipsEndpoint(AwsEndpointProviderUtils.fipsEnabledBuiltIn(executionAttributes)); setClientContextParams(builder, executionAttributes); setContextParams(builder, executionAttributes.getAttribute(AwsExecutionAttribute.OPERATION_NAME), request); setStaticContextParams(builder, executionAttributes.getAttribute(AwsExecutionAttribute.OPERATION_NAME)); return builder.build(); } private static void setContextParams(QueryEndpointParams.Builder params, String operationName, SdkRequest request) { switch (operationName) { case "OperationWithContextParam": setContextParams(params, (OperationWithContextParamRequest) request); break; default: break; } } private static void setContextParams(QueryEndpointParams.Builder params, OperationWithContextParamRequest request) { params.operationContextParam(request.stringMember()); } private static void setStaticContextParams(QueryEndpointParams.Builder params, String operationName) { switch (operationName) { case "OperationWithStaticContextParams": operationWithStaticContextParamsStaticContextParams(params); break; default: break; } } private static void operationWithStaticContextParamsStaticContextParams(QueryEndpointParams.Builder params) { params.staticStringParam("hello"); } private <T extends Identity> SelectedAuthScheme<T> authSchemeWithEndpointSignerProperties( List<EndpointAuthScheme> endpointAuthSchemes, SelectedAuthScheme<T> selectedAuthScheme) { for (EndpointAuthScheme endpointAuthScheme : endpointAuthSchemes) { AuthSchemeOption.Builder option = selectedAuthScheme.authSchemeOption().toBuilder(); if (endpointAuthScheme instanceof SigV4AuthScheme) { SigV4AuthScheme v4AuthScheme = (SigV4AuthScheme) endpointAuthScheme; if (v4AuthScheme.isDisableDoubleEncodingSet()) { option.putSignerProperty(AwsV4HttpSigner.DOUBLE_URL_ENCODE, !v4AuthScheme.disableDoubleEncoding()); } if (v4AuthScheme.signingRegion() != null) { option.putSignerProperty(AwsV4HttpSigner.REGION_NAME, v4AuthScheme.signingRegion()); } if (v4AuthScheme.signingName() != null) { option.putSignerProperty(AwsV4HttpSigner.SERVICE_SIGNING_NAME, v4AuthScheme.signingName()); } return new SelectedAuthScheme<>(selectedAuthScheme.identity(), selectedAuthScheme.signer(), option.build()); } if (endpointAuthScheme instanceof SigV4aAuthScheme) { SigV4aAuthScheme v4aAuthScheme = (SigV4aAuthScheme) endpointAuthScheme; if (v4aAuthScheme.isDisableDoubleEncodingSet()) { option.putSignerProperty(AwsV4aHttpSigner.DOUBLE_URL_ENCODE, !v4aAuthScheme.disableDoubleEncoding()); } if (v4aAuthScheme.signingRegionSet() != null) { RegionSet regionSet = RegionSet.create(v4aAuthScheme.signingRegionSet()); option.putSignerProperty(AwsV4aHttpSigner.REGION_SET, regionSet); } if (v4aAuthScheme.signingName() != null) { option.putSignerProperty(AwsV4aHttpSigner.SERVICE_SIGNING_NAME, v4aAuthScheme.signingName()); } return new SelectedAuthScheme<>(selectedAuthScheme.identity(), selectedAuthScheme.signer(), option.build()); } throw new IllegalArgumentException("Endpoint auth scheme '" + endpointAuthScheme.name() + "' cannot be mapped to the SDK auth scheme. Was it declared in the service's model?"); } return selectedAuthScheme; } private static void setClientContextParams(QueryEndpointParams.Builder params, ExecutionAttributes executionAttributes) { AttributeMap clientContextParams = executionAttributes.getAttribute(SdkInternalExecutionAttribute.CLIENT_CONTEXT_PARAMS); Optional.ofNullable(clientContextParams.get(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM)).ifPresent( params::booleanContextParam); Optional.ofNullable(clientContextParams.get(QueryClientContextParams.STRING_CONTEXT_PARAM)).ifPresent( params::stringContextParam); } private static Optional<String> hostPrefix(String operationName, SdkRequest request) { switch (operationName) { case "APostOperation": { return Optional.of("foo-"); } default: return Optional.empty(); } } private Supplier<Signer> signerProvider(EndpointAuthScheme authScheme) { switch (authScheme.name()) { case "sigv4": return Aws4Signer::create; case "sigv4a": return SignerLoader::getSigV4aSigner; default: break; } throw SdkClientException.create("Don't know how to create signer for auth scheme: " + authScheme.name()); } }
3,215
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/rules/endpoint-parameters.java
package software.amazon.awssdk.services.query.endpoints; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.utils.builder.CopyableBuilder; import software.amazon.awssdk.utils.builder.ToCopyableBuilder; /** * The parameters object used to resolve an endpoint for the Query service. */ @Generated("software.amazon.awssdk:codegen") @SdkPublicApi public final class QueryEndpointParams implements ToCopyableBuilder<QueryEndpointParams.Builder, QueryEndpointParams> { private final Region region; private final Boolean useDualStackEndpoint; private final Boolean useFIPSEndpoint; private final String endpointId; private final Boolean defaultTrueParam; private final String defaultStringParam; private final String deprecatedParam; private final Boolean booleanContextParam; private final String stringContextParam; private final String operationContextParam; private QueryEndpointParams(BuilderImpl builder) { this.region = builder.region; this.useDualStackEndpoint = builder.useDualStackEndpoint; this.useFIPSEndpoint = builder.useFIPSEndpoint; this.endpointId = builder.endpointId; this.defaultTrueParam = builder.defaultTrueParam; this.defaultStringParam = builder.defaultStringParam; this.deprecatedParam = builder.deprecatedParam; this.booleanContextParam = builder.booleanContextParam; this.stringContextParam = builder.stringContextParam; this.operationContextParam = builder.operationContextParam; } public static Builder builder() { return new BuilderImpl(); } public Region region() { return region; } public Boolean useDualStackEndpoint() { return useDualStackEndpoint; } public Boolean useFipsEndpoint() { return useFIPSEndpoint; } public String endpointId() { return endpointId; } public Boolean defaultTrueParam() { return defaultTrueParam; } public String defaultStringParam() { return defaultStringParam; } @Deprecated public String deprecatedParam() { return deprecatedParam; } public Boolean booleanContextParam() { return booleanContextParam; } public String stringContextParam() { return stringContextParam; } public String operationContextParam() { return operationContextParam; } public Builder toBuilder() { return new BuilderImpl(this); } public interface Builder extends CopyableBuilder<Builder, QueryEndpointParams> { Builder region(Region region); Builder useDualStackEndpoint(Boolean useDualStackEndpoint); Builder useFipsEndpoint(Boolean useFIPSEndpoint); Builder endpointId(String endpointId); Builder defaultTrueParam(Boolean defaultTrueParam); Builder defaultStringParam(String defaultStringParam); @Deprecated Builder deprecatedParam(String deprecatedParam); Builder booleanContextParam(Boolean booleanContextParam); Builder stringContextParam(String stringContextParam); Builder operationContextParam(String operationContextParam); QueryEndpointParams build(); } private static class BuilderImpl implements Builder { private Region region; private Boolean useDualStackEndpoint; private Boolean useFIPSEndpoint; private String endpointId; private Boolean defaultTrueParam = true; private String defaultStringParam = "hello endpoints"; private String deprecatedParam; private Boolean booleanContextParam; private String stringContextParam; private String operationContextParam; private BuilderImpl() { } private BuilderImpl(QueryEndpointParams builder) { this.region = builder.region; this.useDualStackEndpoint = builder.useDualStackEndpoint; this.useFIPSEndpoint = builder.useFIPSEndpoint; this.endpointId = builder.endpointId; this.defaultTrueParam = builder.defaultTrueParam; this.defaultStringParam = builder.defaultStringParam; this.deprecatedParam = builder.deprecatedParam; this.booleanContextParam = builder.booleanContextParam; this.stringContextParam = builder.stringContextParam; this.operationContextParam = builder.operationContextParam; } @Override public Builder region(Region region) { this.region = region; return this; } @Override public Builder useDualStackEndpoint(Boolean useDualStackEndpoint) { this.useDualStackEndpoint = useDualStackEndpoint; return this; } @Override public Builder useFipsEndpoint(Boolean useFIPSEndpoint) { this.useFIPSEndpoint = useFIPSEndpoint; return this; } @Override public Builder endpointId(String endpointId) { this.endpointId = endpointId; return this; } @Override public Builder defaultTrueParam(Boolean defaultTrueParam) { this.defaultTrueParam = defaultTrueParam; if (this.defaultTrueParam == null) { this.defaultTrueParam = true; } return this; } @Override public Builder defaultStringParam(String defaultStringParam) { this.defaultStringParam = defaultStringParam; if (this.defaultStringParam == null) { this.defaultStringParam = "hello endpoints"; } return this; } @Deprecated @Override public Builder deprecatedParam(String deprecatedParam) { this.deprecatedParam = deprecatedParam; return this; } @Override public Builder booleanContextParam(Boolean booleanContextParam) { this.booleanContextParam = booleanContextParam; return this; } @Override public Builder stringContextParam(String stringContextParam) { this.stringContextParam = stringContextParam; return this; } @Override public Builder operationContextParam(String operationContextParam) { this.operationContextParam = operationContextParam; return this; } @Override public QueryEndpointParams build() { return new QueryEndpointParams(this); } } }
3,216
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/rules/endpoint-provider-class.java
package software.amazon.awssdk.services.query.endpoints.internal; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.concurrent.CompletableFuture; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.services.query.endpoints.QueryEndpointParams; import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.MapUtils; import software.amazon.awssdk.utils.Validate; @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public final class DefaultQueryEndpointProvider implements QueryEndpointProvider { private static final EndpointRuleset ENDPOINT_RULE_SET = ruleSet(); @Override public CompletableFuture<Endpoint> resolveEndpoint(QueryEndpointParams endpointParams) { Validate.notNull(endpointParams.region(), "Parameter 'region' must not be null"); Value res = new DefaultRuleEngine().evaluate(ENDPOINT_RULE_SET, toIdentifierValueMap(endpointParams)); try { return CompletableFuture.completedFuture(AwsEndpointProviderUtils.valueAsEndpointOrThrow(res)); } catch (Exception error) { return CompletableFutureUtils.failedFuture(error); } } private static Map<Identifier, Value> toIdentifierValueMap(QueryEndpointParams params) { Map<Identifier, Value> paramsMap = new HashMap<>(); if (params.region() != null) { paramsMap.put(Identifier.of("region"), Value.fromStr(params.region().id())); } if (params.useDualStackEndpoint() != null) { paramsMap.put(Identifier.of("useDualStackEndpoint"), Value.fromBool(params.useDualStackEndpoint())); } if (params.useFipsEndpoint() != null) { paramsMap.put(Identifier.of("useFIPSEndpoint"), Value.fromBool(params.useFipsEndpoint())); } if (params.endpointId() != null) { paramsMap.put(Identifier.of("endpointId"), Value.fromStr(params.endpointId())); } if (params.defaultTrueParam() != null) { paramsMap.put(Identifier.of("defaultTrueParam"), Value.fromBool(params.defaultTrueParam())); } if (params.defaultStringParam() != null) { paramsMap.put(Identifier.of("defaultStringParam"), Value.fromStr(params.defaultStringParam())); } if (params.deprecatedParam() != null) { paramsMap.put(Identifier.of("deprecatedParam"), Value.fromStr(params.deprecatedParam())); } if (params.booleanContextParam() != null) { paramsMap.put(Identifier.of("booleanContextParam"), Value.fromBool(params.booleanContextParam())); } if (params.stringContextParam() != null) { paramsMap.put(Identifier.of("stringContextParam"), Value.fromStr(params.stringContextParam())); } if (params.operationContextParam() != null) { paramsMap.put(Identifier.of("operationContextParam"), Value.fromStr(params.operationContextParam())); } return paramsMap; } private static Rule endpointRule_2() { return Rule .builder() .addCondition( Condition .builder() .fn(FnNode.builder().fn("isSet").argv(Arrays.asList(Expr.ref(Identifier.of("useFIPSEndpoint")))) .build().validate()).build()) .addCondition( Condition .builder() .fn(FnNode.builder().fn("booleanEquals") .argv(Arrays.asList(Expr.ref(Identifier.of("useFIPSEndpoint")), Expr.of(true))).build() .validate()).build()).error("FIPS endpoints not supported with multi-region endpoints"); } private static Rule endpointRule_3() { return Rule .builder() .addCondition( Condition .builder() .fn(FnNode .builder() .fn("not") .argv(Arrays.asList(FnNode.builder().fn("isSet") .argv(Arrays.asList(Expr.ref(Identifier.of("useFIPSEndpoint")))).build() .validate())).build().validate()).build()) .addCondition( Condition .builder() .fn(FnNode.builder().fn("isSet") .argv(Arrays.asList(Expr.ref(Identifier.of("useDualStackEndpoint")))).build().validate()) .build()) .addCondition( Condition .builder() .fn(FnNode.builder().fn("booleanEquals") .argv(Arrays.asList(Expr.ref(Identifier.of("useDualStackEndpoint")), Expr.of(true))) .build().validate()).build()) .endpoint( EndpointResult .builder() .url(Expr.of("https://{endpointId}.query.{partitionResult#dualStackDnsSuffix}")) .addProperty( Identifier.of("authSchemes"), Literal.fromTuple(Arrays.asList(Literal.fromRecord(MapUtils.of(Identifier.of("name"), Literal.fromStr("sigv4a"), Identifier.of("signingName"), Literal.fromStr("query"), Identifier.of("signingRegionSet"), Literal.fromTuple(Arrays.asList(Literal.fromStr("*")))))))).build()); } private static Rule endpointRule_4() { return Rule.builder() .endpoint( EndpointResult .builder() .url(Expr.of("https://{endpointId}.query.{partitionResult#dnsSuffix}")) .addProperty( Identifier.of("authSchemes"), Literal.fromTuple(Arrays.asList(Literal.fromRecord(MapUtils.of(Identifier.of("name"), Literal.fromStr("sigv4a"), Identifier.of("signingName"), Literal.fromStr("query"), Identifier.of("signingRegionSet"), Literal.fromTuple(Arrays.asList(Literal.fromStr("*")))))))).build()); } private static Rule endpointRule_1() { return Rule .builder() .addCondition( Condition .builder() .fn(FnNode.builder().fn("isSet").argv(Arrays.asList(Expr.ref(Identifier.of("endpointId")))) .build().validate()).build()) .treeRule(Arrays.asList(endpointRule_2(), endpointRule_3(), endpointRule_4())); } private static Rule endpointRule_6() { return Rule .builder() .addCondition( Condition .builder() .fn(FnNode.builder().fn("isSet").argv(Arrays.asList(Expr.ref(Identifier.of("useFIPSEndpoint")))) .build().validate()).build()) .addCondition( Condition .builder() .fn(FnNode.builder().fn("booleanEquals") .argv(Arrays.asList(Expr.ref(Identifier.of("useFIPSEndpoint")), Expr.of(true))).build() .validate()).build()) .addCondition( Condition .builder() .fn(FnNode .builder() .fn("not") .argv(Arrays.asList(FnNode.builder().fn("isSet") .argv(Arrays.asList(Expr.ref(Identifier.of("useDualStackEndpoint")))).build() .validate())).build().validate()).build()) .endpoint( EndpointResult .builder() .url(Expr.of("https://query-fips.{region}.{partitionResult#dnsSuffix}")) .addProperty( Identifier.of("authSchemes"), Literal.fromTuple(Arrays.asList(Literal.fromRecord(MapUtils.of(Identifier.of("name"), Literal.fromStr("sigsigv4a"), Identifier.of("signingName"), Literal.fromStr("query"), Identifier.of("signingRegionSet"), Literal.fromTuple(Arrays.asList(Literal.fromStr("*")))))))).build()); } private static Rule endpointRule_7() { return Rule .builder() .addCondition( Condition .builder() .fn(FnNode.builder().fn("isSet") .argv(Arrays.asList(Expr.ref(Identifier.of("useDualStackEndpoint")))).build().validate()) .build()) .addCondition( Condition .builder() .fn(FnNode.builder().fn("booleanEquals") .argv(Arrays.asList(Expr.ref(Identifier.of("useDualStackEndpoint")), Expr.of(true))) .build().validate()).build()) .addCondition( Condition .builder() .fn(FnNode .builder() .fn("not") .argv(Arrays.asList(FnNode.builder().fn("isSet") .argv(Arrays.asList(Expr.ref(Identifier.of("useFIPSEndpoint")))).build() .validate())).build().validate()).build()) .endpoint( EndpointResult .builder() .url(Expr.of("https://query.{region}.{partitionResult#dualStackDnsSuffix}")) .addProperty( Identifier.of("authSchemes"), Literal.fromTuple(Arrays.asList(Literal.fromRecord(MapUtils.of(Identifier.of("name"), Literal.fromStr("sigv4a"), Identifier.of("signingName"), Literal.fromStr("query"), Identifier.of("signingRegionSet"), Literal.fromTuple(Arrays.asList(Literal.fromStr("*"))))), Literal .fromRecord(MapUtils.of(Identifier.of("name"), Literal.fromStr("sigv4"), Identifier.of("signingName"), Literal.fromStr("query"), Identifier.of("signingRegion"), Literal.fromStr("{region}")))))).build()); } private static Rule endpointRule_8() { return Rule .builder() .addCondition( Condition .builder() .fn(FnNode.builder().fn("isSet") .argv(Arrays.asList(Expr.ref(Identifier.of("useDualStackEndpoint")))).build().validate()) .build()) .addCondition( Condition .builder() .fn(FnNode.builder().fn("isSet").argv(Arrays.asList(Expr.ref(Identifier.of("useFIPSEndpoint")))) .build().validate()).build()) .addCondition( Condition .builder() .fn(FnNode.builder().fn("booleanEquals") .argv(Arrays.asList(Expr.ref(Identifier.of("useDualStackEndpoint")), Expr.of(true))) .build().validate()).build()) .addCondition( Condition .builder() .fn(FnNode.builder().fn("booleanEquals") .argv(Arrays.asList(Expr.ref(Identifier.of("useFIPSEndpoint")), Expr.of(true))).build() .validate()).build()) .endpoint( EndpointResult .builder() .url(Expr.of("https://query-fips.{region}.{partitionResult#dualStackDnsSuffix}")) .addProperty( Identifier.of("authSchemes"), Literal.fromTuple(Arrays.asList(Literal.fromRecord(MapUtils.of(Identifier.of("name"), Literal.fromStr("sigv4a"), Identifier.of("signingName"), Literal.fromStr("query"), Identifier.of("signingRegionSet"), Literal.fromTuple(Arrays.asList(Literal.fromStr("*")))))))).build()); } private static Rule endpointRule_9() { return Rule.builder().endpoint( EndpointResult.builder().url(Expr.of("https://query.{region}.{partitionResult#dnsSuffix}")).build()); } private static Rule endpointRule_5() { return Rule .builder() .addCondition( Condition .builder() .fn(FnNode.builder().fn("isValidHostLabel") .argv(Arrays.asList(Expr.ref(Identifier.of("region")), Expr.of(false))).build() .validate()).build()) .treeRule(Arrays.asList(endpointRule_6(), endpointRule_7(), endpointRule_8(), endpointRule_9())); } private static Rule endpointRule_10() { return Rule.builder().error("{region} is not a valid HTTP host-label"); } private static Rule endpointRule_0() { return Rule .builder() .addCondition( Condition .builder() .fn(FnNode.builder().fn("partition").argv(Arrays.asList(Expr.ref(Identifier.of("region")))) .build().validate()).result("partitionResult").build()) .treeRule(Arrays.asList(endpointRule_1(), endpointRule_5(), endpointRule_10())); } private static EndpointRuleset ruleSet() { return EndpointRuleset .builder() .version("1.2") .serviceId("query") .parameters( Parameters .builder() .addParameter( Parameter.builder().name("region").type(ParameterType.fromValue("string")).required(true) .builtIn("AWS::Region").documentation("The region to send requests to").build()) .addParameter( Parameter.builder().name("useDualStackEndpoint").type(ParameterType.fromValue("boolean")) .required(false).builtIn("AWS::UseDualStack").build()) .addParameter( Parameter.builder().name("useFIPSEndpoint").type(ParameterType.fromValue("boolean")) .required(false).builtIn("AWS::UseFIPS").build()) .addParameter( Parameter.builder().name("endpointId").type(ParameterType.fromValue("string")) .required(false).build()) .addParameter( Parameter.builder().name("defaultTrueParam").type(ParameterType.fromValue("boolean")) .required(false).documentation("A param that defauls to true") .defaultValue(Value.fromBool(true)).build()) .addParameter( Parameter.builder().name("defaultStringParam").type(ParameterType.fromValue("string")) .required(false).defaultValue(Value.fromStr("hello endpoints")).build()) .addParameter( Parameter.builder().name("deprecatedParam").type(ParameterType.fromValue("string")) .required(false).deprecated(new Parameter.Deprecated("Don't use!", "2021-01-01")) .build()) .addParameter( Parameter.builder().name("booleanContextParam").type(ParameterType.fromValue("boolean")) .required(false).build()) .addParameter( Parameter.builder().name("stringContextParam").type(ParameterType.fromValue("string")) .required(false).build()) .addParameter( Parameter.builder().name("operationContextParam").type(ParameterType.fromValue("string")) .required(false).build()).build()).addRule(endpointRule_0()).build(); } @Override public boolean equals(Object rhs) { return rhs != null && getClass().equals(rhs.getClass()); } @Override public int hashCode() { return getClass().hashCode(); } }
3,217
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/rules/request-set-endpoint-interceptor.java
package software.amazon.awssdk.services.query.endpoints.internal; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.interceptor.Context; import software.amazon.awssdk.core.interceptor.ExecutionAttributes; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.interceptor.SdkExecutionAttribute; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.http.SdkHttpRequest; @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public final class QueryRequestSetEndpointInterceptor implements ExecutionInterceptor { @Override public SdkHttpRequest modifyHttpRequest(Context.ModifyHttpRequest context, ExecutionAttributes executionAttributes) { if (AwsEndpointProviderUtils.endpointIsDiscovered(executionAttributes)) { return context.httpRequest(); } Endpoint endpoint = (Endpoint) executionAttributes.getAttribute(SdkInternalExecutionAttribute.RESOLVED_ENDPOINT); return AwsEndpointProviderUtils.setUri(context.httpRequest(), executionAttributes.getAttribute(SdkExecutionAttribute.CLIENT_ENDPOINT), endpoint.url()); } }
3,218
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/rules/endpoint-provider-interface.java
package software.amazon.awssdk.services.query.endpoints; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.endpoints.EndpointProvider; import software.amazon.awssdk.services.query.endpoints.internal.DefaultQueryEndpointProvider; /** * An endpoint provider for Query. The endpoint provider takes a set of parameters using {@link QueryEndpointParams}, * and resolves an {@link Endpoint} base on the given parameters. */ @Generated("software.amazon.awssdk:codegen") @SdkPublicApi public interface QueryEndpointProvider extends EndpointProvider { /** * Compute the endpoint based on the given set of parameters. */ CompletableFuture<Endpoint> resolveEndpoint(QueryEndpointParams endpointParams); /** * Compute the endpoint based on the given set of parameters. */ default CompletableFuture<Endpoint> resolveEndpoint(Consumer<QueryEndpointParams.Builder> endpointParamsConsumer) { QueryEndpointParams.Builder paramsBuilder = QueryEndpointParams.builder(); endpointParamsConsumer.accept(paramsBuilder); return resolveEndpoint(paramsBuilder.build()); } static QueryEndpointProvider defaultProvider() { return new DefaultQueryEndpointProvider(); } }
3,219
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/rules/client-context-params.java
package software.amazon.awssdk.services.query.endpoints; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.utils.AttributeMap; @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public final class QueryClientContextParams<T> extends AttributeMap.Key<T> { /** * A boolean client context parameter */ public static final QueryClientContextParams<Boolean> BOOLEAN_CONTEXT_PARAM = new QueryClientContextParams<>(Boolean.class); /** * a string client context parameter */ public static final QueryClientContextParams<String> STRING_CONTEXT_PARAM = new QueryClientContextParams<>(String.class); private QueryClientContextParams(Class<T> valueClass) { super(valueClass); } }
3,220
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/rules/endpoint-rules-test-class.java
package software.amazon.awssdk.services.query.endpoints; import java.net.URI; import java.util.Arrays; import java.util.List; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.core.rules.testing.AsyncTestCase; import software.amazon.awssdk.core.rules.testing.BaseRuleSetClientTest; import software.amazon.awssdk.core.rules.testing.SyncTestCase; import software.amazon.awssdk.core.rules.testing.model.Expect; import software.amazon.awssdk.endpoints.Endpoint; import software.amazon.awssdk.regions.Region; import software.amazon.awssdk.services.query.QueryAsyncClient; import software.amazon.awssdk.services.query.QueryAsyncClientBuilder; import software.amazon.awssdk.services.query.QueryClient; import software.amazon.awssdk.services.query.QueryClientBuilder; import software.amazon.awssdk.services.query.model.ChecksumStructure; import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest; @Generated("software.amazon.awssdk:codegen") public class QueryClientEndpointTests extends BaseRuleSetClientTest { @BeforeEach public void methodSetup() { super.methodSetup(); } @AfterAll public static void teardown() { } @MethodSource("syncTestCases") @ParameterizedTest public void syncClient_usesCorrectEndpoint(SyncTestCase tc) { runAndVerify(tc); } @MethodSource("asyncTestCases") @ParameterizedTest public void asyncClient_usesCorrectEndpoint(AsyncTestCase tc) { runAndVerify(tc); } private static List<SyncTestCase> syncTestCases() { return Arrays.asList( new SyncTestCase("test case 3", () -> { QueryClientBuilder builder = QueryClient.builder(); builder.credentialsProvider(BaseRuleSetClientTest.CREDENTIALS_PROVIDER); builder.tokenProvider(BaseRuleSetClientTest.TOKEN_PROVIDER); builder.httpClient(getSyncHttpClient()); builder.region(Region.of("us-east-1")); OperationWithContextParamRequest request = OperationWithContextParamRequest.builder() .stringMember("this is a test").build(); builder.build().operationWithContextParam(request); }, Expect.builder().endpoint(Endpoint.builder().url(URI.create("https://myservice.aws")).build()).build()), new SyncTestCase("test case 4", () -> { QueryClientBuilder builder = QueryClient.builder(); builder.credentialsProvider(BaseRuleSetClientTest.CREDENTIALS_PROVIDER); builder.tokenProvider(BaseRuleSetClientTest.TOKEN_PROVIDER); builder.httpClient(getSyncHttpClient()); builder.region(Region.of("us-east-6")); OperationWithContextParamRequest request = OperationWithContextParamRequest.builder() .stringMember("this is a test").build(); builder.build().operationWithContextParam(request); }, Expect.builder().endpoint(Endpoint.builder().url(URI.create("https://myservice.aws")).build()).build(), "Does not work"), new SyncTestCase("Has complex operation input", () -> { QueryClientBuilder builder = QueryClient.builder(); builder.credentialsProvider(BaseRuleSetClientTest.CREDENTIALS_PROVIDER); builder.tokenProvider(BaseRuleSetClientTest.TOKEN_PROVIDER); builder.httpClient(getSyncHttpClient()); OperationWithContextParamRequest request = OperationWithContextParamRequest.builder() .nestedMember(ChecksumStructure.builder().checksumMode("foo").build()).build(); builder.build().operationWithContextParam(request); }, Expect.builder().error("Missing info").build())); } private static List<AsyncTestCase> asyncTestCases() { return Arrays.asList( new AsyncTestCase("test case 3", () -> { QueryAsyncClientBuilder builder = QueryAsyncClient.builder(); builder.credentialsProvider(BaseRuleSetClientTest.CREDENTIALS_PROVIDER); builder.tokenProvider(BaseRuleSetClientTest.TOKEN_PROVIDER); builder.httpClient(getAsyncHttpClient()); builder.region(Region.of("us-east-1")); OperationWithContextParamRequest request = OperationWithContextParamRequest.builder() .stringMember("this is a test").build(); return builder.build().operationWithContextParam(request); }, Expect.builder().endpoint(Endpoint.builder().url(URI.create("https://myservice.aws")).build()).build()), new AsyncTestCase("test case 4", () -> { QueryAsyncClientBuilder builder = QueryAsyncClient.builder(); builder.credentialsProvider(BaseRuleSetClientTest.CREDENTIALS_PROVIDER); builder.tokenProvider(BaseRuleSetClientTest.TOKEN_PROVIDER); builder.httpClient(getAsyncHttpClient()); builder.region(Region.of("us-east-6")); OperationWithContextParamRequest request = OperationWithContextParamRequest.builder() .stringMember("this is a test").build(); return builder.build().operationWithContextParam(request); }, Expect.builder().endpoint(Endpoint.builder().url(URI.create("https://myservice.aws")).build()).build(), "Does not work"), new AsyncTestCase("Has complex operation input", () -> { QueryAsyncClientBuilder builder = QueryAsyncClient.builder(); builder.credentialsProvider(BaseRuleSetClientTest.CREDENTIALS_PROVIDER); builder.tokenProvider(BaseRuleSetClientTest.TOKEN_PROVIDER); builder.httpClient(getAsyncHttpClient()); OperationWithContextParamRequest request = OperationWithContextParamRequest.builder() .nestedMember(ChecksumStructure.builder().checksumMode("foo").build()).build(); return builder.build().operationWithContextParam(request); }, Expect.builder().error("Missing info").build())); } }
3,221
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-client-builder-class.java
package software.amazon.awssdk.services.json; import java.util.ArrayList; import java.util.List; import software.amazon.MyServiceHttpConfig; import software.amazon.MyServiceRetryPolicy; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.signer.Aws4Signer; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.codegen.poet.plugins.InternalTestPlugin1; import software.amazon.awssdk.codegen.poet.plugins.InternalTestPlugin2; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.endpoints.JsonClientContextParams; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor; import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.AttributeMap; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { @Override protected final String serviceEndpointPrefix() { return "json-service-endpoint"; } @Override protected final String serviceName() { return "Json"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkAdvancedClientOption.SIGNER, defaultSigner()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .option(SdkClientOption.SERVICE_CONFIGURATION, ServiceConfiguration.builder().build()) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()) .option(SdkAdvancedClientOption.TOKEN_SIGNER, defaultTokenSigner())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new JsonResolveEndpointInterceptor()); endpointInterceptors.add(new JsonRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/json/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); ServiceConfiguration.Builder serviceConfigBuilder = ((ServiceConfiguration) config .option(SdkClientOption.SERVICE_CONFIGURATION)).toBuilder(); serviceConfigBuilder.profileFile(serviceConfigBuilder.profileFileSupplier() != null ? serviceConfigBuilder .profileFileSupplier() : config.option(SdkClientOption.PROFILE_FILE_SUPPLIER)); serviceConfigBuilder.profileName(serviceConfigBuilder.profileName() != null ? serviceConfigBuilder.profileName() : config .option(SdkClientOption.PROFILE_NAME)); if (serviceConfigBuilder.dualstackEnabled() != null) { Validate.validState( config.option(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED) == null, "Dualstack has been configured on both ServiceConfiguration and the client/global level. Please limit dualstack configuration to one location."); } else { serviceConfigBuilder.dualstackEnabled(config.option(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED)); } if (serviceConfigBuilder.fipsModeEnabled() != null) { Validate.validState( config.option(AwsClientOption.FIPS_ENDPOINT_ENABLED) == null, "Fips has been configured on both ServiceConfiguration and the client/global level. Please limit fips configuration to one location."); } else { serviceConfigBuilder.fipsModeEnabled(config.option(AwsClientOption.FIPS_ENDPOINT_ENABLED)); } if (serviceConfigBuilder.useArnRegionEnabled() != null) { Validate.validState( clientContextParams.get(JsonClientContextParams.USE_ARN_REGION) == null, "UseArnRegion has been configured on both ServiceConfiguration and the client/global level. Please limit UseArnRegion configuration to one location."); } else { serviceConfigBuilder.useArnRegionEnabled(clientContextParams.get(JsonClientContextParams.USE_ARN_REGION)); } if (serviceConfigBuilder.multiRegionEnabled() != null) { Validate.validState( clientContextParams.get(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS) == null, "DisableMultiRegionAccessPoints has been configured on both ServiceConfiguration and the client/global level. Please limit DisableMultiRegionAccessPoints configuration to one location."); } else if (clientContextParams.get(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS) != null) { serviceConfigBuilder.multiRegionEnabled(!clientContextParams .get(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS)); } if (serviceConfigBuilder.pathStyleAccessEnabled() != null) { Validate.validState( clientContextParams.get(JsonClientContextParams.FORCE_PATH_STYLE) == null, "ForcePathStyle has been configured on both ServiceConfiguration and the client/global level. Please limit ForcePathStyle configuration to one location."); } else { serviceConfigBuilder.pathStyleAccessEnabled(clientContextParams.get(JsonClientContextParams.FORCE_PATH_STYLE)); } if (serviceConfigBuilder.accelerateModeEnabled() != null) { Validate.validState( clientContextParams.get(JsonClientContextParams.ACCELERATE) == null, "Accelerate has been configured on both ServiceConfiguration and the client/global level. Please limit Accelerate configuration to one location."); } else { serviceConfigBuilder.accelerateModeEnabled(clientContextParams.get(JsonClientContextParams.ACCELERATE)); } ServiceConfiguration finalServiceConfig = serviceConfigBuilder.build(); clientContextParams.put(JsonClientContextParams.USE_ARN_REGION, finalServiceConfig.useArnRegionEnabled()); clientContextParams.put(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS, !finalServiceConfig.multiRegionEnabled()); clientContextParams.put(JsonClientContextParams.FORCE_PATH_STYLE, finalServiceConfig.pathStyleAccessEnabled()); clientContextParams.put(JsonClientContextParams.ACCELERATE, finalServiceConfig.accelerateModeEnabled()); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors) .option(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED, finalServiceConfig.dualstackEnabled()) .option(AwsClientOption.FIPS_ENDPOINT_ENABLED, finalServiceConfig.fipsModeEnabled()) .option(SdkClientOption.RETRY_POLICY, MyServiceRetryPolicy.resolveRetryPolicy(config)) .option(SdkClientOption.SERVICE_CONFIGURATION, finalServiceConfig); return builder.build(); } private Signer defaultSigner() { return Aws4Signer.create(); } @Override protected final String signingName() { return "json-service"; } private JsonEndpointProvider defaultEndpointProvider() { return JsonEndpointProvider.defaultProvider(); } public B serviceConfiguration(ServiceConfiguration serviceConfiguration) { clientConfiguration.option(SdkClientOption.SERVICE_CONFIGURATION, serviceConfiguration); return thisBuilder(); } public void setServiceConfiguration(ServiceConfiguration serviceConfiguration) { serviceConfiguration(serviceConfiguration); } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } private Signer defaultTokenSigner() { return BearerTokenSigner.create(); } @Override protected final AttributeMap serviceHttpConfig() { AttributeMap result = MyServiceHttpConfig.defaultHttpConfig(); return result; } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { List<SdkPlugin> internalPlugins = new ArrayList<>(); internalPlugins.add(new InternalTestPlugin1()); internalPlugins.add(new InternalTestPlugin2()); return internalPlugins; } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER), "The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder."); Validate.notNull(c.option(SdkAdvancedClientOption.TOKEN_SIGNER), "The 'overrideConfiguration.advancedOption[TOKEN_SIGNER]' must be configured in the client builder."); Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,222
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-composed-sync-default-client-builder.java
package software.amazon.awssdk.services.json; import java.util.ArrayList; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.signer.Aws4Signer; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.endpoints.JsonClientContextParams; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor; import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { @Override protected final String serviceEndpointPrefix() { return "json-service-endpoint"; } @Override protected final String serviceName() { return "Json"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkAdvancedClientOption.SIGNER, defaultSigner()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .option(SdkClientOption.SERVICE_CONFIGURATION, ServiceConfiguration.builder().build()) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()) .option(SdkAdvancedClientOption.TOKEN_SIGNER, defaultTokenSigner())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new JsonResolveEndpointInterceptor()); endpointInterceptors.add(new JsonRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/json/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); ServiceConfiguration.Builder serviceConfigBuilder = ((ServiceConfiguration) config .option(SdkClientOption.SERVICE_CONFIGURATION)).toBuilder(); serviceConfigBuilder.profileFile(serviceConfigBuilder.profileFileSupplier() != null ? serviceConfigBuilder .profileFileSupplier() : config.option(SdkClientOption.PROFILE_FILE_SUPPLIER)); serviceConfigBuilder.profileName(serviceConfigBuilder.profileName() != null ? serviceConfigBuilder.profileName() : config .option(SdkClientOption.PROFILE_NAME)); ServiceConfiguration finalServiceConfig = serviceConfigBuilder.build(); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.SERVICE_CONFIGURATION, finalServiceConfig); return builder.build(); } private Signer defaultSigner() { return Aws4Signer.create(); } @Override protected final String signingName() { return "json-service"; } private JsonEndpointProvider defaultEndpointProvider() { return JsonEndpointProvider.defaultProvider(); } public B customParameter(Boolean customParameter) { clientContextParams.put(JsonClientContextParams.CUSTOM_PARAMETER, customParameter); return thisBuilder(); } public B serviceConfiguration(ServiceConfiguration serviceConfiguration) { clientConfiguration.option(SdkClientOption.SERVICE_CONFIGURATION, serviceConfiguration); return thisBuilder(); } public void setServiceConfiguration(ServiceConfiguration serviceConfiguration) { serviceConfiguration(serviceConfiguration); } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } private Signer defaultTokenSigner() { return BearerTokenSigner.create(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER), "The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder."); Validate.notNull(c.option(SdkAdvancedClientOption.TOKEN_SIGNER), "The 'overrideConfiguration.advancedOption[TOKEN_SIGNER]' must be configured in the client builder."); Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,223
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-composed-sync-client-builder-class.java
package software.amazon.awssdk.services.json; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.builder.SyncClientDecorator; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; /** * Internal implementation of {@link JsonClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonClientBuilder extends DefaultJsonBaseClientBuilder<JsonClientBuilder, JsonClient> implements JsonClientBuilder { @Override public DefaultJsonClientBuilder endpointProvider(JsonEndpointProvider endpointProvider) { clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider); return this; } @Override public DefaultJsonClientBuilder tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) { clientConfiguration.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, tokenProvider); return this; } @Override protected final JsonClient buildClient() { SdkClientConfiguration clientConfiguration = super.syncClientConfiguration(); this.validateClientOptions(clientConfiguration); JsonClient client = new DefaultJsonClient(clientConfiguration); return new SyncClientDecorator().decorate(client, clientConfiguration, clientContextParams.copy().build()); } }
3,224
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-no-auth-service-client-builder-class.java
package software.amazon.awssdk.services.database; import java.util.ArrayList; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.services.database.endpoints.DatabaseEndpointProvider; import software.amazon.awssdk.services.database.endpoints.internal.DatabaseRequestSetEndpointInterceptor; import software.amazon.awssdk.services.database.endpoints.internal.DatabaseResolveEndpointInterceptor; import software.amazon.awssdk.services.database.internal.DatabaseServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; /** * Internal base class for {@link DefaultDatabaseClientBuilder} and {@link DefaultDatabaseAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultDatabaseBaseClientBuilder<B extends DatabaseBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { @Override protected final String serviceEndpointPrefix() { return "database-service-endpoint"; } @Override protected final String serviceName() { return "Database"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()).option( SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new DatabaseResolveEndpointInterceptor()); endpointInterceptors.add(new DatabaseRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/database/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors); return builder.build(); } @Override protected final String signingName() { return "database-service"; } private DatabaseEndpointProvider defaultEndpointProvider() { return DatabaseEndpointProvider.defaultProvider(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); DatabaseServiceClientConfigurationBuilder serviceConfigBuilder = new DatabaseServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { } }
3,225
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-sync-client-builder-class.java
package software.amazon.awssdk.services.json; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; /** * Internal implementation of {@link JsonClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonClientBuilder extends DefaultJsonBaseClientBuilder<JsonClientBuilder, JsonClient> implements JsonClientBuilder { @Override public DefaultJsonClientBuilder endpointProvider(JsonEndpointProvider endpointProvider) { clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider); return this; } @Override public DefaultJsonClientBuilder tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) { clientConfiguration.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, tokenProvider); return this; } @Override protected final JsonClient buildClient() { SdkClientConfiguration clientConfiguration = super.syncClientConfiguration(); this.validateClientOptions(clientConfiguration); JsonClient client = new DefaultJsonClient(clientConfiguration); return client; } }
3,226
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-sync-client-builder-interface.java
/* * Copyright 2010-2017 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.json; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.awscore.client.builder.AwsSyncClientBuilder; /** * A builder for creating an instance of {@link JsonClient}. This can be created with the static * {@link JsonClient#builder()} method. */ @Generated("software.amazon.awssdk:codegen") public interface JsonClientBuilder extends AwsSyncClientBuilder<JsonClientBuilder, JsonClient>, JsonBaseClientBuilder<JsonClientBuilder, JsonClient> { }
3,227
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-customcontextparams-sync-client-builder-class.java
package software.amazon.awssdk.services.json; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider; import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; /** * This includes configuration specific to Json Service that is supported by both {@link JsonClientBuilder} and * {@link JsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkPublicApi public interface JsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsClientBuilder<B, C> { B serviceConfiguration(ServiceConfiguration serviceConfiguration); default B serviceConfiguration(Consumer<ServiceConfiguration.Builder> serviceConfiguration) { return serviceConfiguration(ServiceConfiguration.builder().applyMutation(serviceConfiguration).build()); } /** * Set the {@link JsonEndpointProvider} implementation that will be used by the client to determine the endpoint for * each request. This is optional; if none is provided a default implementation will be used the SDK. */ default B endpointProvider(JsonEndpointProvider endpointProvider) { throw new UnsupportedOperationException(); } /** * Set the {@link JsonAuthSchemeProvider} implementation that will be used by the client to resolve the auth scheme * for each request. This is optional; if none is provided a default implementation will be used the SDK. */ default B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) { throw new UnsupportedOperationException(); } /** * Enables this client to use Custom Parameter */ B customParameter(Boolean customParameter); /** * Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will * use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}. * <p> * If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this * token provider to retrieve the token to use for authorization. * <p> * This provider works in conjunction with the * {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By * default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}. */ default B tokenProvider(SdkTokenProvider tokenProvider) { return tokenProvider((IdentityProvider<? extends TokenIdentity>) tokenProvider); } /** * Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will * use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}. * <p> * If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this * token provider to retrieve the token to use for authorization. * <p> * This provider works in conjunction with the * {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By * default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}. */ default B tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) { throw new UnsupportedOperationException(); } }
3,228
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-query-async-client-builder-class.java
package software.amazon.awssdk.services.query; import java.net.URI; import java.util.ArrayList; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.codegen.internal.QueryProtocolCustomTestInterceptor; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.endpoints.EndpointProvider; import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; import software.amazon.awssdk.utils.CollectionUtils; /** * Internal implementation of {@link QueryAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultQueryAsyncClientBuilder extends DefaultQueryBaseClientBuilder<QueryAsyncClientBuilder, QueryAsyncClient> implements QueryAsyncClientBuilder { @Override public DefaultQueryAsyncClientBuilder endpointProvider(QueryEndpointProvider endpointProvider) { clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider); return this; } @Override public DefaultQueryAsyncClientBuilder tokenProvider(SdkTokenProvider tokenProvider) { clientConfiguration.option(AwsClientOption.TOKEN_PROVIDER, tokenProvider); return this; } @Override protected final QueryAsyncClient buildClient() { SdkClientConfiguration clientConfiguration = super.asyncClientConfiguration(); this.validateClientOptions(clientConfiguration); QueryServiceClientConfiguration serviceClientConfiguration = initializeServiceClientConfig(clientConfiguration); List<ExecutionInterceptor> interceptors = clientConfiguration.option(SdkClientOption.EXECUTION_INTERCEPTORS); List<ExecutionInterceptor> customizationInterceptors = new ArrayList<>(); customizationInterceptors.add(new QueryProtocolCustomTestInterceptor()); interceptors = CollectionUtils.mergeLists(customizationInterceptors, interceptors); clientConfiguration = clientConfiguration.toBuilder().option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors) .build(); QueryAsyncClient client = new DefaultQueryAsyncClient(serviceClientConfiguration, clientConfiguration); return client; } private QueryServiceClientConfiguration initializeServiceClientConfig(SdkClientConfiguration clientConfig) { URI endpointOverride = null; EndpointProvider endpointProvider = clientConfig.option(SdkClientOption.ENDPOINT_PROVIDER); if (clientConfig.option(SdkClientOption.ENDPOINT_OVERRIDDEN) != null && Boolean.TRUE.equals(clientConfig.option(SdkClientOption.ENDPOINT_OVERRIDDEN))) { endpointOverride = clientConfig.option(SdkClientOption.ENDPOINT); } return QueryServiceClientConfiguration.builder().overrideConfiguration(overrideConfiguration()) .region(clientConfig.option(AwsClientOption.AWS_REGION)).endpointOverride(endpointOverride) .endpointProvider(endpointProvider).build(); } }
3,229
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-async-client-builder-interface.java
/* * Copyright 2010-2017 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.json; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.awscore.client.builder.AwsAsyncClientBuilder; /** * A builder for creating an instance of {@link JsonAsyncClient}. This can be created with the static * {@link JsonAsyncClient#builder()} method. */ @Generated("software.amazon.awssdk:codegen") public interface JsonAsyncClientBuilder extends AwsAsyncClientBuilder<JsonAsyncClientBuilder, JsonAsyncClient>, JsonBaseClientBuilder<JsonAsyncClientBuilder, JsonAsyncClient> { }
3,230
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-composed-async-client-builder-class.java
package software.amazon.awssdk.services.json; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.builder.AsyncClientDecorator; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; /** * Internal implementation of {@link JsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonAsyncClientBuilder extends DefaultJsonBaseClientBuilder<JsonAsyncClientBuilder, JsonAsyncClient> implements JsonAsyncClientBuilder { @Override public DefaultJsonAsyncClientBuilder endpointProvider(JsonEndpointProvider endpointProvider) { clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider); return this; } @Override public DefaultJsonAsyncClientBuilder tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) { clientConfiguration.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, tokenProvider); return this; } @Override protected final JsonAsyncClient buildClient() { SdkClientConfiguration clientConfiguration = super.asyncClientConfiguration(); this.validateClientOptions(clientConfiguration); JsonAsyncClient client = new DefaultJsonAsyncClient(clientConfiguration); return new AsyncClientDecorator().decorate(client, clientConfiguration, clientContextParams.copy().build()); } }
3,231
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-client-builder-interface.java
package software.amazon.awssdk.services.json; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider; import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; /** * This includes configuration specific to Json Service that is supported by both {@link JsonClientBuilder} and * {@link JsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkPublicApi public interface JsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsClientBuilder<B, C> { B serviceConfiguration(ServiceConfiguration serviceConfiguration); default B serviceConfiguration(Consumer<ServiceConfiguration.Builder> serviceConfiguration) { return serviceConfiguration(ServiceConfiguration.builder().applyMutation(serviceConfiguration).build()); } /** * Set the {@link JsonEndpointProvider} implementation that will be used by the client to determine the endpoint for * each request. This is optional; if none is provided a default implementation will be used the SDK. */ default B endpointProvider(JsonEndpointProvider endpointProvider) { throw new UnsupportedOperationException(); } /** * Set the {@link JsonAuthSchemeProvider} implementation that will be used by the client to resolve the auth scheme for * each request. This is optional; if none is provided a default implementation will be used the SDK. */ default B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) { throw new UnsupportedOperationException(); } /** * Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will * use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}. * <p> * If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this * token provider to retrieve the token to use for authorization. * <p> * This provider works in conjunction with the * {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By * default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}. */ default B tokenProvider(SdkTokenProvider tokenProvider) { return tokenProvider((IdentityProvider<? extends TokenIdentity>) tokenProvider); } /** * Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will * use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}. * <p> * If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this * token provider to retrieve the token to use for authorization. * <p> * This provider works in conjunction with the * {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By * default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}. */ default B tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) { throw new UnsupportedOperationException(); } }
3,232
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-client-builder-internal-defaults-class.java
package software.amazon.awssdk.services.json; import java.util.ArrayList; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.signer.Aws4Signer; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor; import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { @Override protected final String serviceEndpointPrefix() { return "json-service-endpoint"; } @Override protected final String serviceName() { return "Json"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkAdvancedClientOption.SIGNER, defaultSigner()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)); } @Override protected final SdkClientConfiguration mergeInternalDefaults(SdkClientConfiguration config) { return config.merge(c -> { c.option(SdkClientOption.INTERNAL_USER_AGENT, "md/foobar"); c.option(SdkClientOption.DEFAULT_RETRY_MODE, RetryMode.STANDARD); }); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new JsonResolveEndpointInterceptor()); endpointInterceptors.add(new JsonRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/json/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors); return builder.build(); } private Signer defaultSigner() { return Aws4Signer.create(); } @Override protected final String signingName() { return "json-service"; } private JsonEndpointProvider defaultEndpointProvider() { return JsonEndpointProvider.defaultProvider(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER), "The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder."); } }
3,233
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-no-auth-ops-client-builder-class.java
package software.amazon.awssdk.services.database; import java.util.ArrayList; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.signer.Aws4Signer; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.services.database.endpoints.DatabaseEndpointProvider; import software.amazon.awssdk.services.database.endpoints.internal.DatabaseRequestSetEndpointInterceptor; import software.amazon.awssdk.services.database.endpoints.internal.DatabaseResolveEndpointInterceptor; import software.amazon.awssdk.services.database.internal.DatabaseServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultDatabaseClientBuilder} and {@link DefaultDatabaseAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultDatabaseBaseClientBuilder<B extends DatabaseBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { @Override protected final String serviceEndpointPrefix() { return "database-service-endpoint"; } @Override protected final String serviceName() { return "Database"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkAdvancedClientOption.SIGNER, defaultSigner()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new DatabaseResolveEndpointInterceptor()); endpointInterceptors.add(new DatabaseRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/database/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors); return builder.build(); } private Signer defaultSigner() { return Aws4Signer.create(); } @Override protected final String signingName() { return "database-service"; } private DatabaseEndpointProvider defaultEndpointProvider() { return DatabaseEndpointProvider.defaultProvider(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); DatabaseServiceClientConfigurationBuilder serviceConfigBuilder = new DatabaseServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER), "The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder."); } }
3,234
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-bearer-auth-client-builder-interface.java
package software.amazon.awssdk.services.json; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.auth.token.credentials.SdkTokenProvider; import software.amazon.awssdk.awscore.client.builder.AwsClientBuilder; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; /** * This includes configuration specific to Json Service that is supported by both {@link JsonClientBuilder} and * {@link JsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkPublicApi public interface JsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsClientBuilder<B, C> { /** * Set the {@link JsonEndpointProvider} implementation that will be used by the client to determine the endpoint for * each request. This is optional; if none is provided a default implementation will be used the SDK. */ default B endpointProvider(JsonEndpointProvider endpointProvider) { throw new UnsupportedOperationException(); } /** * Set the {@link JsonAuthSchemeProvider} implementation that will be used by the client to resolve the auth scheme for * each request. This is optional; if none is provided a default implementation will be used the SDK. */ default B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) { throw new UnsupportedOperationException(); } /** * Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will * use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}. * <p> * If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this * token provider to retrieve the token to use for authorization. * <p> * This provider works in conjunction with the * {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By * default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}. */ default B tokenProvider(SdkTokenProvider tokenProvider) { return tokenProvider((IdentityProvider<? extends TokenIdentity>) tokenProvider); } /** * Set the token provider to use for bearer token authorization. This is optional, if none is provided, the SDK will * use {@link software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider}. * <p> * If the service, or any of its operations require Bearer Token Authorization, then the SDK will default to this * token provider to retrieve the token to use for authorization. * <p> * This provider works in conjunction with the * {@code software.amazon.awssdk.core.client.config.SdkAdvancedClientOption.TOKEN_SIGNER} set on the client. By * default it is {@link software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner}. */ default B tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) { throw new UnsupportedOperationException(); } }
3,235
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-bearer-auth-client-builder-class.java
package software.amazon.awssdk.services.json; import java.util.ArrayList; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor; import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { @Override protected final String serviceEndpointPrefix() { return "json-service-endpoint"; } @Override protected final String serviceName() { return "Json"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()) .option(SdkAdvancedClientOption.TOKEN_SIGNER, defaultTokenSigner())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new JsonResolveEndpointInterceptor()); endpointInterceptors.add(new JsonRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/json/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors); return builder.build(); } @Override protected final String signingName() { return "json-service"; } private JsonEndpointProvider defaultEndpointProvider() { return JsonEndpointProvider.defaultProvider(); } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } private Signer defaultTokenSigner() { return BearerTokenSigner.create(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(SdkAdvancedClientOption.TOKEN_SIGNER), "The 'overrideConfiguration.advancedOption[TOKEN_SIGNER]' must be configured in the client builder."); Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,236
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-query-client-builder-class.java
package software.amazon.awssdk.services.query; import java.util.ArrayList; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.signer.Aws4Signer; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams; import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; import software.amazon.awssdk.services.query.endpoints.internal.QueryRequestSetEndpointInterceptor; import software.amazon.awssdk.services.query.endpoints.internal.QueryResolveEndpointInterceptor; import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultQueryClientBuilder} and {@link DefaultQueryAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultQueryBaseClientBuilder<B extends QueryBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { @Override protected final String serviceEndpointPrefix() { return "query-service"; } @Override protected final String serviceName() { return "Query"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkAdvancedClientOption.SIGNER, defaultSigner()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()) .option(SdkAdvancedClientOption.TOKEN_SIGNER, defaultTokenSigner())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new QueryResolveEndpointInterceptor()); endpointInterceptors.add(new QueryRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/query/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.CLIENT_CONTEXT_PARAMS, clientContextParams.build()); return builder.build(); } private Signer defaultSigner() { return Aws4Signer.create(); } @Override protected final String signingName() { return "query-service"; } private QueryEndpointProvider defaultEndpointProvider() { return QueryEndpointProvider.defaultProvider(); } public B booleanContextParam(Boolean booleanContextParam) { clientContextParams.put(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM, booleanContextParam); return thisBuilder(); } public B stringContextParam(String stringContextParam) { clientContextParams.put(QueryClientContextParams.STRING_CONTEXT_PARAM, stringContextParam); return thisBuilder(); } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } private Signer defaultTokenSigner() { return BearerTokenSigner.create(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER), "The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder."); Validate.notNull(c.option(SdkAdvancedClientOption.TOKEN_SIGNER), "The 'overrideConfiguration.advancedOption[TOKEN_SIGNER]' must be configured in the client builder."); Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,237
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-async-client-builder-class.java
package software.amazon.awssdk.services.json; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; /** * Internal implementation of {@link JsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonAsyncClientBuilder extends DefaultJsonBaseClientBuilder<JsonAsyncClientBuilder, JsonAsyncClient> implements JsonAsyncClientBuilder { @Override public DefaultJsonAsyncClientBuilder endpointProvider(JsonEndpointProvider endpointProvider) { clientConfiguration.option(SdkClientOption.ENDPOINT_PROVIDER, endpointProvider); return this; } @Override public DefaultJsonAsyncClientBuilder tokenProvider(IdentityProvider<? extends TokenIdentity> tokenProvider) { clientConfiguration.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, tokenProvider); return this; } @Override protected final JsonAsyncClient buildClient() { SdkClientConfiguration clientConfiguration = super.asyncClientConfiguration(); this.validateClientOptions(clientConfiguration); JsonAsyncClient client = new DefaultJsonAsyncClient(clientConfiguration); return client; } }
3,238
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/test-client-builder-endpoints-auth-params.java
package software.amazon.awssdk.services.query; import java.util.ArrayList; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.signer.Aws4Signer; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkAdvancedClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams; import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; import software.amazon.awssdk.services.query.endpoints.internal.QueryRequestSetEndpointInterceptor; import software.amazon.awssdk.services.query.endpoints.internal.QueryResolveEndpointInterceptor; import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultQueryClientBuilder} and {@link DefaultQueryAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultQueryBaseClientBuilder<B extends QueryBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { @Override protected final String serviceEndpointPrefix() { return "query-service"; } @Override protected final String serviceName() { return "Query"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkAdvancedClientOption.SIGNER, defaultSigner()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider()) .option(SdkAdvancedClientOption.TOKEN_SIGNER, defaultTokenSigner())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new QueryResolveEndpointInterceptor()); endpointInterceptors.add(new QueryRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/query/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.CLIENT_CONTEXT_PARAMS, clientContextParams.build()); return builder.build(); } private Signer defaultSigner() { return Aws4Signer.create(); } @Override protected final String signingName() { return "query-service"; } private QueryEndpointProvider defaultEndpointProvider() { return QueryEndpointProvider.defaultProvider(); } public B booleanContextParam(Boolean booleanContextParam) { clientContextParams.put(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM, booleanContextParam); return thisBuilder(); } public B stringContextParam(String stringContextParam) { clientContextParams.put(QueryClientContextParams.STRING_CONTEXT_PARAM, stringContextParam); return thisBuilder(); } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } private Signer defaultTokenSigner() { return BearerTokenSigner.create(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(SdkAdvancedClientOption.SIGNER), "The 'overrideConfiguration.advancedOption[SIGNER]' must be configured in the client builder."); Validate.notNull(c.option(SdkAdvancedClientOption.TOKEN_SIGNER), "The 'overrideConfiguration.advancedOption[TOKEN_SIGNER]' must be configured in the client builder."); Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,239
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-client-builder-class.java
package software.amazon.awssdk.services.json; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import software.amazon.MyServiceHttpConfig; import software.amazon.MyServiceRetryPolicy; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.codegen.poet.plugins.InternalTestPlugin1; import software.amazon.awssdk.codegen.poet.plugins.InternalTestPlugin2; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme; import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme; import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme; import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider; import software.amazon.awssdk.services.json.auth.scheme.internal.JsonAuthSchemeInterceptor; import software.amazon.awssdk.services.json.endpoints.JsonClientContextParams; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor; import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.AttributeMap; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>(); @Override protected final String serviceEndpointPrefix() { return "json-service-endpoint"; } @Override protected final String serviceName() { return "Json"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider()) .option(SdkClientOption.AUTH_SCHEMES, authSchemes()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .option(SdkClientOption.SERVICE_CONFIGURATION, ServiceConfiguration.builder().build()) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new JsonAuthSchemeInterceptor()); endpointInterceptors.add(new JsonResolveEndpointInterceptor()); endpointInterceptors.add(new JsonRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/json/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); ServiceConfiguration.Builder serviceConfigBuilder = ((ServiceConfiguration) config .option(SdkClientOption.SERVICE_CONFIGURATION)).toBuilder(); serviceConfigBuilder.profileFile(serviceConfigBuilder.profileFileSupplier() != null ? serviceConfigBuilder .profileFileSupplier() : config.option(SdkClientOption.PROFILE_FILE_SUPPLIER)); serviceConfigBuilder.profileName(serviceConfigBuilder.profileName() != null ? serviceConfigBuilder.profileName() : config .option(SdkClientOption.PROFILE_NAME)); if (serviceConfigBuilder.dualstackEnabled() != null) { Validate.validState( config.option(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED) == null, "Dualstack has been configured on both ServiceConfiguration and the client/global level. Please limit dualstack configuration to one location."); } else { serviceConfigBuilder.dualstackEnabled(config.option(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED)); } if (serviceConfigBuilder.fipsModeEnabled() != null) { Validate.validState( config.option(AwsClientOption.FIPS_ENDPOINT_ENABLED) == null, "Fips has been configured on both ServiceConfiguration and the client/global level. Please limit fips configuration to one location."); } else { serviceConfigBuilder.fipsModeEnabled(config.option(AwsClientOption.FIPS_ENDPOINT_ENABLED)); } if (serviceConfigBuilder.useArnRegionEnabled() != null) { Validate.validState( clientContextParams.get(JsonClientContextParams.USE_ARN_REGION) == null, "UseArnRegion has been configured on both ServiceConfiguration and the client/global level. Please limit UseArnRegion configuration to one location."); } else { serviceConfigBuilder.useArnRegionEnabled(clientContextParams.get(JsonClientContextParams.USE_ARN_REGION)); } if (serviceConfigBuilder.multiRegionEnabled() != null) { Validate.validState( clientContextParams.get(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS) == null, "DisableMultiRegionAccessPoints has been configured on both ServiceConfiguration and the client/global level. Please limit DisableMultiRegionAccessPoints configuration to one location."); } else if (clientContextParams.get(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS) != null) { serviceConfigBuilder.multiRegionEnabled(!clientContextParams .get(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS)); } if (serviceConfigBuilder.pathStyleAccessEnabled() != null) { Validate.validState( clientContextParams.get(JsonClientContextParams.FORCE_PATH_STYLE) == null, "ForcePathStyle has been configured on both ServiceConfiguration and the client/global level. Please limit ForcePathStyle configuration to one location."); } else { serviceConfigBuilder.pathStyleAccessEnabled(clientContextParams.get(JsonClientContextParams.FORCE_PATH_STYLE)); } if (serviceConfigBuilder.accelerateModeEnabled() != null) { Validate.validState( clientContextParams.get(JsonClientContextParams.ACCELERATE) == null, "Accelerate has been configured on both ServiceConfiguration and the client/global level. Please limit Accelerate configuration to one location."); } else { serviceConfigBuilder.accelerateModeEnabled(clientContextParams.get(JsonClientContextParams.ACCELERATE)); } ServiceConfiguration finalServiceConfig = serviceConfigBuilder.build(); clientContextParams.put(JsonClientContextParams.USE_ARN_REGION, finalServiceConfig.useArnRegionEnabled()); clientContextParams.put(JsonClientContextParams.DISABLE_MULTI_REGION_ACCESS_POINTS, !finalServiceConfig.multiRegionEnabled()); clientContextParams.put(JsonClientContextParams.FORCE_PATH_STYLE, finalServiceConfig.pathStyleAccessEnabled()); clientContextParams.put(JsonClientContextParams.ACCELERATE, finalServiceConfig.accelerateModeEnabled()); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors) .option(AwsClientOption.DUALSTACK_ENDPOINT_ENABLED, finalServiceConfig.dualstackEnabled()) .option(AwsClientOption.FIPS_ENDPOINT_ENABLED, finalServiceConfig.fipsModeEnabled()) .option(SdkClientOption.RETRY_POLICY, MyServiceRetryPolicy.resolveRetryPolicy(config)) .option(SdkClientOption.SERVICE_CONFIGURATION, finalServiceConfig); return builder.build(); } @Override protected final String signingName() { return "json-service"; } private JsonEndpointProvider defaultEndpointProvider() { return JsonEndpointProvider.defaultProvider(); } public B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) { clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider); return thisBuilder(); } private JsonAuthSchemeProvider defaultAuthSchemeProvider() { return JsonAuthSchemeProvider.defaultProvider(); } @Override public B putAuthScheme(AuthScheme<?> authScheme) { additionalAuthSchemes.put(authScheme.schemeId(), authScheme); return thisBuilder(); } private Map<String, AuthScheme<?>> authSchemes() { Map<String, AuthScheme<?>> schemes = new HashMap<>(3 + this.additionalAuthSchemes.size()); AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create(); schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme); BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create(); schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme); NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create(); schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme); schemes.putAll(this.additionalAuthSchemes); return schemes; } public B serviceConfiguration(ServiceConfiguration serviceConfiguration) { clientConfiguration.option(SdkClientOption.SERVICE_CONFIGURATION, serviceConfiguration); return thisBuilder(); } public void setServiceConfiguration(ServiceConfiguration serviceConfiguration) { serviceConfiguration(serviceConfiguration); } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } @Override protected final AttributeMap serviceHttpConfig() { AttributeMap result = MyServiceHttpConfig.defaultHttpConfig(); return result; } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { List<SdkPlugin> internalPlugins = new ArrayList<>(); internalPlugins.add(new InternalTestPlugin1()); internalPlugins.add(new InternalTestPlugin2()); return internalPlugins; } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,240
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-composed-sync-default-client-builder.java
package software.amazon.awssdk.services.json; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme; import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme; import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme; import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider; import software.amazon.awssdk.services.json.auth.scheme.internal.JsonAuthSchemeInterceptor; import software.amazon.awssdk.services.json.endpoints.JsonClientContextParams; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor; import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>(); @Override protected final String serviceEndpointPrefix() { return "json-service-endpoint"; } @Override protected final String serviceName() { return "Json"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider()) .option(SdkClientOption.AUTH_SCHEMES, authSchemes()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .option(SdkClientOption.SERVICE_CONFIGURATION, ServiceConfiguration.builder().build()) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new JsonAuthSchemeInterceptor()); endpointInterceptors.add(new JsonResolveEndpointInterceptor()); endpointInterceptors.add(new JsonRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/json/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); ServiceConfiguration.Builder serviceConfigBuilder = ((ServiceConfiguration) config .option(SdkClientOption.SERVICE_CONFIGURATION)).toBuilder(); serviceConfigBuilder.profileFile(serviceConfigBuilder.profileFileSupplier() != null ? serviceConfigBuilder .profileFileSupplier() : config.option(SdkClientOption.PROFILE_FILE_SUPPLIER)); serviceConfigBuilder.profileName(serviceConfigBuilder.profileName() != null ? serviceConfigBuilder.profileName() : config .option(SdkClientOption.PROFILE_NAME)); ServiceConfiguration finalServiceConfig = serviceConfigBuilder.build(); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.SERVICE_CONFIGURATION, finalServiceConfig); return builder.build(); } @Override protected final String signingName() { return "json-service"; } private JsonEndpointProvider defaultEndpointProvider() { return JsonEndpointProvider.defaultProvider(); } public B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) { clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider); return thisBuilder(); } private JsonAuthSchemeProvider defaultAuthSchemeProvider() { return JsonAuthSchemeProvider.defaultProvider(); } @Override public B putAuthScheme(AuthScheme<?> authScheme) { additionalAuthSchemes.put(authScheme.schemeId(), authScheme); return thisBuilder(); } private Map<String, AuthScheme<?>> authSchemes() { Map<String, AuthScheme<?>> schemes = new HashMap<>(3 + this.additionalAuthSchemes.size()); AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create(); schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme); BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create(); schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme); NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create(); schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme); schemes.putAll(this.additionalAuthSchemes); return schemes; } public B customParameter(Boolean customParameter) { clientContextParams.put(JsonClientContextParams.CUSTOM_PARAMETER, customParameter); return thisBuilder(); } public B serviceConfiguration(ServiceConfiguration serviceConfiguration) { clientConfiguration.option(SdkClientOption.SERVICE_CONFIGURATION, serviceConfiguration); return thisBuilder(); } public void setServiceConfiguration(ServiceConfiguration serviceConfiguration) { serviceConfiguration(serviceConfiguration); } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,241
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-no-auth-service-client-builder-class.java
package software.amazon.awssdk.services.database; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme; import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.services.database.auth.scheme.DatabaseAuthSchemeProvider; import software.amazon.awssdk.services.database.auth.scheme.internal.DatabaseAuthSchemeInterceptor; import software.amazon.awssdk.services.database.endpoints.DatabaseEndpointProvider; import software.amazon.awssdk.services.database.endpoints.internal.DatabaseRequestSetEndpointInterceptor; import software.amazon.awssdk.services.database.endpoints.internal.DatabaseResolveEndpointInterceptor; import software.amazon.awssdk.services.database.internal.DatabaseServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; /** * Internal base class for {@link DefaultDatabaseClientBuilder} and {@link DefaultDatabaseAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultDatabaseBaseClientBuilder<B extends DatabaseBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>(); @Override protected final String serviceEndpointPrefix() { return "database-service-endpoint"; } @Override protected final String serviceName() { return "Database"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider()) .option(SdkClientOption.AUTH_SCHEMES, authSchemes()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new DatabaseAuthSchemeInterceptor()); endpointInterceptors.add(new DatabaseResolveEndpointInterceptor()); endpointInterceptors.add(new DatabaseRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/database/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors); return builder.build(); } @Override protected final String signingName() { return "database-service"; } private DatabaseEndpointProvider defaultEndpointProvider() { return DatabaseEndpointProvider.defaultProvider(); } public B authSchemeProvider(DatabaseAuthSchemeProvider authSchemeProvider) { clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider); return thisBuilder(); } private DatabaseAuthSchemeProvider defaultAuthSchemeProvider() { return DatabaseAuthSchemeProvider.defaultProvider(); } @Override public B putAuthScheme(AuthScheme<?> authScheme) { additionalAuthSchemes.put(authScheme.schemeId(), authScheme); return thisBuilder(); } private Map<String, AuthScheme<?>> authSchemes() { Map<String, AuthScheme<?>> schemes = new HashMap<>(1 + this.additionalAuthSchemes.size()); NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create(); schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme); schemes.putAll(this.additionalAuthSchemes); return schemes; } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); DatabaseServiceClientConfigurationBuilder serviceConfigBuilder = new DatabaseServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { } }
3,242
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-client-builder-internal-defaults-class.java
package software.amazon.awssdk.services.json; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.core.retry.RetryMode; import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme; import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme; import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider; import software.amazon.awssdk.services.json.auth.scheme.internal.JsonAuthSchemeInterceptor; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor; import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; /** * Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>(); @Override protected final String serviceEndpointPrefix() { return "json-service-endpoint"; } @Override protected final String serviceName() { return "Json"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider()) .option(SdkClientOption.AUTH_SCHEMES, authSchemes()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)); } @Override protected final SdkClientConfiguration mergeInternalDefaults(SdkClientConfiguration config) { return config.merge(c -> { c.option(SdkClientOption.INTERNAL_USER_AGENT, "md/foobar"); c.option(SdkClientOption.DEFAULT_RETRY_MODE, RetryMode.STANDARD); }); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new JsonAuthSchemeInterceptor()); endpointInterceptors.add(new JsonResolveEndpointInterceptor()); endpointInterceptors.add(new JsonRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/json/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors); return builder.build(); } @Override protected final String signingName() { return "json-service"; } private JsonEndpointProvider defaultEndpointProvider() { return JsonEndpointProvider.defaultProvider(); } public B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) { clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider); return thisBuilder(); } private JsonAuthSchemeProvider defaultAuthSchemeProvider() { return JsonAuthSchemeProvider.defaultProvider(); } @Override public B putAuthScheme(AuthScheme<?> authScheme) { additionalAuthSchemes.put(authScheme.schemeId(), authScheme); return thisBuilder(); } private Map<String, AuthScheme<?>> authSchemes() { Map<String, AuthScheme<?>> schemes = new HashMap<>(2 + this.additionalAuthSchemes.size()); AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create(); schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme); NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create(); schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme); schemes.putAll(this.additionalAuthSchemes); return schemes; } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { } }
3,243
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-no-auth-ops-client-builder-class.java
package software.amazon.awssdk.services.database; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme; import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme; import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme; import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.services.database.auth.scheme.DatabaseAuthSchemeProvider; import software.amazon.awssdk.services.database.auth.scheme.internal.DatabaseAuthSchemeInterceptor; import software.amazon.awssdk.services.database.endpoints.DatabaseEndpointProvider; import software.amazon.awssdk.services.database.endpoints.internal.DatabaseRequestSetEndpointInterceptor; import software.amazon.awssdk.services.database.endpoints.internal.DatabaseResolveEndpointInterceptor; import software.amazon.awssdk.services.database.internal.DatabaseServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; /** * Internal base class for {@link DefaultDatabaseClientBuilder} and {@link DefaultDatabaseAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultDatabaseBaseClientBuilder<B extends DatabaseBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>(); @Override protected final String serviceEndpointPrefix() { return "database-service-endpoint"; } @Override protected final String serviceName() { return "Database"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c.option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider()) .option(SdkClientOption.AUTH_SCHEMES, authSchemes()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false)); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new DatabaseAuthSchemeInterceptor()); endpointInterceptors.add(new DatabaseResolveEndpointInterceptor()); endpointInterceptors.add(new DatabaseRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/database/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors); return builder.build(); } @Override protected final String signingName() { return "database-service"; } private DatabaseEndpointProvider defaultEndpointProvider() { return DatabaseEndpointProvider.defaultProvider(); } public B authSchemeProvider(DatabaseAuthSchemeProvider authSchemeProvider) { clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider); return thisBuilder(); } private DatabaseAuthSchemeProvider defaultAuthSchemeProvider() { return DatabaseAuthSchemeProvider.defaultProvider(); } @Override public B putAuthScheme(AuthScheme<?> authScheme) { additionalAuthSchemes.put(authScheme.schemeId(), authScheme); return thisBuilder(); } private Map<String, AuthScheme<?>> authSchemes() { Map<String, AuthScheme<?>> schemes = new HashMap<>(3 + this.additionalAuthSchemes.size()); AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create(); schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme); BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create(); schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme); NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create(); schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme); schemes.putAll(this.additionalAuthSchemes); return schemes; } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); DatabaseServiceClientConfigurationBuilder serviceConfigBuilder = new DatabaseServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { } }
3,244
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-bearer-auth-client-builder-class.java
package software.amazon.awssdk.services.json; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme; import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme; import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.json.auth.scheme.JsonAuthSchemeProvider; import software.amazon.awssdk.services.json.auth.scheme.internal.JsonAuthSchemeInterceptor; import software.amazon.awssdk.services.json.endpoints.JsonEndpointProvider; import software.amazon.awssdk.services.json.endpoints.internal.JsonRequestSetEndpointInterceptor; import software.amazon.awssdk.services.json.endpoints.internal.JsonResolveEndpointInterceptor; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultJsonClientBuilder} and {@link DefaultJsonAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultJsonBaseClientBuilder<B extends JsonBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>(); @Override protected final String serviceEndpointPrefix() { return "json-service-endpoint"; } @Override protected final String serviceName() { return "Json"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider()) .option(SdkClientOption.AUTH_SCHEMES, authSchemes()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new JsonAuthSchemeInterceptor()); endpointInterceptors.add(new JsonResolveEndpointInterceptor()); endpointInterceptors.add(new JsonRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/json/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors); return builder.build(); } @Override protected final String signingName() { return "json-service"; } private JsonEndpointProvider defaultEndpointProvider() { return JsonEndpointProvider.defaultProvider(); } public B authSchemeProvider(JsonAuthSchemeProvider authSchemeProvider) { clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider); return thisBuilder(); } private JsonAuthSchemeProvider defaultAuthSchemeProvider() { return JsonAuthSchemeProvider.defaultProvider(); } @Override public B putAuthScheme(AuthScheme<?> authScheme) { additionalAuthSchemes.put(authScheme.schemeId(), authScheme); return thisBuilder(); } private Map<String, AuthScheme<?>> authSchemes() { Map<String, AuthScheme<?>> schemes = new HashMap<>(2 + this.additionalAuthSchemes.size()); BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create(); schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme); NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create(); schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme); schemes.putAll(this.additionalAuthSchemes); return schemes; } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,245
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-query-client-builder-class.java
package software.amazon.awssdk.services.query; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme; import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme; import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme; import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.query.auth.scheme.QueryAuthSchemeProvider; import software.amazon.awssdk.services.query.auth.scheme.internal.QueryAuthSchemeInterceptor; import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams; import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; import software.amazon.awssdk.services.query.endpoints.internal.QueryRequestSetEndpointInterceptor; import software.amazon.awssdk.services.query.endpoints.internal.QueryResolveEndpointInterceptor; import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultQueryClientBuilder} and {@link DefaultQueryAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultQueryBaseClientBuilder<B extends QueryBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>(); @Override protected final String serviceEndpointPrefix() { return "query-service"; } @Override protected final String serviceName() { return "Query"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider()) .option(SdkClientOption.AUTH_SCHEMES, authSchemes()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new QueryAuthSchemeInterceptor()); endpointInterceptors.add(new QueryResolveEndpointInterceptor()); endpointInterceptors.add(new QueryRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/query/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.CLIENT_CONTEXT_PARAMS, clientContextParams.build()); return builder.build(); } @Override protected final String signingName() { return "query-service"; } private QueryEndpointProvider defaultEndpointProvider() { return QueryEndpointProvider.defaultProvider(); } public B authSchemeProvider(QueryAuthSchemeProvider authSchemeProvider) { clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider); return thisBuilder(); } private QueryAuthSchemeProvider defaultAuthSchemeProvider() { return QueryAuthSchemeProvider.defaultProvider(); } @Override public B putAuthScheme(AuthScheme<?> authScheme) { additionalAuthSchemes.put(authScheme.schemeId(), authScheme); return thisBuilder(); } private Map<String, AuthScheme<?>> authSchemes() { Map<String, AuthScheme<?>> schemes = new HashMap<>(3 + this.additionalAuthSchemes.size()); AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create(); schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme); BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create(); schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme); NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create(); schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme); schemes.putAll(this.additionalAuthSchemes); return schemes; } public B booleanContextParam(Boolean booleanContextParam) { clientContextParams.put(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM, booleanContextParam); return thisBuilder(); } public B stringContextParam(String stringContextParam) { clientContextParams.put(QueryClientContextParams.STRING_CONTEXT_PARAM, stringContextParam); return thisBuilder(); } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,246
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/builder/sra/test-client-builder-endpoints-auth-params.java
package software.amazon.awssdk.services.query; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.credentials.TokenUtils; import software.amazon.awssdk.auth.token.credentials.aws.DefaultAwsTokenProvider; import software.amazon.awssdk.awscore.client.builder.AwsDefaultClientBuilder; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.interceptor.ClasspathInterceptorChainFactory; import software.amazon.awssdk.core.interceptor.ExecutionInterceptor; import software.amazon.awssdk.http.auth.aws.scheme.AwsV4AuthScheme; import software.amazon.awssdk.http.auth.aws.scheme.AwsV4aAuthScheme; import software.amazon.awssdk.http.auth.scheme.BearerAuthScheme; import software.amazon.awssdk.http.auth.scheme.NoAuthAuthScheme; import software.amazon.awssdk.http.auth.spi.scheme.AuthScheme; import software.amazon.awssdk.identity.spi.IdentityProvider; import software.amazon.awssdk.identity.spi.IdentityProviders; import software.amazon.awssdk.identity.spi.TokenIdentity; import software.amazon.awssdk.services.query.auth.scheme.QueryAuthSchemeProvider; import software.amazon.awssdk.services.query.auth.scheme.internal.QueryAuthSchemeInterceptor; import software.amazon.awssdk.services.query.endpoints.QueryClientContextParams; import software.amazon.awssdk.services.query.endpoints.QueryEndpointProvider; import software.amazon.awssdk.services.query.endpoints.internal.QueryRequestSetEndpointInterceptor; import software.amazon.awssdk.services.query.endpoints.internal.QueryResolveEndpointInterceptor; import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder; import software.amazon.awssdk.utils.CollectionUtils; import software.amazon.awssdk.utils.Validate; /** * Internal base class for {@link DefaultQueryClientBuilder} and {@link DefaultQueryAsyncClientBuilder}. */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi abstract class DefaultQueryBaseClientBuilder<B extends QueryBaseClientBuilder<B, C>, C> extends AwsDefaultClientBuilder<B, C> { private final Map<String, AuthScheme<?>> additionalAuthSchemes = new HashMap<>(); @Override protected final String serviceEndpointPrefix() { return "query-service"; } @Override protected final String serviceName() { return "Query"; } @Override protected final SdkClientConfiguration mergeServiceDefaults(SdkClientConfiguration config) { return config.merge(c -> c .option(SdkClientOption.ENDPOINT_PROVIDER, defaultEndpointProvider()) .option(SdkClientOption.AUTH_SCHEME_PROVIDER, defaultAuthSchemeProvider()) .option(SdkClientOption.AUTH_SCHEMES, authSchemes()) .option(SdkClientOption.CRC32_FROM_COMPRESSED_DATA_ENABLED, false) .lazyOption(AwsClientOption.TOKEN_PROVIDER, p -> TokenUtils.toSdkTokenProvider(p.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER))) .option(AwsClientOption.TOKEN_IDENTITY_PROVIDER, defaultTokenProvider())); } @Override protected final SdkClientConfiguration finalizeServiceConfiguration(SdkClientConfiguration config) { List<ExecutionInterceptor> endpointInterceptors = new ArrayList<>(); endpointInterceptors.add(new QueryAuthSchemeInterceptor()); endpointInterceptors.add(new QueryResolveEndpointInterceptor()); endpointInterceptors.add(new QueryRequestSetEndpointInterceptor()); ClasspathInterceptorChainFactory interceptorFactory = new ClasspathInterceptorChainFactory(); List<ExecutionInterceptor> interceptors = interceptorFactory .getInterceptors("software/amazon/awssdk/services/query/execution.interceptors"); List<ExecutionInterceptor> additionalInterceptors = new ArrayList<>(); interceptors = CollectionUtils.mergeLists(endpointInterceptors, interceptors); interceptors = CollectionUtils.mergeLists(interceptors, additionalInterceptors); interceptors = CollectionUtils.mergeLists(interceptors, config.option(SdkClientOption.EXECUTION_INTERCEPTORS)); SdkClientConfiguration.Builder builder = config.toBuilder(); builder.lazyOption(SdkClientOption.IDENTITY_PROVIDERS, c -> { IdentityProviders.Builder result = IdentityProviders.builder(); IdentityProvider<?> tokenIdentityProvider = c.get(AwsClientOption.TOKEN_IDENTITY_PROVIDER); if (tokenIdentityProvider != null) { result.putIdentityProvider(tokenIdentityProvider); } IdentityProvider<?> credentialsIdentityProvider = c.get(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER); if (credentialsIdentityProvider != null) { result.putIdentityProvider(credentialsIdentityProvider); } return result.build(); }); builder.option(SdkClientOption.EXECUTION_INTERCEPTORS, interceptors).option(SdkClientOption.CLIENT_CONTEXT_PARAMS, clientContextParams.build()); return builder.build(); } @Override protected final String signingName() { return "query-service"; } private QueryEndpointProvider defaultEndpointProvider() { return QueryEndpointProvider.defaultProvider(); } public B authSchemeProvider(QueryAuthSchemeProvider authSchemeProvider) { clientConfiguration.option(SdkClientOption.AUTH_SCHEME_PROVIDER, authSchemeProvider); return thisBuilder(); } private QueryAuthSchemeProvider defaultAuthSchemeProvider() { return QueryAuthSchemeProvider.defaultProvider(); } @Override public B putAuthScheme(AuthScheme<?> authScheme) { additionalAuthSchemes.put(authScheme.schemeId(), authScheme); return thisBuilder(); } private Map<String, AuthScheme<?>> authSchemes() { Map<String, AuthScheme<?>> schemes = new HashMap<>(4 + this.additionalAuthSchemes.size()); AwsV4AuthScheme awsV4AuthScheme = AwsV4AuthScheme.create(); schemes.put(awsV4AuthScheme.schemeId(), awsV4AuthScheme); AwsV4aAuthScheme awsV4aAuthScheme = AwsV4aAuthScheme.create(); schemes.put(awsV4aAuthScheme.schemeId(), awsV4aAuthScheme); BearerAuthScheme bearerAuthScheme = BearerAuthScheme.create(); schemes.put(bearerAuthScheme.schemeId(), bearerAuthScheme); NoAuthAuthScheme noAuthAuthScheme = NoAuthAuthScheme.create(); schemes.put(noAuthAuthScheme.schemeId(), noAuthAuthScheme); schemes.putAll(this.additionalAuthSchemes); return schemes; } public B booleanContextParam(Boolean booleanContextParam) { clientContextParams.put(QueryClientContextParams.BOOLEAN_CONTEXT_PARAM, booleanContextParam); return thisBuilder(); } public B stringContextParam(String stringContextParam) { clientContextParams.put(QueryClientContextParams.STRING_CONTEXT_PARAM, stringContextParam); return thisBuilder(); } private IdentityProvider<? extends TokenIdentity> defaultTokenProvider() { return DefaultAwsTokenProvider.create(); } @Override protected SdkClientConfiguration invokePlugins(SdkClientConfiguration config) { List<SdkPlugin> internalPlugins = internalPlugins(); List<SdkPlugin> externalPlugins = plugins(); if (internalPlugins.isEmpty() && externalPlugins.isEmpty()) { return config; } List<SdkPlugin> plugins = CollectionUtils.mergeLists(internalPlugins, externalPlugins); SdkClientConfiguration.Builder configuration = config.toBuilder(); QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private List<SdkPlugin> internalPlugins() { return Collections.emptyList(); } protected static void validateClientOptions(SdkClientConfiguration c) { Validate.notNull(c.option(AwsClientOption.TOKEN_IDENTITY_PROVIDER), "The 'tokenProvider' must be configured in the client builder."); } }
3,247
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventthreemarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.EventThree; import software.amazon.awssdk.utils.Validate; /** * {@link EventThree} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class EventThreeMarshaller implements Marshaller<EventThree> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(false) .hasPayloadMembers(true).hasImplicitPayloadMembers(true).httpMethod(SdkHttpMethod.GET).hasEvent(true).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public EventThreeMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(EventThree eventThree) { Validate.paramNotNull(eventThree, "eventThree"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(eventThree).toBuilder().putHeader(":message-type", "event") .putHeader(":event-type", eventThree.sdkEventType().toString()) .putHeader(":content-type", protocolFactory.getContentType()).build(); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,248
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventstreamoperationwithonlyinputrequestmarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.EventStreamOperationWithOnlyInputRequest; import software.amazon.awssdk.utils.Validate; /** * {@link EventStreamOperationWithOnlyInputRequest} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class EventStreamOperationWithOnlyInputRequestMarshaller implements Marshaller<EventStreamOperationWithOnlyInputRequest> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder() .requestUri("/2016-03-11/EventStreamOperationWithOnlyInput").httpMethod(SdkHttpMethod.POST) .hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true).hasPayloadMembers(true).hasEventStreamingInput(true) .build(); private final BaseAwsJsonProtocolFactory protocolFactory; public EventStreamOperationWithOnlyInputRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest) { Validate.paramNotNull(eventStreamOperationWithOnlyInputRequest, "eventStreamOperationWithOnlyInputRequest"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(eventStreamOperationWithOnlyInputRequest); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,249
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventtwomarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.EventTwo; import software.amazon.awssdk.utils.Validate; /** * {@link EventTwo} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class EventTwoMarshaller implements Marshaller<EventTwo> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(false) .hasPayloadMembers(true).hasImplicitPayloadMembers(true).httpMethod(SdkHttpMethod.GET).hasEvent(true).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public EventTwoMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(EventTwo eventTwo) { Validate.paramNotNull(eventTwo, "eventTwo"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(eventTwo).toBuilder().putHeader(":message-type", "event") .putHeader(":event-type", eventTwo.sdkEventType().toString()) .putHeader(":content-type", protocolFactory.getContentType()).build(); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,250
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/inputeventtwomarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.InputEventTwo; import software.amazon.awssdk.utils.Validate; /** * {@link InputEventTwo} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class InputEventTwoMarshaller implements Marshaller<InputEventTwo> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(false) .hasPayloadMembers(true).hasImplicitPayloadMembers(true).httpMethod(SdkHttpMethod.GET).hasEvent(true).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public InputEventTwoMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(InputEventTwo inputEventTwo) { Validate.paramNotNull(inputEventTwo, "inputEventTwo"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(inputEventTwo).toBuilder().putHeader(":message-type", "event") .putHeader(":event-type", inputEventTwo.sdkEventType().toString()) .putHeader(":content-type", protocolFactory.getContentType()).build(); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,251
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/inputeventmarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.InputEvent; import software.amazon.awssdk.utils.Validate; /** * {@link InputEvent} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class InputEventMarshaller implements Marshaller<InputEvent> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(true) .hasPayloadMembers(true).hasImplicitPayloadMembers(false).httpMethod(SdkHttpMethod.GET).hasEvent(true).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public InputEventMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(InputEvent inputEvent) { Validate.paramNotNull(inputEvent, "inputEvent"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(inputEvent).toBuilder().putHeader(":message-type", "event") .putHeader(":event-type", inputEvent.sdkEventType().toString()) .putHeader(":content-type", "application/octet-stream").build(); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,252
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/streaminginputoperationrequestmarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.StreamingInputOperationRequest; import software.amazon.awssdk.utils.Validate; /** * {@link StreamingInputOperationRequest} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class StreamingInputOperationRequestMarshaller implements Marshaller<StreamingInputOperationRequest> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder() .requestUri("/2016-03-11/streamingInputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true) .hasImplicitPayloadMembers(false).hasPayloadMembers(true).hasStreamingInput(true).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public StreamingInputOperationRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(StreamingInputOperationRequest streamingInputOperationRequest) { Validate.paramNotNull(streamingInputOperationRequest, "streamingInputOperationRequest"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(streamingInputOperationRequest); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,253
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/operationwithnoinputoroutputrequestmarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.OperationWithNoInputOrOutputRequest; import software.amazon.awssdk.utils.Validate; /** * {@link OperationWithNoInputOrOutputRequest} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class OperationWithNoInputOrOutputRequestMarshaller implements Marshaller<OperationWithNoInputOrOutputRequest> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/") .httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(false) .hasPayloadMembers(false).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public OperationWithNoInputOrOutputRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(OperationWithNoInputOrOutputRequest operationWithNoInputOrOutputRequest) { Validate.paramNotNull(operationWithNoInputOrOutputRequest, "operationWithNoInputOrOutputRequest"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(operationWithNoInputOrOutputRequest); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,254
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventonemarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.EventOne; import software.amazon.awssdk.utils.Validate; /** * {@link EventOne} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class EventOneMarshaller implements Marshaller<EventOne> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().hasExplicitPayloadMember(false) .hasPayloadMembers(true).hasImplicitPayloadMembers(true).httpMethod(SdkHttpMethod.GET).hasEvent(true).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public EventOneMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(EventOne eventOne) { Validate.paramNotNull(eventOne, "eventOne"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(eventOne).toBuilder().putHeader(":message-type", "event") .putHeader(":event-type", eventOne.sdkEventType().toString()) .putHeader(":content-type", protocolFactory.getContentType()).build(); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,255
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/eventstreamoperationrequestmarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.EventStreamOperationRequest; import software.amazon.awssdk.utils.Validate; /** * {@link EventStreamOperationRequest} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class EventStreamOperationRequestMarshaller implements Marshaller<EventStreamOperationRequest> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder() .requestUri("/2016-03-11/eventStreamOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(true) .hasImplicitPayloadMembers(false).hasPayloadMembers(true).hasEventStreamingInput(true).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public EventStreamOperationRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(EventStreamOperationRequest eventStreamOperationRequest) { Validate.paramNotNull(eventStreamOperationRequest, "eventStreamOperationRequest"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(eventStreamOperationRequest); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,256
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/alltypesrequestmarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.AllTypesRequest; import software.amazon.awssdk.utils.Validate; /** * {@link AllTypesRequest} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class AllTypesRequestMarshaller implements Marshaller<AllTypesRequest> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/") .httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true) .hasPayloadMembers(true).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public AllTypesRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(AllTypesRequest allTypesRequest) { Validate.paramNotNull(allTypesRequest, "allTypesRequest"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(allTypesRequest); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,257
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/nestedcontainersrequestmarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.NestedContainersRequest; import software.amazon.awssdk.utils.Validate; /** * {@link NestedContainersRequest} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class NestedContainersRequestMarshaller implements Marshaller<NestedContainersRequest> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder().requestUri("/") .httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false).hasImplicitPayloadMembers(true) .hasPayloadMembers(true).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public NestedContainersRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(NestedContainersRequest nestedContainersRequest) { Validate.paramNotNull(nestedContainersRequest, "nestedContainersRequest"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(nestedContainersRequest); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,258
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/transform/streamingoutputoperationrequestmarshaller.java
package software.amazon.awssdk.services.jsonprotocoltests.transform; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.runtime.transform.Marshaller; import software.amazon.awssdk.http.SdkHttpFullRequest; import software.amazon.awssdk.http.SdkHttpMethod; import software.amazon.awssdk.protocols.core.OperationInfo; import software.amazon.awssdk.protocols.core.ProtocolMarshaller; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.services.jsonprotocoltests.model.StreamingOutputOperationRequest; import software.amazon.awssdk.utils.Validate; /** * {@link StreamingOutputOperationRequest} Marshaller */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi public class StreamingOutputOperationRequestMarshaller implements Marshaller<StreamingOutputOperationRequest> { private static final OperationInfo SDK_OPERATION_BINDING = OperationInfo.builder() .requestUri("/2016-03-11/streamingOutputOperation").httpMethod(SdkHttpMethod.POST).hasExplicitPayloadMember(false) .hasImplicitPayloadMembers(false).hasPayloadMembers(false).build(); private final BaseAwsJsonProtocolFactory protocolFactory; public StreamingOutputOperationRequestMarshaller(BaseAwsJsonProtocolFactory protocolFactory) { this.protocolFactory = protocolFactory; } @Override public SdkHttpFullRequest marshall(StreamingOutputOperationRequest streamingOutputOperationRequest) { Validate.paramNotNull(streamingOutputOperationRequest, "streamingOutputOperationRequest"); try { ProtocolMarshaller<SdkHttpFullRequest> protocolMarshaller = protocolFactory .createProtocolMarshaller(SDK_OPERATION_BINDING); return protocolMarshaller.marshall(streamingOutputOperationRequest); } catch (Exception e) { throw SdkClientException.builder().message("Unable to marshall request to JSON: " + e.getMessage()).cause(e).build(); } } }
3,259
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-class.java
package software.amazon.awssdk.services.json; import java.util.Collections; import java.util.List; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.signer.Aws4UnsignedPayloadSigner; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InvalidInputException; import software.amazon.awssdk.services.json.model.JsonException; import software.amazon.awssdk.services.json.model.JsonRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.HostnameValidator; import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link JsonClient}. * * @see JsonClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonClient implements JsonClient { private static final Logger log = Logger.loggerFor(DefaultJsonClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_JSON).build(); private final SyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultJsonClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsSyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata, APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); String hostPrefix = "{StringMember}-foo."; HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember", "aPostOperationRequest"); String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember()); return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return Result of the APostOperationWithOutput operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public APostOperationWithOutputResponse aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); return clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the BearerAuthOperation operation. * * @param bearerAuthOperationRequest * @return Result of the BearerAuthOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest) throws AwsServiceException, SdkClientException, JsonException { bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create()); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, BearerAuthOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the GetOperationWithChecksum operation. * * @param getOperationWithChecksumRequest * @return Result of the GetOperationWithChecksum operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public GetOperationWithChecksumResponse getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(false).build(); HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(getOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return Result of the GetWithoutRequiredMembers operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ @Override public GetWithoutRequiredMembersResponse getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetWithoutRequiredMembersResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers"); return clientHandler .execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>() .withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(getWithoutRequiredMembersRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithChecksumRequired operation. * * @param operationWithChecksumRequiredRequest * @return Result of the OperationWithChecksumRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public OperationWithChecksumRequiredResponse operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); return clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithRequestCompression operation. * * @param operationWithRequestCompressionRequest * @return Result of the OperationWithRequestCompression operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public OperationWithRequestCompressionResponse operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); return clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return Result of the PaginatedOperationWithResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ @Override public PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PaginatedOperationWithResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey"); return clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>() .withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(paginatedOperationWithResultKeyRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return Result of the PaginatedOperationWithoutResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ @Override public PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey"); return clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>() .withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(paginatedOperationWithoutResultKeyRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the PutOperationWithChecksum operation. * * @param putOperationWithChecksumRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PutOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); return clientHandler.execute( new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(putOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .requestBody(requestBody).build()), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); return clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingInputOutputOperationResponse and an InputStream to the response content are provided as * parameters to the callback. The callback may return a transformed type which will be the return value of * this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing * this interface and for links to pre-canned implementations for common scenarios like downloading to a * file. The service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, RequestBody requestBody, ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { streamingInputOutputOperationRequest = applySignerOverride(streamingInputOutputOperationRequest, Aws4UnsignedPayloadSigner.create()); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOutputOperationRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation"); return clientHandler.execute( new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>() .withOperationName("StreamingInputOutputOperation") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller .builder() .delegateMarshaller( new StreamingInputOutputOperationRequestMarshaller(protocolFactory)) .requestBody(requestBody).transferEncoding(true).build()), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); return clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Creates an instance of {@link JsonUtilities} object with the configuration set on this client. */ @Override public JsonUtilities utilities() { return JsonUtilities.create(param1, param2, param3); } private <T extends JsonRequest> T applySignerOverride(T request, Signer signer) { if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) { return request; } Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build(); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(signerOverride).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(JsonException::builder) .protocol(AwsJsonProtocol.REST_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()); } @Override public final JsonServiceClientConfiguration serviceClientConfiguration() { return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public void close() { clientHandler.close(); } }
3,260
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-abstract-async-client-class.java
package software.amazon.awssdk.services.json; import java.util.concurrent.CompletableFuture; import java.util.function.Function; import org.reactivestreams.Publisher; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.core.SdkClient; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InputEventStream; import software.amazon.awssdk.services.json.model.InputEventStreamTwo; import software.amazon.awssdk.services.json.model.JsonRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.utils.Validate; @Generated("software.amazon.awssdk:codegen") @SdkPublicApi public abstract class DelegatingJsonAsyncClient implements JsonAsyncClient { private final JsonAsyncClient delegate; public DelegatingJsonAsyncClient(JsonAsyncClient delegate) { Validate.paramNotNull(delegate, "delegate"); this.delegate = delegate; } /** * Creates an instance of {@link JsonUtilities} object with the configuration set on this client. */ @Override public JsonUtilities utilities() { return delegate.utilities(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { return invokeOperation(aPostOperationRequest, request -> delegate.aPostOperation(request)); } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { return invokeOperation(aPostOperationWithOutputRequest, request -> delegate.aPostOperationWithOutput(request)); } /** * Invokes the BearerAuthOperation operation asynchronously. * * @param bearerAuthOperationRequest * @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation( BearerAuthOperationRequest bearerAuthOperationRequest) { return invokeOperation(bearerAuthOperationRequest, request -> delegate.bearerAuthOperation(request)); } /** * Invokes the EventStreamOperation operation asynchronously. * * @param eventStreamOperationRequest * @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest, Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) { return invokeOperation(eventStreamOperationRequest, request -> delegate.eventStreamOperation(request, requestStream, asyncResponseHandler)); } /** * Invokes the EventStreamOperationWithOnlyInput operation asynchronously. * * @param eventStreamOperationWithOnlyInputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyInput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput( EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest, Publisher<InputEventStreamTwo> requestStream) { return invokeOperation(eventStreamOperationWithOnlyInputRequest, request -> delegate.eventStreamOperationWithOnlyInput(request, requestStream)); } /** * Invokes the EventStreamOperationWithOnlyOutput operation asynchronously. * * @param eventStreamOperationWithOnlyOutputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperationWithOnlyOutput( EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) { return invokeOperation(eventStreamOperationWithOnlyOutputRequest, request -> delegate.eventStreamOperationWithOnlyOutput(request, asyncResponseHandler)); } /** * Invokes the GetOperationWithChecksum operation asynchronously. * * @param getOperationWithChecksumRequest * @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) { return invokeOperation(getOperationWithChecksumRequest, request -> delegate.getOperationWithChecksum(request)); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) { return invokeOperation(getWithoutRequiredMembersRequest, request -> delegate.getWithoutRequiredMembers(request)); } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { return invokeOperation(operationWithChecksumRequiredRequest, request -> delegate.operationWithChecksumRequired(request)); } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { return invokeOperation(operationWithRequestCompressionRequest, request -> delegate.operationWithRequestCompression(request)); } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) { return invokeOperation(paginatedOperationWithResultKeyRequest, request -> delegate.paginatedOperationWithResultKey(request)); } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) { return invokeOperation(paginatedOperationWithoutResultKeyRequest, request -> delegate.paginatedOperationWithoutResultKey(request)); } /** * Invokes the PutOperationWithChecksum operation asynchronously. * * @param putOperationWithChecksumRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) { return invokeOperation(putOperationWithChecksumRequest, request -> delegate.putOperationWithChecksum(request, requestBody, asyncResponseTransformer)); } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { return invokeOperation(streamingInputOperationRequest, request -> delegate.streamingInputOperation(request, requestBody)); } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) { return invokeOperation(streamingInputOutputOperationRequest, request -> delegate.streamingInputOutputOperation(request, requestBody, asyncResponseTransformer)); } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { return invokeOperation(streamingOutputOperationRequest, request -> delegate.streamingOutputOperation(request, asyncResponseTransformer)); } @Override public final JsonServiceClientConfiguration serviceClientConfiguration() { return delegate.serviceClientConfiguration(); } @Override public final String serviceName() { return delegate.serviceName(); } public SdkClient delegate() { return this.delegate; } protected <T extends JsonRequest, ReturnT> CompletableFuture<ReturnT> invokeOperation(T request, Function<T, CompletableFuture<ReturnT>> operation) { return operation.apply(request); } @Override public void close() { delegate.close(); } }
3,261
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-class.java
package software.amazon.awssdk.services.json; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.nio.ByteBuffer; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Consumer; import org.reactivestreams.Publisher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.signer.AsyncAws4Signer; import software.amazon.awssdk.auth.signer.Aws4UnsignedPayloadSigner; import software.amazon.awssdk.auth.signer.EventStreamAws4Signer; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.client.handler.AwsClientHandlerUtils; import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionJsonMarshaller; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier; import software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkPojoBuilder; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.SdkResponse; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils; import software.amazon.awssdk.core.async.SdkPublisher; import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.AttachHttpMetadataResponseHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.protocol.VoidSdkResponse; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.json.model.EventStream; import software.amazon.awssdk.services.json.model.EventStreamOperationRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InputEventStream; import software.amazon.awssdk.services.json.model.InputEventStreamTwo; import software.amazon.awssdk.services.json.model.InvalidInputException; import software.amazon.awssdk.services.json.model.JsonException; import software.amazon.awssdk.services.json.model.JsonRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.json.model.inputeventstream.DefaultInputEvent; import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventOne; import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventTwo; import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyInputRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller; import software.amazon.awssdk.services.json.transform.InputEventMarshaller; import software.amazon.awssdk.services.json.transform.InputEventTwoMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.HostnameValidator; import software.amazon.awssdk.utils.Pair; /** * Internal implementation of {@link JsonAsyncClient}. * * @see JsonAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonAsyncClient implements JsonAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_JSON).build(); private final AsyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private final Executor executor; protected DefaultJsonAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR); } @Override public JsonUtilities utilities() { return JsonUtilities.create(param1, param2, param3); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); String hostPrefix = "{StringMember}-foo."; HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember", "aPostOperationRequest"); String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember()); CompletableFuture<APostOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(aPostOperationWithOutputRequest)); CompletableFuture<APostOperationWithOutputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the BearerAuthOperation operation asynchronously. * * @param bearerAuthOperationRequest * @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation( BearerAuthOperationRequest bearerAuthOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create()); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, BearerAuthOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .credentialType(CredentialType.TOKEN).withInput(bearerAuthOperationRequest)); CompletableFuture<BearerAuthOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperation operation asynchronously. * * @param eventStreamOperationRequest * @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest, Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation"); eventStreamOperationRequest = applySignerOverride(eventStreamOperationRequest, EventStreamAws4Signer.create()); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationResponse> responseHandler = new AttachHttpMetadataResponseHandler( protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder)); HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(), EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder) .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder) .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder) .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder() .putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build(); SdkPublisher<InputEventStream> eventPublisher = SdkPublisher.adapt(requestStream); Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map( AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer); CompletableFuture<Void> future = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler) .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler) .exceptionResponseHandler(errorResponseHandler).future(future).executor(executor).serviceName(serviceName()) .build(); RestEventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder() .eventStreamAsyncResponseTransformer(asyncResponseTransformer) .eventStreamResponseHandler(asyncResponseHandler).build(); CompletableFuture<Void> executeFuture = clientHandler.execute( new ClientExecutionParams<EventStreamOperationRequest, EventStreamOperationResponse>() .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory)) .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(eventStreamOperationRequest), restAsyncResponseTransformer); CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { try { asyncResponseHandler.exceptionOccurred(e); } finally { future.completeExceptionally(e); } } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return CompletableFutureUtils.forwardExceptionTo(future, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperationWithOnlyInput operation asynchronously. * * @param eventStreamOperationWithOnlyInputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyInput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput( EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest, Publisher<InputEventStreamTwo> requestStream) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput"); eventStreamOperationWithOnlyInputRequest = applySignerOverride(eventStreamOperationWithOnlyInputRequest, EventStreamAws4Signer.create()); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationWithOnlyInputResponse> responseHandler = protocolFactory .createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder() .putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory)) .putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build(); SdkPublisher<InputEventStreamTwo> eventPublisher = SdkPublisher.adapt(requestStream); Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map( AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer); CompletableFuture<EventStreamOperationWithOnlyInputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<EventStreamOperationWithOnlyInputRequest, EventStreamOperationWithOnlyInputResponse>() .withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory)) .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationWithOnlyInputRequest)); CompletableFuture<EventStreamOperationWithOnlyInputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperationWithOnlyOutput operation asynchronously. * * @param eventStreamOperationWithOnlyOutputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperationWithOnlyOutput( EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationWithOnlyOutputResponse> responseHandler = new AttachHttpMetadataResponseHandler( protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder)); HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(), EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder) .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder) .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder) .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<Void> future = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationWithOnlyOutputResponse, EventStream> builder() .eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler) .initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).future(future) .executor(executor).serviceName(serviceName()).build(); RestEventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer .<EventStreamOperationWithOnlyOutputResponse, EventStream> builder() .eventStreamAsyncResponseTransformer(asyncResponseTransformer) .eventStreamResponseHandler(asyncResponseHandler).build(); CompletableFuture<Void> executeFuture = clientHandler .execute( new ClientExecutionParams<EventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponse>() .withOperationName("EventStreamOperationWithOnlyOutput") .withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(eventStreamOperationWithOnlyOutputRequest), restAsyncResponseTransformer); CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { try { asyncResponseHandler.exceptionOccurred(e); } finally { future.completeExceptionally(e); } } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return CompletableFutureUtils.forwardExceptionTo(future, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the GetOperationWithChecksum operation asynchronously. * * @param getOperationWithChecksumRequest * @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(false).build(); HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest)); CompletableFuture<GetOperationWithChecksumResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetWithoutRequiredMembersResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<GetWithoutRequiredMembersResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>() .withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getWithoutRequiredMembersRequest)); CompletableFuture<GetWithoutRequiredMembersResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); CompletableFuture<OperationWithRequestCompressionResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PaginatedOperationWithResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<PaginatedOperationWithResultKeyResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>() .withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(paginatedOperationWithResultKeyRequest)); CompletableFuture<PaginatedOperationWithResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory .createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<PaginatedOperationWithoutResultKeyResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>() .withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(paginatedOperationWithoutResultKeyRequest)); CompletableFuture<PaginatedOperationWithoutResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the PutOperationWithChecksum operation asynchronously. * * @param putOperationWithChecksumRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); if (!isSignerOverridden(clientConfiguration)) { putOperationWithChecksumRequest = applySignerOverride(putOperationWithChecksumRequest, AsyncAws4Signer.create()); } JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PutOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .withAsyncRequestBody(requestBody) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()).withInput(putOperationWithChecksumRequest), asyncResponseTransformer); AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); if (!isSignerOverridden(clientConfiguration)) { streamingInputOperationRequest = applySignerOverride(streamingInputOperationRequest, AsyncAws4Signer.create()); } JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture<StreamingInputOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOutputOperationRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation"); Pair<AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); streamingInputOutputOperationRequest = applySignerOverride(streamingInputOutputOperationRequest, Aws4UnsignedPayloadSigner.create()); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>() .withOperationName("StreamingInputOutputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller .builder() .delegateMarshaller( new StreamingInputOutputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).transferEncoding(true).build()) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(streamingOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final JsonServiceClientConfiguration serviceClientConfiguration() { return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(JsonException::builder) .protocol(AwsJsonProtocol.REST_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private <T extends JsonRequest> T applySignerOverride(T request, Signer signer) { if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) { return request; } Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build(); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(signerOverride).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } private static boolean isSignerOverridden(SdkClientConfiguration clientConfiguration) { return Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.SIGNER_OVERRIDDEN)); } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }
3,262
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-json-async-client-class.java
package software.amazon.awssdk.services.json; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.nio.ByteBuffer; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Consumer; import org.reactivestreams.Publisher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.signer.AsyncAws4Signer; import software.amazon.awssdk.auth.signer.Aws4UnsignedPayloadSigner; import software.amazon.awssdk.auth.signer.EventStreamAws4Signer; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.client.handler.AwsClientHandlerUtils; import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionJsonMarshaller; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkPojoBuilder; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.SdkResponse; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils; import software.amazon.awssdk.core.async.SdkPublisher; import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.AttachHttpMetadataResponseHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.protocol.VoidSdkResponse; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.EventStream; import software.amazon.awssdk.services.json.model.EventStreamOperationRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InputEventStream; import software.amazon.awssdk.services.json.model.InputEventStreamTwo; import software.amazon.awssdk.services.json.model.InvalidInputException; import software.amazon.awssdk.services.json.model.JsonException; import software.amazon.awssdk.services.json.model.JsonRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.json.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.ServiceFaultException; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.json.model.inputeventstream.DefaultInputEvent; import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventOne; import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventTwo; import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyInputRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller; import software.amazon.awssdk.services.json.transform.InputEventMarshaller; import software.amazon.awssdk.services.json.transform.InputEventTwoMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.HostnameValidator; import software.amazon.awssdk.utils.Pair; /** * Internal implementation of {@link JsonAsyncClient}. * * @see JsonAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonAsyncClient implements JsonAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.AWS_JSON).build(); private final AsyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private final Executor executor; protected DefaultJsonAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR); } @Override public JsonUtilities utilities() { return JsonUtilities.create(param1, param2, param3); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); String hostPrefix = "{StringMember}-foo."; HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember", "aPostOperationRequest"); String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember()); CompletableFuture<APostOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>ServiceFaultException</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(aPostOperationWithOutputRequest)); CompletableFuture<APostOperationWithOutputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperation operation asynchronously. * * @param eventStreamOperationRequest * @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest, Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation"); eventStreamOperationRequest = applySignerOverride(eventStreamOperationRequest, EventStreamAws4Signer.create()); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationResponse> responseHandler = new AttachHttpMetadataResponseHandler( protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder)); HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(), EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder) .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder) .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder) .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder() .putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build(); SdkPublisher<InputEventStream> eventPublisher = SdkPublisher.adapt(requestStream); Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map( AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer); CompletableFuture<Void> future = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler) .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler) .exceptionResponseHandler(errorResponseHandler).future(future).executor(executor).serviceName(serviceName()) .build(); CompletableFuture<Void> executeFuture = clientHandler.execute( new ClientExecutionParams<EventStreamOperationRequest, SdkResponse>() .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory)) .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true) .withInitialRequestEvent(true).withResponseHandler(voidResponseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest), asyncResponseTransformer); CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { try { asyncResponseHandler.exceptionOccurred(e); } finally { future.completeExceptionally(e); } } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return CompletableFutureUtils.forwardExceptionTo(future, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperationWithOnlyInput operation asynchronously. * * @param eventStreamOperationWithOnlyInputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyInput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput( EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest, Publisher<InputEventStreamTwo> requestStream) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput"); eventStreamOperationWithOnlyInputRequest = applySignerOverride(eventStreamOperationWithOnlyInputRequest, EventStreamAws4Signer.create()); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationWithOnlyInputResponse> responseHandler = protocolFactory .createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder() .putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory)) .putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build(); SdkPublisher<InputEventStreamTwo> eventPublisher = SdkPublisher.adapt(requestStream); Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map( AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer); CompletableFuture<EventStreamOperationWithOnlyInputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<EventStreamOperationWithOnlyInputRequest, EventStreamOperationWithOnlyInputResponse>() .withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory)) .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withInitialRequestEvent(true) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(eventStreamOperationWithOnlyInputRequest)); CompletableFuture<EventStreamOperationWithOnlyInputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperationWithOnlyOutput operation asynchronously. * * @param eventStreamOperationWithOnlyOutputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperationWithOnlyOutput( EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationWithOnlyOutputResponse> responseHandler = new AttachHttpMetadataResponseHandler( protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder)); HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(), EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder) .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder) .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder) .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<Void> future = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationWithOnlyOutputResponse, EventStream> builder() .eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler) .initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).future(future) .executor(executor).serviceName(serviceName()).build(); CompletableFuture<Void> executeFuture = clientHandler.execute( new ClientExecutionParams<EventStreamOperationWithOnlyOutputRequest, SdkResponse>() .withOperationName("EventStreamOperationWithOnlyOutput").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory)) .withResponseHandler(voidResponseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(eventStreamOperationWithOnlyOutputRequest), asyncResponseTransformer); CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { try { asyncResponseHandler.exceptionOccurred(e); } finally { future.completeExceptionally(e); } } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return CompletableFutureUtils.forwardExceptionTo(future, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetWithoutRequiredMembersResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<GetWithoutRequiredMembersResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>() .withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getWithoutRequiredMembersRequest)); CompletableFuture<GetWithoutRequiredMembersResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithNoneAuthType operation asynchronously. * * @param operationWithNoneAuthTypeRequest * @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithNoneAuthTypeResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); CompletableFuture<OperationWithRequestCompressionResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PaginatedOperationWithResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<PaginatedOperationWithResultKeyResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>() .withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(paginatedOperationWithResultKeyRequest)); CompletableFuture<PaginatedOperationWithResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory .createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<PaginatedOperationWithoutResultKeyResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>() .withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(paginatedOperationWithoutResultKeyRequest)); CompletableFuture<PaginatedOperationWithoutResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); if (!isSignerOverridden(clientConfiguration)) { streamingInputOperationRequest = applySignerOverride(streamingInputOperationRequest, AsyncAws4Signer.create()); } JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture<StreamingInputOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOutputOperationRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation"); Pair<AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); streamingInputOutputOperationRequest = applySignerOverride(streamingInputOutputOperationRequest, Aws4UnsignedPayloadSigner.create()); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>() .withOperationName("StreamingInputOutputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller .builder() .delegateMarshaller( new StreamingInputOutputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).transferEncoding(true).build()) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(streamingOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final JsonServiceClientConfiguration serviceClientConfiguration() { return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(JsonException::builder) .protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInputException") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ServiceFaultException") .exceptionBuilderSupplier(ServiceFaultException::builder).httpStatusCode(500).build()); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private <T extends JsonRequest> T applySignerOverride(T request, Signer signer) { if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) { return request; } Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build(); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(signerOverride).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } private static boolean isSignerOverridden(SdkClientConfiguration clientConfiguration) { return Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.SIGNER_OVERRIDDEN)); } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }
3,263
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-client-class.java
package software.amazon.awssdk.services.query; import java.util.Collections; import java.util.List; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory; import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder; import software.amazon.awssdk.services.query.model.APostOperationRequest; import software.amazon.awssdk.services.query.model.APostOperationResponse; import software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.query.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.query.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.query.model.InvalidInputException; import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest; import software.amazon.awssdk.services.query.model.OperationWithContextParamResponse; import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsRequest; import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsResponse; import software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.query.model.QueryException; import software.amazon.awssdk.services.query.model.QueryRequest; import software.amazon.awssdk.services.query.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.query.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.query.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithContextParamRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithStaticContextParamsRequestMarshaller; import software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.services.query.waiters.QueryWaiter; import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link QueryClient}. * * @see QueryClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultQueryClient implements QueryClient { private static final Logger log = Logger.loggerFor(DefaultQueryClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.QUERY).build(); private final SyncClientHandler clientHandler; private final AwsQueryProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultQueryClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsSyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory .createResponseHandler(APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); String hostPrefix = "foo-"; String resolvedHostExpression = "foo-"; return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return Result of the APostOperationWithOutput operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public APostOperationWithOutputResponse aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory .createResponseHandler(APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); return clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the BearerAuthOperation operation. * * @param bearerAuthOperationRequest * @return Result of the BearerAuthOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest) throws AwsServiceException, SdkClientException, QueryException { bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create()); HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory .createResponseHandler(BearerAuthOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the GetOperationWithChecksum operation. * * @param getOperationWithChecksumRequest * @return Result of the GetOperationWithChecksum operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public GetOperationWithChecksumResponse getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory .createResponseHandler(GetOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(getOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithChecksumRequired operation. * * @param operationWithChecksumRequiredRequest * @return Result of the OperationWithChecksumRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public OperationWithChecksumRequiredResponse operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); return clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithContextParam operation. * * @param operationWithContextParamRequest * @return Result of the OperationWithContextParam operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithContextParam * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithContextParam" * target="_top">AWS API Documentation</a> */ @Override public OperationWithContextParamResponse operationWithContextParam( OperationWithContextParamRequest operationWithContextParamRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithContextParamResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithContextParamResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithContextParamRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithContextParamRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithContextParam"); return clientHandler .execute(new ClientExecutionParams<OperationWithContextParamRequest, OperationWithContextParamResponse>() .withOperationName("OperationWithContextParam").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithContextParamRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithNoneAuthType operation. * * @param operationWithNoneAuthTypeRequest * @return Result of the OperationWithNoneAuthType operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public OperationWithNoneAuthTypeResponse operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithNoneAuthTypeResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); return clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithRequestCompression operation. * * @param operationWithRequestCompressionRequest * @return Result of the OperationWithRequestCompression operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public OperationWithRequestCompressionResponse operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); return clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithStaticContextParams operation. * * @param operationWithStaticContextParamsRequest * @return Result of the OperationWithStaticContextParams operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithStaticContextParams * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithStaticContextParams" * target="_top">AWS API Documentation</a> */ @Override public OperationWithStaticContextParamsResponse operationWithStaticContextParams( OperationWithStaticContextParamsRequest operationWithStaticContextParamsRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithStaticContextParamsResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithStaticContextParamsResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithStaticContextParamsRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithStaticContextParamsRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithStaticContextParams"); return clientHandler .execute(new ClientExecutionParams<OperationWithStaticContextParamsRequest, OperationWithStaticContextParamsResponse>() .withOperationName("OperationWithStaticContextParams").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithStaticContextParamsRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new OperationWithStaticContextParamsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the PutOperationWithChecksum operation. * * @param putOperationWithChecksumRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory .createResponseHandler(PutOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(putOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory .createResponseHandler(StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); return clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory .createResponseHandler(StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); return clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Create an instance of {@link QueryWaiter} using this client. * <p> * Waiters created via this method are managed by the SDK and resources will be released when the service client is * closed. * * @return an instance of {@link QueryWaiter} */ @Override public QueryWaiter waiter() { return QueryWaiter.builder().client(this).build(); } private <T extends QueryRequest> T applySignerOverride(T request, Signer signer) { if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) { return request; } Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build(); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(signerOverride).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private AwsQueryProtocolFactory init() { return AwsQueryProtocolFactory .builder() .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(QueryException::builder).build(); } @Override public final QueryServiceClientConfiguration serviceClientConfiguration() { return new QueryServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public void close() { clientHandler.close(); } }
3,264
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-sync-client-class.java
package software.amazon.awssdk.services.querytojsoncompatible; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.querytojsoncompatible.internal.QueryToJsonCompatibleServiceClientConfigurationBuilder; import software.amazon.awssdk.services.querytojsoncompatible.model.APostOperationRequest; import software.amazon.awssdk.services.querytojsoncompatible.model.APostOperationResponse; import software.amazon.awssdk.services.querytojsoncompatible.model.InvalidInputException; import software.amazon.awssdk.services.querytojsoncompatible.model.QueryToJsonCompatibleException; import software.amazon.awssdk.services.querytojsoncompatible.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.utils.HostnameValidator; import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link QueryToJsonCompatibleClient}. * * @see QueryToJsonCompatibleClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultQueryToJsonCompatibleClient implements QueryToJsonCompatibleClient { private static final Logger log = Logger.loggerFor(DefaultQueryToJsonCompatibleClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.AWS_JSON).build(); private final SyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultQueryToJsonCompatibleClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsSyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryToJsonCompatibleException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryToJsonCompatibleClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-to-json-compatible-service-2010-05-08/APostOperation" * target="_top">AWS API Documentation</a> */ @Override public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, QueryToJsonCompatibleException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata, APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QueryToJsonCompatibleService"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); String hostPrefix = "{StringMember}-foo."; HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember", "aPostOperationRequest"); String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember()); return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } @Override public final String serviceName() { return SERVICE_NAME; } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); QueryToJsonCompatibleServiceClientConfigurationBuilder serviceConfigBuilder = new QueryToJsonCompatibleServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(QueryToJsonCompatibleException::builder) .protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1") .hasAwsQueryCompatible(true) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()); } @Override public final QueryToJsonCompatibleServiceClientConfiguration serviceClientConfiguration() { return new QueryToJsonCompatibleServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public void close() { clientHandler.close(); } }
3,265
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-sync.java
package software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.internal.ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.OneOperationRequest; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.OneOperationResponse; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.ProtocolRestJsonWithCustomContentTypeException; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.transform.OneOperationRequestMarshaller; import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link ProtocolRestJsonWithCustomContentTypeClient}. * * @see ProtocolRestJsonWithCustomContentTypeClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultProtocolRestJsonWithCustomContentTypeClient implements ProtocolRestJsonWithCustomContentTypeClient { private static final Logger log = Logger.loggerFor(DefaultProtocolRestJsonWithCustomContentTypeClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_JSON).build(); private final SyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultProtocolRestJsonWithCustomContentTypeClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsSyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); } /** * Invokes the OneOperation operation. * * @param oneOperationRequest * @return Result of the OneOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws ProtocolRestJsonWithCustomContentTypeException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample ProtocolRestJsonWithCustomContentTypeClient.OneOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/restjson-2016-03-11/OneOperation" target="_top">AWS API * Documentation</a> */ @Override public OneOperationResponse oneOperation(OneOperationRequest oneOperationRequest) throws AwsServiceException, SdkClientException, ProtocolRestJsonWithCustomContentTypeException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OneOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata, OneOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(oneOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, oneOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AmazonProtocolRestJsonWithCustomContentType"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OneOperation"); return clientHandler.execute(new ClientExecutionParams<OneOperationRequest, OneOperationResponse>() .withOperationName("OneOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(oneOperationRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new OneOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } @Override public final String serviceName() { return SERVICE_NAME; } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder serviceConfigBuilder = new ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder.clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(ProtocolRestJsonWithCustomContentTypeException::builder) .protocol(AwsJsonProtocol.REST_JSON).protocolVersion("1.1").contentType("application/json"); } @Override public final ProtocolRestJsonWithCustomContentTypeServiceClientConfiguration serviceClientConfiguration() { return new ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()) .build(); } @Override public void close() { clientHandler.close(); } }
3,266
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-aws-query-compatible-json-async-client-class.java
package software.amazon.awssdk.services.querytojsoncompatible; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.querytojsoncompatible.internal.QueryToJsonCompatibleServiceClientConfigurationBuilder; import software.amazon.awssdk.services.querytojsoncompatible.model.APostOperationRequest; import software.amazon.awssdk.services.querytojsoncompatible.model.APostOperationResponse; import software.amazon.awssdk.services.querytojsoncompatible.model.InvalidInputException; import software.amazon.awssdk.services.querytojsoncompatible.model.QueryToJsonCompatibleException; import software.amazon.awssdk.services.querytojsoncompatible.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.HostnameValidator; /** * Internal implementation of {@link QueryToJsonCompatibleAsyncClient}. * * @see QueryToJsonCompatibleAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultQueryToJsonCompatibleAsyncClient implements QueryToJsonCompatibleAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultQueryToJsonCompatibleAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.AWS_JSON).build(); private final AsyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultQueryToJsonCompatibleAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryToJsonCompatibleException Base class for all service exceptions. Unknown exceptions will be * thrown as an instance of this type.</li> * </ul> * @sample QueryToJsonCompatibleAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-to-json-compatible-service-2010-05-08/APostOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "QueryToJsonCompatibleService"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); String hostPrefix = "{StringMember}-foo."; HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember", "aPostOperationRequest"); String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember()); CompletableFuture<APostOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final QueryToJsonCompatibleServiceClientConfiguration serviceClientConfiguration() { return new QueryToJsonCompatibleServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(QueryToJsonCompatibleException::builder) .protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1") .hasAwsQueryCompatible(true) .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); QueryToJsonCompatibleServiceClientConfigurationBuilder serviceConfigBuilder = new QueryToJsonCompatibleServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }
3,267
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-client-interface.java
package software.amazon.awssdk.services.json; import java.nio.file.Path; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.annotations.ThreadSafe; import software.amazon.awssdk.awscore.AwsClient; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.core.ResponseBytes; import software.amazon.awssdk.core.ResponseInputStream; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.regions.ServiceMetadata; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InvalidInputException; import software.amazon.awssdk.services.json.model.JsonException; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable; import software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable; /** * Service client for accessing Json Service. This can be created using the static {@link #builder()} method. * * A service that is implemented using the query protocol */ @Generated("software.amazon.awssdk:codegen") @SdkPublicApi @ThreadSafe public interface JsonClient extends AwsClient { String SERVICE_NAME = "json-service"; /** * Value for looking up the service's metadata from the * {@link software.amazon.awssdk.regions.ServiceMetadataProvider}. */ String SERVICE_METADATA_ID = "json-service-endpoint"; /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> * * @deprecated This API is deprecated, use something else */ @Deprecated default APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * <br/> * <p> * This is a convenience which creates an instance of the {@link APostOperationRequest.Builder} avoiding the need to * create one manually via {@link APostOperationRequest#builder()} * </p> * * @param aPostOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.APostOperationRequest.Builder} to create a request. * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> * * @deprecated This API is deprecated, use something else */ @Deprecated default APostOperationResponse aPostOperation(Consumer<APostOperationRequest.Builder> aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { return aPostOperation(APostOperationRequest.builder().applyMutation(aPostOperationRequest).build()); } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return Result of the APostOperationWithOutput operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ default APostOperationWithOutputResponse aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * <br/> * <p> * This is a convenience which creates an instance of the {@link APostOperationWithOutputRequest.Builder} avoiding * the need to create one manually via {@link APostOperationWithOutputRequest#builder()} * </p> * * @param aPostOperationWithOutputRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest.Builder} to create a * request. * @return Result of the APostOperationWithOutput operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ default APostOperationWithOutputResponse aPostOperationWithOutput( Consumer<APostOperationWithOutputRequest.Builder> aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { return aPostOperationWithOutput(APostOperationWithOutputRequest.builder().applyMutation(aPostOperationWithOutputRequest) .build()); } /** * Invokes the BearerAuthOperation operation. * * @param bearerAuthOperationRequest * @return Result of the BearerAuthOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ default BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Invokes the BearerAuthOperation operation.<br/> * <p> * This is a convenience which creates an instance of the {@link BearerAuthOperationRequest.Builder} avoiding the * need to create one manually via {@link BearerAuthOperationRequest#builder()} * </p> * * @param bearerAuthOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.BearerAuthOperationRequest.Builder} to create a request. * @return Result of the BearerAuthOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ default BearerAuthOperationResponse bearerAuthOperation( Consumer<BearerAuthOperationRequest.Builder> bearerAuthOperationRequest) throws AwsServiceException, SdkClientException, JsonException { return bearerAuthOperation(BearerAuthOperationRequest.builder().applyMutation(bearerAuthOperationRequest).build()); } /** * Invokes the GetOperationWithChecksum operation. * * @param getOperationWithChecksumRequest * @return Result of the GetOperationWithChecksum operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default GetOperationWithChecksumResponse getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Invokes the GetOperationWithChecksum operation.<br/> * <p> * This is a convenience which creates an instance of the {@link GetOperationWithChecksumRequest.Builder} avoiding * the need to create one manually via {@link GetOperationWithChecksumRequest#builder()} * </p> * * @param getOperationWithChecksumRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest.Builder} to create a * request. * @return Result of the GetOperationWithChecksum operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default GetOperationWithChecksumResponse getOperationWithChecksum( Consumer<GetOperationWithChecksumRequest.Builder> getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException, JsonException { return getOperationWithChecksum(GetOperationWithChecksumRequest.builder().applyMutation(getOperationWithChecksumRequest) .build()); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return Result of the GetWithoutRequiredMembers operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ default GetWithoutRequiredMembersResponse getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * <br/> * <p> * This is a convenience which creates an instance of the {@link GetWithoutRequiredMembersRequest.Builder} avoiding * the need to create one manually via {@link GetWithoutRequiredMembersRequest#builder()} * </p> * * @param getWithoutRequiredMembersRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest.Builder} to create a * request. * @return Result of the GetWithoutRequiredMembers operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ default GetWithoutRequiredMembersResponse getWithoutRequiredMembers( Consumer<GetWithoutRequiredMembersRequest.Builder> getWithoutRequiredMembersRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { return getWithoutRequiredMembers(GetWithoutRequiredMembersRequest.builder() .applyMutation(getWithoutRequiredMembersRequest).build()); } /** * Invokes the OperationWithChecksumRequired operation. * * @param operationWithChecksumRequiredRequest * @return Result of the OperationWithChecksumRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ default OperationWithChecksumRequiredResponse operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Invokes the OperationWithChecksumRequired operation.<br/> * <p> * This is a convenience which creates an instance of the {@link OperationWithChecksumRequiredRequest.Builder} * avoiding the need to create one manually via {@link OperationWithChecksumRequiredRequest#builder()} * </p> * * @param operationWithChecksumRequiredRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest.Builder} to create * a request. * @return Result of the OperationWithChecksumRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ default OperationWithChecksumRequiredResponse operationWithChecksumRequired( Consumer<OperationWithChecksumRequiredRequest.Builder> operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, JsonException { return operationWithChecksumRequired(OperationWithChecksumRequiredRequest.builder() .applyMutation(operationWithChecksumRequiredRequest).build()); } /** * Invokes the OperationWithRequestCompression operation. * * @param operationWithRequestCompressionRequest * @return Result of the OperationWithRequestCompression operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ default OperationWithRequestCompressionResponse operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Invokes the OperationWithRequestCompression operation.<br/> * <p> * This is a convenience which creates an instance of the {@link OperationWithRequestCompressionRequest.Builder} * avoiding the need to create one manually via {@link OperationWithRequestCompressionRequest#builder()} * </p> * * @param operationWithRequestCompressionRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest.Builder} to * create a request. * @return Result of the OperationWithRequestCompression operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ default OperationWithRequestCompressionResponse operationWithRequestCompression( Consumer<OperationWithRequestCompressionRequest.Builder> operationWithRequestCompressionRequest) throws AwsServiceException, SdkClientException, JsonException { return operationWithRequestCompression(OperationWithRequestCompressionRequest.builder() .applyMutation(operationWithRequestCompressionRequest).build()); } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return Result of the PaginatedOperationWithResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Some paginated operation with result_key in paginators.json file<br/> * <p> * This is a convenience which creates an instance of the {@link PaginatedOperationWithResultKeyRequest.Builder} * avoiding the need to create one manually via {@link PaginatedOperationWithResultKeyRequest#builder()} * </p> * * @param paginatedOperationWithResultKeyRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest.Builder} to * create a request. * @return Result of the PaginatedOperationWithResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey( Consumer<PaginatedOperationWithResultKeyRequest.Builder> paginatedOperationWithResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { return paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest.builder() .applyMutation(paginatedOperationWithResultKeyRequest).build()); } /** * Some paginated operation with result_key in paginators.json file * * @return Result of the PaginatedOperationWithResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithResultKey * @see #paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey() throws AwsServiceException, SdkClientException, JsonException { return paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest.builder().build()); } /** * Some paginated operation with result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will * internally handle making service calls for you. * </p> * <p> * When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. * </p> * * <p> * The following are few ways to iterate through the response pages: * </p> * 1) Using a Stream * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request); * responses.stream().forEach(....); * } * </pre> * * 2) Using For loop * * <pre> * { * &#064;code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client * .paginatedOperationWithResultKeyPaginator(request); * for (software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response : responses) { * // do something; * } * } * </pre> * * 3) Use iterator directly * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request); * responses.iterator().forEachRemaining(....); * } * </pre> * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation.</b> * </p> * * @return A custom iterable that can be used to iterate through all the response pages. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithResultKey * @see #paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithResultKeyIterable paginatedOperationWithResultKeyPaginator() throws AwsServiceException, SdkClientException, JsonException { return paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest.builder().build()); } /** * Some paginated operation with result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will * internally handle making service calls for you. * </p> * <p> * When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. * </p> * * <p> * The following are few ways to iterate through the response pages: * </p> * 1) Using a Stream * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request); * responses.stream().forEach(....); * } * </pre> * * 2) Using For loop * * <pre> * { * &#064;code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client * .paginatedOperationWithResultKeyPaginator(request); * for (software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response : responses) { * // do something; * } * } * </pre> * * 3) Use iterator directly * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request); * responses.iterator().forEachRemaining(....); * } * </pre> * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation.</b> * </p> * * @param paginatedOperationWithResultKeyRequest * @return A custom iterable that can be used to iterate through all the response pages. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithResultKeyIterable paginatedOperationWithResultKeyPaginator( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { return new PaginatedOperationWithResultKeyIterable(this, paginatedOperationWithResultKeyRequest); } /** * Some paginated operation with result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will * internally handle making service calls for you. * </p> * <p> * When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. * </p> * * <p> * The following are few ways to iterate through the response pages: * </p> * 1) Using a Stream * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request); * responses.stream().forEach(....); * } * </pre> * * 2) Using For loop * * <pre> * { * &#064;code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client * .paginatedOperationWithResultKeyPaginator(request); * for (software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response : responses) { * // do something; * } * } * </pre> * * 3) Use iterator directly * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyIterable responses = client.paginatedOperationWithResultKeyPaginator(request); * responses.iterator().forEachRemaining(....); * } * </pre> * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation.</b> * </p> * <p> * This is a convenience which creates an instance of the {@link PaginatedOperationWithResultKeyRequest.Builder} * avoiding the need to create one manually via {@link PaginatedOperationWithResultKeyRequest#builder()} * </p> * * @param paginatedOperationWithResultKeyRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest.Builder} to * create a request. * @return A custom iterable that can be used to iterate through all the response pages. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithResultKeyIterable paginatedOperationWithResultKeyPaginator( Consumer<PaginatedOperationWithResultKeyRequest.Builder> paginatedOperationWithResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { return paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest.builder() .applyMutation(paginatedOperationWithResultKeyRequest).build()); } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return Result of the PaginatedOperationWithoutResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Some paginated operation without result_key in paginators.json file<br/> * <p> * This is a convenience which creates an instance of the {@link PaginatedOperationWithoutResultKeyRequest.Builder} * avoiding the need to create one manually via {@link PaginatedOperationWithoutResultKeyRequest#builder()} * </p> * * @param paginatedOperationWithoutResultKeyRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest.Builder} to * create a request. * @return Result of the PaginatedOperationWithoutResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey( Consumer<PaginatedOperationWithoutResultKeyRequest.Builder> paginatedOperationWithoutResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { return paginatedOperationWithoutResultKey(PaginatedOperationWithoutResultKeyRequest.builder() .applyMutation(paginatedOperationWithoutResultKeyRequest).build()); } /** * Some paginated operation without result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)} * operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will * internally handle making service calls for you. * </p> * <p> * When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. * </p> * * <p> * The following are few ways to iterate through the response pages: * </p> * 1) Using a Stream * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client.paginatedOperationWithoutResultKeyPaginator(request); * responses.stream().forEach(....); * } * </pre> * * 2) Using For loop * * <pre> * { * &#064;code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client * .paginatedOperationWithoutResultKeyPaginator(request); * for (software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse response : responses) { * // do something; * } * } * </pre> * * 3) Use iterator directly * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client.paginatedOperationWithoutResultKeyPaginator(request); * responses.iterator().forEachRemaining(....); * } * </pre> * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)} * operation.</b> * </p> * * @param paginatedOperationWithoutResultKeyRequest * @return A custom iterable that can be used to iterate through all the response pages. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithoutResultKeyIterable paginatedOperationWithoutResultKeyPaginator( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { return new PaginatedOperationWithoutResultKeyIterable(this, paginatedOperationWithoutResultKeyRequest); } /** * Some paginated operation without result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)} * operation. The return type is a custom iterable that can be used to iterate through all the pages. SDK will * internally handle making service calls for you. * </p> * <p> * When this operation is called, a custom iterable is returned but no service calls are made yet. So there is no * guarantee that the request is valid. As you iterate through the iterable, SDK will start lazily loading response * pages by making service calls until there are no pages left or your iteration stops. If there are errors in your * request, you will see the failures only after you start iterating through the iterable. * </p> * * <p> * The following are few ways to iterate through the response pages: * </p> * 1) Using a Stream * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client.paginatedOperationWithoutResultKeyPaginator(request); * responses.stream().forEach(....); * } * </pre> * * 2) Using For loop * * <pre> * { * &#064;code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client * .paginatedOperationWithoutResultKeyPaginator(request); * for (software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse response : responses) { * // do something; * } * } * </pre> * * 3) Use iterator directly * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyIterable responses = client.paginatedOperationWithoutResultKeyPaginator(request); * responses.iterator().forEachRemaining(....); * } * </pre> * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)} * operation.</b> * </p> * <p> * This is a convenience which creates an instance of the {@link PaginatedOperationWithoutResultKeyRequest.Builder} * avoiding the need to create one manually via {@link PaginatedOperationWithoutResultKeyRequest#builder()} * </p> * * @param paginatedOperationWithoutResultKeyRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest.Builder} to * create a request. * @return A custom iterable that can be used to iterate through all the response pages. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithoutResultKeyIterable paginatedOperationWithoutResultKeyPaginator( Consumer<PaginatedOperationWithoutResultKeyRequest.Builder> paginatedOperationWithoutResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { return paginatedOperationWithoutResultKeyPaginator(PaginatedOperationWithoutResultKeyRequest.builder() .applyMutation(paginatedOperationWithoutResultKeyRequest).build()); } /** * Invokes the PutOperationWithChecksum operation. * * @param putOperationWithChecksumRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Invokes the PutOperationWithChecksum operation.<br/> * <p> * This is a convenience which creates an instance of the {@link PutOperationWithChecksumRequest.Builder} avoiding * the need to create one manually via {@link PutOperationWithChecksumRequest#builder()} * </p> * * @param putOperationWithChecksumRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest.Builder} to create a * request. * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default <ReturnT> ReturnT putOperationWithChecksum( Consumer<PutOperationWithChecksumRequest.Builder> putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { return putOperationWithChecksum(PutOperationWithChecksumRequest.builder().applyMutation(putOperationWithChecksumRequest) .build(), requestBody, responseTransformer); } /** * Invokes the PutOperationWithChecksum operation. * * @param putOperationWithChecksumRequest * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows ' * <p> * Object data. * </p> * ' * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PutOperationWithChecksum * @see #putOperationWithChecksum(PutOperationWithChecksumRequest, RequestBody) * @see #putOperationWithChecksum(PutOperationWithChecksumRequest, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default PutOperationWithChecksumResponse putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, Path sourcePath, Path destinationPath) throws AwsServiceException, SdkClientException, JsonException { return putOperationWithChecksum(putOperationWithChecksumRequest, RequestBody.fromFile(sourcePath), ResponseTransformer.toFile(destinationPath)); } /** * Invokes the PutOperationWithChecksum operation.<br/> * <p> * This is a convenience which creates an instance of the {@link PutOperationWithChecksumRequest.Builder} avoiding * the need to create one manually via {@link PutOperationWithChecksumRequest#builder()} * </p> * * @param putOperationWithChecksumRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest.Builder} to create a * request. * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows ' * <p> * Object data. * </p> * ' * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PutOperationWithChecksum * @see #putOperationWithChecksum(PutOperationWithChecksumRequest, RequestBody) * @see #putOperationWithChecksum(PutOperationWithChecksumRequest, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default PutOperationWithChecksumResponse putOperationWithChecksum( Consumer<PutOperationWithChecksumRequest.Builder> putOperationWithChecksumRequest, Path sourcePath, Path destinationPath) throws AwsServiceException, SdkClientException, JsonException { return putOperationWithChecksum(PutOperationWithChecksumRequest.builder().applyMutation(putOperationWithChecksumRequest) .build(), sourcePath, destinationPath); } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ default StreamingInputOperationResponse streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Some operation with a streaming input<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingInputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingInputOperationRequest#builder()} * </p> * * @param streamingInputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingInputOperationRequest.Builder} to create a * request. * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ default StreamingInputOperationResponse streamingInputOperation( Consumer<StreamingInputOperationRequest.Builder> streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, JsonException { return streamingInputOperation(StreamingInputOperationRequest.builder().applyMutation(streamingInputOperationRequest) .build(), requestBody); } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOperation * @see #streamingInputOperation(StreamingInputOperationRequest, RequestBody) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ default StreamingInputOperationResponse streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, Path sourcePath) throws AwsServiceException, SdkClientException, JsonException { return streamingInputOperation(streamingInputOperationRequest, RequestBody.fromFile(sourcePath)); } /** * Some operation with a streaming input<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingInputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingInputOperationRequest#builder()} * </p> * * @param streamingInputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingInputOperationRequest.Builder} to create a * request. * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOperation * @see #streamingInputOperation(StreamingInputOperationRequest, RequestBody) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ default StreamingInputOperationResponse streamingInputOperation( Consumer<StreamingInputOperationRequest.Builder> streamingInputOperationRequest, Path sourcePath) throws AwsServiceException, SdkClientException, JsonException { return streamingInputOperation(StreamingInputOperationRequest.builder().applyMutation(streamingInputOperationRequest) .build(), sourcePath); } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingInputOutputOperationResponse and an InputStream to the response content are provided as * parameters to the callback. The callback may return a transformed type which will be the return value of * this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing * this interface and for links to pre-canned implementations for common scenarios like downloading to a * file. The service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ default <ReturnT> ReturnT streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, RequestBody requestBody, ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Some operation with streaming input and streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingInputOutputOperationRequest.Builder} * avoiding the need to create one manually via {@link StreamingInputOutputOperationRequest#builder()} * </p> * * @param streamingInputOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest.Builder} to create * a request. * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingInputOutputOperationResponse and an InputStream to the response content are provided as * parameters to the callback. The callback may return a transformed type which will be the return value of * this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing * this interface and for links to pre-canned implementations for common scenarios like downloading to a * file. The service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ default <ReturnT> ReturnT streamingInputOutputOperation( Consumer<StreamingInputOutputOperationRequest.Builder> streamingInputOutputOperationRequest, RequestBody requestBody, ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { return streamingInputOutputOperation( StreamingInputOutputOperationRequest.builder().applyMutation(streamingInputOutputOperationRequest).build(), requestBody, responseTransformer); } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows 'This be a stream' * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOutputOperation * @see #streamingInputOutputOperation(StreamingInputOutputOperationRequest, RequestBody) * @see #streamingInputOutputOperation(StreamingInputOutputOperationRequest, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ default StreamingInputOutputOperationResponse streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, Path sourcePath, Path destinationPath) throws AwsServiceException, SdkClientException, JsonException { return streamingInputOutputOperation(streamingInputOutputOperationRequest, RequestBody.fromFile(sourcePath), ResponseTransformer.toFile(destinationPath)); } /** * Some operation with streaming input and streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingInputOutputOperationRequest.Builder} * avoiding the need to create one manually via {@link StreamingInputOutputOperationRequest#builder()} * </p> * * @param streamingInputOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest.Builder} to create * a request. * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows 'This be a stream' * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOutputOperation * @see #streamingInputOutputOperation(StreamingInputOutputOperationRequest, RequestBody) * @see #streamingInputOutputOperation(StreamingInputOutputOperationRequest, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ default StreamingInputOutputOperationResponse streamingInputOutputOperation( Consumer<StreamingInputOutputOperationRequest.Builder> streamingInputOutputOperationRequest, Path sourcePath, Path destinationPath) throws AwsServiceException, SdkClientException, JsonException { return streamingInputOutputOperation( StreamingInputOutputOperationRequest.builder().applyMutation(streamingInputOutputOperationRequest).build(), sourcePath, destinationPath); } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { throw new UnsupportedOperationException(); } /** * Some operation with a streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingOutputOperationRequest#builder()} * </p> * * @param streamingOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a * request. * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default <ReturnT> ReturnT streamingOutputOperation( Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest) .build(), responseTransformer); } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see #streamingOutputOperation(StreamingOutputOperationRequest, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default StreamingOutputOperationResponse streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, Path destinationPath) throws AwsServiceException, SdkClientException, JsonException { return streamingOutputOperation(streamingOutputOperationRequest, ResponseTransformer.toFile(destinationPath)); } /** * Some operation with a streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingOutputOperationRequest#builder()} * </p> * * @param streamingOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a * request. * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see #streamingOutputOperation(StreamingOutputOperationRequest, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default StreamingOutputOperationResponse streamingOutputOperation( Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest, Path destinationPath) throws AwsServiceException, SdkClientException, JsonException { return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest) .build(), destinationPath); } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @return A {@link ResponseInputStream} containing data streamed from service. Note that this is an unmanaged * reference to the underlying HTTP connection so great care must be taken to ensure all data if fully read * from the input stream and that it is properly closed. Failure to do so may result in sub-optimal behavior * and exhausting connections in the connection pool. The unmarshalled response object can be obtained via * {@link ResponseInputStream#response()}. The service documentation for the response content is as follows * 'This be a stream'. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see #getObject(streamingOutputOperation, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default ResponseInputStream<StreamingOutputOperationResponse> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest) throws AwsServiceException, SdkClientException, JsonException { return streamingOutputOperation(streamingOutputOperationRequest, ResponseTransformer.toInputStream()); } /** * Some operation with a streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingOutputOperationRequest#builder()} * </p> * * @param streamingOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a * request. * @return A {@link ResponseInputStream} containing data streamed from service. Note that this is an unmanaged * reference to the underlying HTTP connection so great care must be taken to ensure all data if fully read * from the input stream and that it is properly closed. Failure to do so may result in sub-optimal behavior * and exhausting connections in the connection pool. The unmarshalled response object can be obtained via * {@link ResponseInputStream#response()}. The service documentation for the response content is as follows * 'This be a stream'. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see #getObject(streamingOutputOperation, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default ResponseInputStream<StreamingOutputOperationResponse> streamingOutputOperation( Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest) throws AwsServiceException, SdkClientException, JsonException { return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest) .build()); } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @return A {@link ResponseBytes} that loads the data streamed from the service into memory and exposes it in * convenient in-memory representations like a byte buffer or string. The unmarshalled response object can * be obtained via {@link ResponseBytes#response()}. The service documentation for the response content is * as follows 'This be a stream'. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see #getObject(streamingOutputOperation, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default ResponseBytes<StreamingOutputOperationResponse> streamingOutputOperationAsBytes( StreamingOutputOperationRequest streamingOutputOperationRequest) throws AwsServiceException, SdkClientException, JsonException { return streamingOutputOperation(streamingOutputOperationRequest, ResponseTransformer.toBytes()); } /** * Some operation with a streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingOutputOperationRequest#builder()} * </p> * * @param streamingOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a * request. * @return A {@link ResponseBytes} that loads the data streamed from the service into memory and exposes it in * convenient in-memory representations like a byte buffer or string. The unmarshalled response object can * be obtained via {@link ResponseBytes#response()}. The service documentation for the response content is * as follows 'This be a stream'. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see #getObject(streamingOutputOperation, ResponseTransformer) * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default ResponseBytes<StreamingOutputOperationResponse> streamingOutputOperationAsBytes( Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest) throws AwsServiceException, SdkClientException, JsonException { return streamingOutputOperationAsBytes(StreamingOutputOperationRequest.builder() .applyMutation(streamingOutputOperationRequest).build()); } /** * Creates an instance of {@link JsonUtilities} object with the configuration set on this client. */ default JsonUtilities utilities() { throw new UnsupportedOperationException(); } /** * Create a {@link JsonClient} with the region loaded from the * {@link software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain} and credentials loaded from the * {@link software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider}. */ static JsonClient create() { return builder().build(); } /** * Create a builder that can be used to configure and create a {@link JsonClient}. */ static JsonClientBuilder builder() { return new DefaultJsonClientBuilder(); } static ServiceMetadata serviceMetadata() { return ServiceMetadata.of(SERVICE_METADATA_ID); } @Override default JsonServiceClientConfiguration serviceClientConfiguration() { throw new UnsupportedOperationException(); } }
3,268
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-async-client-class.java
package software.amazon.awssdk.services.xml; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import java.util.function.Consumer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.signer.AsyncAws4Signer; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier; import software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.Response; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkPojoBuilder; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils; import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.xml.AwsXmlProtocolFactory; import software.amazon.awssdk.protocols.xml.XmlOperationMetadata; import software.amazon.awssdk.services.xml.internal.XmlServiceClientConfigurationBuilder; import software.amazon.awssdk.services.xml.model.APostOperationRequest; import software.amazon.awssdk.services.xml.model.APostOperationResponse; import software.amazon.awssdk.services.xml.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.xml.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.xml.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.xml.model.EventStream; import software.amazon.awssdk.services.xml.model.EventStreamOperationRequest; import software.amazon.awssdk.services.xml.model.EventStreamOperationResponse; import software.amazon.awssdk.services.xml.model.EventStreamOperationResponseHandler; import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.xml.model.InvalidInputException; import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.xml.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.xml.model.XmlException; import software.amazon.awssdk.services.xml.model.XmlRequest; import software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.xml.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.EventStreamOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.xml.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.Pair; /** * Internal implementation of {@link XmlAsyncClient}. * * @see XmlAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultXmlAsyncClient implements XmlAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultXmlAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_XML).build(); private final AsyncClientHandler clientHandler; private final AwsXmlProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private final Executor executor; protected DefaultXmlAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(); this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR); } /** * <p> * Performs a post operation to the xml service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(APostOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); String hostPrefix = "foo-"; String resolvedHostExpression = "foo-"; CompletableFuture<APostOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).hostPrefixExpression(resolvedHostExpression) .withMetricCollector(apiCallMetricCollector).withInput(aPostOperationRequest)); CompletableFuture<APostOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the xml service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); HttpResponseHandler<Response<APostOperationWithOutputResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(APostOperationWithOutputResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .withInput(aPostOperationWithOutputRequest)); CompletableFuture<APostOperationWithOutputResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the BearerAuthOperation operation asynchronously. * * @param bearerAuthOperationRequest * @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation( BearerAuthOperationRequest bearerAuthOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create()); HttpResponseHandler<Response<BearerAuthOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(BearerAuthOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).credentialType(CredentialType.TOKEN) .withMetricCollector(apiCallMetricCollector).withInput(bearerAuthOperationRequest)); CompletableFuture<BearerAuthOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperation operation asynchronously. * * @param eventStreamOperationRequest * @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.EventStreamOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/EventStreamOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest, EventStreamOperationResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation"); HttpResponseHandler<EventStreamOperationResponse> responseHandler = protocolFactory.createResponseHandler( EventStreamOperationResponse::builder, XmlOperationMetadata.builder().hasStreamingSuccessResponse(true) .build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( EventStreamTaggedUnionPojoSupplier.builder() .putSdkPojoSupplier("EventPayloadEvent", EventStream::eventPayloadEventBuilder) .putSdkPojoSupplier("NonEventPayloadEvent", EventStream::nonEventPayloadEventBuilder) .putSdkPojoSupplier("SecondEventPayloadEvent", EventStream::secondEventPayloadEventBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build(), XmlOperationMetadata .builder().hasStreamingSuccessResponse(false).build()); CompletableFuture<Void> eventStreamTransformFuture = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler) .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler) .exceptionResponseHandler(errorResponseHandler).future(eventStreamTransformFuture).executor(executor) .serviceName(serviceName()).build(); RestEventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder() .eventStreamAsyncResponseTransformer(asyncResponseTransformer) .eventStreamResponseHandler(asyncResponseHandler).build(); CompletableFuture<Void> executeFuture = clientHandler.execute( new ClientExecutionParams<EventStreamOperationRequest, EventStreamOperationResponse>() .withOperationName("EventStreamOperation").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest), restAsyncResponseTransformer); CompletableFuture<Void> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(e)); eventStreamTransformFuture.completeExceptionally(e); } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return CompletableFutureUtils.forwardExceptionTo(eventStreamTransformFuture, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the GetOperationWithChecksum operation asynchronously. * * @param getOperationWithChecksumRequest * @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); HttpResponseHandler<Response<GetOperationWithChecksumResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(GetOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest)); CompletableFuture<GetOperationWithChecksumResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithNoneAuthType operation asynchronously. * * @param operationWithNoneAuthTypeRequest * @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); HttpResponseHandler<Response<OperationWithNoneAuthTypeResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithNoneAuthTypeResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); HttpResponseHandler<Response<OperationWithRequestCompressionResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithRequestCompressionResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); CompletableFuture<OperationWithRequestCompressionResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the PutOperationWithChecksum operation asynchronously. * * @param putOperationWithChecksumRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); if (!isSignerOverridden(clientConfiguration)) { putOperationWithChecksumRequest = applySignerOverride(putOperationWithChecksumRequest, AsyncAws4Signer.create()); } HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true)); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()).withAsyncRequestBody(requestBody) .withInput(putOperationWithChecksumRequest), asyncResponseTransformer); CompletableFuture<ReturnT> whenCompleteFuture = null; AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); if (!isSignerOverridden(clientConfiguration)) { streamingInputOperationRequest = applySignerOverride(streamingInputOperationRequest, AsyncAws4Signer.create()); } HttpResponseHandler<Response<StreamingInputOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(StreamingInputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()).withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture<StreamingInputOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( StreamingOutputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true)); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(streamingOutputOperationRequest), asyncResponseTransformer); CompletableFuture<ReturnT> whenCompleteFuture = null; AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final XmlServiceClientConfiguration serviceClientConfiguration() { return new XmlServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private AwsXmlProtocolFactory init() { return AwsXmlProtocolFactory .builder() .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(XmlException::builder).build(); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private <T extends XmlRequest> T applySignerOverride(T request, Signer signer) { if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) { return request; } Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build(); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(signerOverride).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } private static boolean isSignerOverridden(SdkClientConfiguration clientConfiguration) { return Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.SIGNER_OVERRIDDEN)); } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); XmlServiceClientConfigurationBuilder serviceConfigBuilder = new XmlServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } @Override public void close() { clientHandler.close(); } }
3,269
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-xml-client-class.java
package software.amazon.awssdk.services.xml; import java.util.Collections; import java.util.List; import java.util.function.Consumer; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.Response; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.xml.AwsXmlProtocolFactory; import software.amazon.awssdk.protocols.xml.XmlOperationMetadata; import software.amazon.awssdk.services.xml.internal.XmlServiceClientConfigurationBuilder; import software.amazon.awssdk.services.xml.model.APostOperationRequest; import software.amazon.awssdk.services.xml.model.APostOperationResponse; import software.amazon.awssdk.services.xml.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.xml.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.xml.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.xml.model.InvalidInputException; import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.xml.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.xml.model.XmlException; import software.amazon.awssdk.services.xml.model.XmlRequest; import software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.xml.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.xml.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link XmlClient}. * * @see XmlClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultXmlClient implements XmlClient { private static final Logger log = Logger.loggerFor(DefaultXmlClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_XML).build(); private final SyncClientHandler clientHandler; private final AwsXmlProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultXmlClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsSyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(); } /** * <p> * Performs a post operation to the xml service and has no output * </p> * * @param aPostOperationRequest * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory.createCombinedResponseHandler( APostOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); String hostPrefix = "foo-"; String resolvedHostExpression = "foo-"; return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * <p> * Performs a post operation to the xml service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return Result of the APostOperationWithOutput operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public APostOperationWithOutputResponse aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<APostOperationWithOutputResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(APostOperationWithOutputResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); return clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the BearerAuthOperation operation. * * @param bearerAuthOperationRequest * @return Result of the BearerAuthOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest) throws AwsServiceException, SdkClientException, XmlException { bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create()); HttpResponseHandler<Response<BearerAuthOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(BearerAuthOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withInput(bearerAuthOperationRequest) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the GetOperationWithChecksum operation. * * @param getOperationWithChecksumRequest * @return Result of the GetOperationWithChecksum operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public GetOperationWithChecksumResponse getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<GetOperationWithChecksumResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(GetOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(getOperationWithChecksumRequest) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithChecksumRequired operation. * * @param operationWithChecksumRequiredRequest * @return Result of the OperationWithChecksumRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public OperationWithChecksumRequiredResponse operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); return clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithNoneAuthType operation. * * @param operationWithNoneAuthTypeRequest * @return Result of the OperationWithNoneAuthType operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public OperationWithNoneAuthTypeResponse operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<OperationWithNoneAuthTypeResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithNoneAuthTypeResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); return clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest) .putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithRequestCompression operation. * * @param operationWithRequestCompressionRequest * @return Result of the OperationWithRequestCompression operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public OperationWithRequestCompressionResponse operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<OperationWithRequestCompressionResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithRequestCompressionResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); return clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the PutOperationWithChecksum operation. * * @param putOperationWithChecksumRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true)); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(putOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<StreamingInputOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(StreamingInputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); return clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( StreamingOutputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true)); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); return clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } private <T extends XmlRequest> T applySignerOverride(T request, Signer signer) { if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) { return request; } Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build(); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(signerOverride).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); XmlServiceClientConfigurationBuilder serviceConfigBuilder = new XmlServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private AwsXmlProtocolFactory init() { return AwsXmlProtocolFactory .builder() .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(XmlException::builder).build(); } @Override public final XmlServiceClientConfiguration serviceClientConfiguration() { return new XmlServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public void close() { clientHandler.close(); } }
3,270
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-customservicemetadata-async.java
package software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.internal.ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.OneOperationRequest; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.OneOperationResponse; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.model.ProtocolRestJsonWithCustomContentTypeException; import software.amazon.awssdk.services.protocolrestjsonwithcustomcontenttype.transform.OneOperationRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; /** * Internal implementation of {@link ProtocolRestJsonWithCustomContentTypeAsyncClient}. * * @see ProtocolRestJsonWithCustomContentTypeAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultProtocolRestJsonWithCustomContentTypeAsyncClient implements ProtocolRestJsonWithCustomContentTypeAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultProtocolRestJsonWithCustomContentTypeAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_JSON).build(); private final AsyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultProtocolRestJsonWithCustomContentTypeAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); } /** * Invokes the OneOperation operation asynchronously. * * @param oneOperationRequest * @return A Java Future containing the result of the OneOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>ProtocolRestJsonWithCustomContentTypeException Base class for all service exceptions. Unknown * exceptions will be thrown as an instance of this type.</li> * </ul> * @sample ProtocolRestJsonWithCustomContentTypeAsyncClient.OneOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/restjson-2016-03-11/OneOperation" target="_top">AWS API * Documentation</a> */ @Override public CompletableFuture<OneOperationResponse> oneOperation(OneOperationRequest oneOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(oneOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, oneOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AmazonProtocolRestJsonWithCustomContentType"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OneOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OneOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata, OneOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OneOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OneOperationRequest, OneOperationResponse>() .withOperationName("OneOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new OneOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(oneOperationRequest)); CompletableFuture<OneOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final ProtocolRestJsonWithCustomContentTypeServiceClientConfiguration serviceClientConfiguration() { return new ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()) .build(); } @Override public final String serviceName() { return SERVICE_NAME; } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder.clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(ProtocolRestJsonWithCustomContentTypeException::builder) .protocol(AwsJsonProtocol.REST_JSON).protocolVersion("1.1").contentType("application/json"); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder serviceConfigBuilder = new ProtocolRestJsonWithCustomContentTypeServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }
3,271
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-json-async-client-interface.java
package software.amazon.awssdk.services.json; import java.nio.file.Path; import java.util.concurrent.CompletableFuture; import java.util.function.Consumer; import org.reactivestreams.Publisher; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.annotations.ThreadSafe; import software.amazon.awssdk.awscore.AwsClient; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.services.builder.Builder; import software.amazon.awssdk.services.builder.CustomBuilder; import software.amazon.awssdk.services.builder.DefaultBuilder; import software.amazon.awssdk.services.builder.DefaultBuilderTwo; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InputEventStream; import software.amazon.awssdk.services.json.model.InputEventStreamTwo; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher; import software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher; /** * Service client for accessing Json Service asynchronously. This can be created using the static {@link #builder()} * method. * * A service that is implemented using the query protocol */ @Generated("software.amazon.awssdk:codegen") @SdkPublicApi @ThreadSafe public interface JsonAsyncClient extends AwsClient { String SERVICE_NAME = "json-service"; /** * Value for looking up the service's metadata from the * {@link software.amazon.awssdk.regions.ServiceMetadataProvider}. */ String SERVICE_METADATA_ID = "json-service-endpoint"; /** * Creates an instance of {@link JsonUtilities} object with the configuration set on this client. */ default JsonUtilities utilities() { throw new UnsupportedOperationException(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> * * @deprecated This API is deprecated, use something else */ @Deprecated default CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { throw new UnsupportedOperationException(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * <br/> * <p> * This is a convenience which creates an instance of the {@link APostOperationRequest.Builder} avoiding the need to * create one manually via {@link APostOperationRequest#builder()} * </p> * * @param aPostOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.APostOperationRequest.Builder} to create a request. * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> * * @deprecated This API is deprecated, use something else */ @Deprecated default CompletableFuture<APostOperationResponse> aPostOperation(Consumer<APostOperationRequest.Builder> aPostOperationRequest) { return aPostOperation(APostOperationRequest.builder().applyMutation(aPostOperationRequest).build()); } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ default CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { throw new UnsupportedOperationException(); } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * <br/> * <p> * This is a convenience which creates an instance of the {@link APostOperationWithOutputRequest.Builder} avoiding * the need to create one manually via {@link APostOperationWithOutputRequest#builder()} * </p> * * @param aPostOperationWithOutputRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest.Builder} to create a * request. * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ default CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( Consumer<APostOperationWithOutputRequest.Builder> aPostOperationWithOutputRequest) { return aPostOperationWithOutput(APostOperationWithOutputRequest.builder().applyMutation(aPostOperationWithOutputRequest) .build()); } /** * Invokes the BearerAuthOperation operation asynchronously. * * @param bearerAuthOperationRequest * @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation( BearerAuthOperationRequest bearerAuthOperationRequest) { throw new UnsupportedOperationException(); } /** * Invokes the BearerAuthOperation operation asynchronously.<br/> * <p> * This is a convenience which creates an instance of the {@link BearerAuthOperationRequest.Builder} avoiding the * need to create one manually via {@link BearerAuthOperationRequest#builder()} * </p> * * @param bearerAuthOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.BearerAuthOperationRequest.Builder} to create a request. * @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation( Consumer<BearerAuthOperationRequest.Builder> bearerAuthOperationRequest) { return bearerAuthOperation(BearerAuthOperationRequest.builder().applyMutation(bearerAuthOperationRequest).build()); } /** * Invokes the EventStreamOperation operation asynchronously. * * @param eventStreamOperationRequest * @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest, Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) { throw new UnsupportedOperationException(); } /** * Invokes the EventStreamOperation operation asynchronously.<br/> * <p> * This is a convenience which creates an instance of the {@link EventStreamOperationRequest.Builder} avoiding the * need to create one manually via {@link EventStreamOperationRequest#builder()} * </p> * * @param eventStreamOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.EventStreamOperationRequest.Builder} to create a * request. * @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<Void> eventStreamOperation( Consumer<EventStreamOperationRequest.Builder> eventStreamOperationRequest, Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) { return eventStreamOperation(EventStreamOperationRequest.builder().applyMutation(eventStreamOperationRequest).build(), requestStream, asyncResponseHandler); } /** * Invokes the EventStreamOperationWithOnlyInput operation asynchronously. * * @param eventStreamOperationWithOnlyInputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyInput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput" * target="_top">AWS API Documentation</a> */ default CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput( EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest, Publisher<InputEventStreamTwo> requestStream) { throw new UnsupportedOperationException(); } /** * Invokes the EventStreamOperationWithOnlyInput operation asynchronously.<br/> * <p> * This is a convenience which creates an instance of the {@link EventStreamOperationWithOnlyInputRequest.Builder} * avoiding the need to create one manually via {@link EventStreamOperationWithOnlyInputRequest#builder()} * </p> * * @param eventStreamOperationWithOnlyInputRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest.Builder} to * create a request. * @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyInput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput" * target="_top">AWS API Documentation</a> */ default CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput( Consumer<EventStreamOperationWithOnlyInputRequest.Builder> eventStreamOperationWithOnlyInputRequest, Publisher<InputEventStreamTwo> requestStream) { return eventStreamOperationWithOnlyInput( EventStreamOperationWithOnlyInputRequest.builder().applyMutation(eventStreamOperationWithOnlyInputRequest) .build(), requestStream); } /** * Invokes the EventStreamOperationWithOnlyOutput operation asynchronously. * * @param eventStreamOperationWithOnlyOutputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput" * target="_top">AWS API Documentation</a> */ default CompletableFuture<Void> eventStreamOperationWithOnlyOutput( EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) { throw new UnsupportedOperationException(); } /** * Invokes the EventStreamOperationWithOnlyOutput operation asynchronously.<br/> * <p> * This is a convenience which creates an instance of the {@link EventStreamOperationWithOnlyOutputRequest.Builder} * avoiding the need to create one manually via {@link EventStreamOperationWithOnlyOutputRequest#builder()} * </p> * * @param eventStreamOperationWithOnlyOutputRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest.Builder} to * create a request. * @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput" * target="_top">AWS API Documentation</a> */ default CompletableFuture<Void> eventStreamOperationWithOnlyOutput( Consumer<EventStreamOperationWithOnlyOutputRequest.Builder> eventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) { return eventStreamOperationWithOnlyOutput( EventStreamOperationWithOnlyOutputRequest.builder().applyMutation(eventStreamOperationWithOnlyOutputRequest) .build(), asyncResponseHandler); } /** * Invokes the GetOperationWithChecksum operation asynchronously. * * @param getOperationWithChecksumRequest * @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) { throw new UnsupportedOperationException(); } /** * Invokes the GetOperationWithChecksum operation asynchronously.<br/> * <p> * This is a convenience which creates an instance of the {@link GetOperationWithChecksumRequest.Builder} avoiding * the need to create one manually via {@link GetOperationWithChecksumRequest#builder()} * </p> * * @param getOperationWithChecksumRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest.Builder} to create a * request. * @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum( Consumer<GetOperationWithChecksumRequest.Builder> getOperationWithChecksumRequest) { return getOperationWithChecksum(GetOperationWithChecksumRequest.builder().applyMutation(getOperationWithChecksumRequest) .build()); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ default CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) { throw new UnsupportedOperationException(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * <br/> * <p> * This is a convenience which creates an instance of the {@link GetWithoutRequiredMembersRequest.Builder} avoiding * the need to create one manually via {@link GetWithoutRequiredMembersRequest#builder()} * </p> * * @param getWithoutRequiredMembersRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest.Builder} to create a * request. * @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ default CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers( Consumer<GetWithoutRequiredMembersRequest.Builder> getWithoutRequiredMembersRequest) { return getWithoutRequiredMembers(GetWithoutRequiredMembersRequest.builder() .applyMutation(getWithoutRequiredMembersRequest).build()); } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ default CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { throw new UnsupportedOperationException(); } /** * Invokes the OperationWithChecksumRequired operation asynchronously.<br/> * <p> * This is a convenience which creates an instance of the {@link OperationWithChecksumRequiredRequest.Builder} * avoiding the need to create one manually via {@link OperationWithChecksumRequiredRequest#builder()} * </p> * * @param operationWithChecksumRequiredRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest.Builder} to create * a request. * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ default CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( Consumer<OperationWithChecksumRequiredRequest.Builder> operationWithChecksumRequiredRequest) { return operationWithChecksumRequired(OperationWithChecksumRequiredRequest.builder() .applyMutation(operationWithChecksumRequiredRequest).build()); } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ default CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { throw new UnsupportedOperationException(); } /** * Invokes the OperationWithRequestCompression operation asynchronously.<br/> * <p> * This is a convenience which creates an instance of the {@link OperationWithRequestCompressionRequest.Builder} * avoiding the need to create one manually via {@link OperationWithRequestCompressionRequest#builder()} * </p> * * @param operationWithRequestCompressionRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest.Builder} to * create a request. * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ default CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( Consumer<OperationWithRequestCompressionRequest.Builder> operationWithRequestCompressionRequest) { return operationWithRequestCompression(OperationWithRequestCompressionRequest.builder() .applyMutation(operationWithRequestCompressionRequest).build()); } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) { throw new UnsupportedOperationException(); } /** * Some paginated operation with result_key in paginators.json file<br/> * <p> * This is a convenience which creates an instance of the {@link PaginatedOperationWithResultKeyRequest.Builder} * avoiding the need to create one manually via {@link PaginatedOperationWithResultKeyRequest#builder()} * </p> * * @param paginatedOperationWithResultKeyRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest.Builder} to * create a request. * @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey( Consumer<PaginatedOperationWithResultKeyRequest.Builder> paginatedOperationWithResultKeyRequest) { return paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest.builder() .applyMutation(paginatedOperationWithResultKeyRequest).build()); } /** * Some paginated operation with result_key in paginators.json file * * @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey() { return paginatedOperationWithResultKey(PaginatedOperationWithResultKeyRequest.builder().build()); } /** * Some paginated operation with result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation. The return type is a custom publisher that can be subscribed to request a stream of response pages. * SDK will internally handle making service calls for you. * </p> * <p> * When the operation is called, an instance of this class is returned. At this point, no service calls are made yet * and so there is no guarantee that the request is valid. If there are errors in your request, you will see the * failures only after you start streaming the data. The subscribe method should be called as a request to start * streaming data. For more info, see * {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe * method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the * starting request. * </p> * * <p> * The following are few ways to use the response class: * </p> * 1) Using the subscribe helper method * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request); * CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response }); * future.get(); * } * </pre> * * 2) Using a custom subscriber * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request); * publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse>() { * * public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... }; * * * public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response) { //... }; * });} * </pre> * * As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2. * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation.</b> * </p> * * @return A custom publisher that can be subscribed to request a stream of response pages.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithResultKeyPublisher paginatedOperationWithResultKeyPaginator() { return paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest.builder().build()); } /** * Some paginated operation with result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation. The return type is a custom publisher that can be subscribed to request a stream of response pages. * SDK will internally handle making service calls for you. * </p> * <p> * When the operation is called, an instance of this class is returned. At this point, no service calls are made yet * and so there is no guarantee that the request is valid. If there are errors in your request, you will see the * failures only after you start streaming the data. The subscribe method should be called as a request to start * streaming data. For more info, see * {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe * method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the * starting request. * </p> * * <p> * The following are few ways to use the response class: * </p> * 1) Using the subscribe helper method * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request); * CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response }); * future.get(); * } * </pre> * * 2) Using a custom subscriber * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request); * publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse>() { * * public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... }; * * * public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response) { //... }; * });} * </pre> * * As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2. * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation.</b> * </p> * * @param paginatedOperationWithResultKeyRequest * @return A custom publisher that can be subscribed to request a stream of response pages.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithResultKeyPublisher paginatedOperationWithResultKeyPaginator( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) { return new PaginatedOperationWithResultKeyPublisher(this, paginatedOperationWithResultKeyRequest); } /** * Some paginated operation with result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation. The return type is a custom publisher that can be subscribed to request a stream of response pages. * SDK will internally handle making service calls for you. * </p> * <p> * When the operation is called, an instance of this class is returned. At this point, no service calls are made yet * and so there is no guarantee that the request is valid. If there are errors in your request, you will see the * failures only after you start streaming the data. The subscribe method should be called as a request to start * streaming data. For more info, see * {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe * method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the * starting request. * </p> * * <p> * The following are few ways to use the response class: * </p> * 1) Using the subscribe helper method * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request); * CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response }); * future.get(); * } * </pre> * * 2) Using a custom subscriber * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithResultKeyPublisher publisher = client.paginatedOperationWithResultKeyPaginator(request); * publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse>() { * * public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... }; * * * public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse response) { //... }; * });} * </pre> * * As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2. * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest)} * operation.</b> * </p> * <p> * This is a convenience which creates an instance of the {@link PaginatedOperationWithResultKeyRequest.Builder} * avoiding the need to create one manually via {@link PaginatedOperationWithResultKeyRequest#builder()} * </p> * * @param paginatedOperationWithResultKeyRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest.Builder} to * create a request. * @return A custom publisher that can be subscribed to request a stream of response pages.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithResultKeyPublisher paginatedOperationWithResultKeyPaginator( Consumer<PaginatedOperationWithResultKeyRequest.Builder> paginatedOperationWithResultKeyRequest) { return paginatedOperationWithResultKeyPaginator(PaginatedOperationWithResultKeyRequest.builder() .applyMutation(paginatedOperationWithResultKeyRequest).build()); } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ default CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) { throw new UnsupportedOperationException(); } /** * Some paginated operation without result_key in paginators.json file<br/> * <p> * This is a convenience which creates an instance of the {@link PaginatedOperationWithoutResultKeyRequest.Builder} * avoiding the need to create one manually via {@link PaginatedOperationWithoutResultKeyRequest#builder()} * </p> * * @param paginatedOperationWithoutResultKeyRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest.Builder} to * create a request. * @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ default CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey( Consumer<PaginatedOperationWithoutResultKeyRequest.Builder> paginatedOperationWithoutResultKeyRequest) { return paginatedOperationWithoutResultKey(PaginatedOperationWithoutResultKeyRequest.builder() .applyMutation(paginatedOperationWithoutResultKeyRequest).build()); } /** * Some paginated operation without result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)} * operation. The return type is a custom publisher that can be subscribed to request a stream of response pages. * SDK will internally handle making service calls for you. * </p> * <p> * When the operation is called, an instance of this class is returned. At this point, no service calls are made yet * and so there is no guarantee that the request is valid. If there are errors in your request, you will see the * failures only after you start streaming the data. The subscribe method should be called as a request to start * streaming data. For more info, see * {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe * method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the * starting request. * </p> * * <p> * The following are few ways to use the response class: * </p> * 1) Using the subscribe helper method * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request); * CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response }); * future.get(); * } * </pre> * * 2) Using a custom subscriber * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request); * publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse>() { * * public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... }; * * * public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse response) { //... }; * });} * </pre> * * As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2. * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)} * operation.</b> * </p> * * @param paginatedOperationWithoutResultKeyRequest * @return A custom publisher that can be subscribed to request a stream of response pages.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithoutResultKeyPublisher paginatedOperationWithoutResultKeyPaginator( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) { return new PaginatedOperationWithoutResultKeyPublisher(this, paginatedOperationWithoutResultKeyRequest); } /** * Some paginated operation without result_key in paginators.json file<br/> * <p> * This is a variant of * {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)} * operation. The return type is a custom publisher that can be subscribed to request a stream of response pages. * SDK will internally handle making service calls for you. * </p> * <p> * When the operation is called, an instance of this class is returned. At this point, no service calls are made yet * and so there is no guarantee that the request is valid. If there are errors in your request, you will see the * failures only after you start streaming the data. The subscribe method should be called as a request to start * streaming data. For more info, see * {@link org.reactivestreams.Publisher#subscribe(org.reactivestreams.Subscriber)}. Each call to the subscribe * method will result in a new {@link org.reactivestreams.Subscription} i.e., a new contract to stream data from the * starting request. * </p> * * <p> * The following are few ways to use the response class: * </p> * 1) Using the subscribe helper method * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request); * CompletableFuture<Void> future = publisher.subscribe(res -> { // Do something with the response }); * future.get(); * } * </pre> * * 2) Using a custom subscriber * * <pre> * {@code * software.amazon.awssdk.services.json.paginators.PaginatedOperationWithoutResultKeyPublisher publisher = client.paginatedOperationWithoutResultKeyPaginator(request); * publisher.subscribe(new Subscriber<software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse>() { * * public void onSubscribe(org.reactivestreams.Subscriber subscription) { //... }; * * * public void onNext(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse response) { //... }; * });} * </pre> * * As the response is a publisher, it can work well with third party reactive streams implementations like RxJava2. * <p> * <b>Please notice that the configuration of MaxResults won't limit the number of results you get with the * paginator. It only limits the number of results in each page.</b> * </p> * <p> * <b>Note: If you prefer to have control on service calls, use the * {@link #paginatedOperationWithoutResultKey(software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest)} * operation.</b> * </p> * <p> * This is a convenience which creates an instance of the {@link PaginatedOperationWithoutResultKeyRequest.Builder} * avoiding the need to create one manually via {@link PaginatedOperationWithoutResultKeyRequest#builder()} * </p> * * @param paginatedOperationWithoutResultKeyRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest.Builder} to * create a request. * @return A custom publisher that can be subscribed to request a stream of response pages.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ default PaginatedOperationWithoutResultKeyPublisher paginatedOperationWithoutResultKeyPaginator( Consumer<PaginatedOperationWithoutResultKeyRequest.Builder> paginatedOperationWithoutResultKeyRequest) { return paginatedOperationWithoutResultKeyPaginator(PaginatedOperationWithoutResultKeyRequest.builder() .applyMutation(paginatedOperationWithoutResultKeyRequest).build()); } /** * Invokes the PutOperationWithChecksum operation asynchronously. * * @param putOperationWithChecksumRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) { throw new UnsupportedOperationException(); } /** * Invokes the PutOperationWithChecksum operation asynchronously.<br/> * <p> * This is a convenience which creates an instance of the {@link PutOperationWithChecksumRequest.Builder} avoiding * the need to create one manually via {@link PutOperationWithChecksumRequest#builder()} * </p> * * @param putOperationWithChecksumRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest.Builder} to create a * request. * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum( Consumer<PutOperationWithChecksumRequest.Builder> putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) { return putOperationWithChecksum(PutOperationWithChecksumRequest.builder().applyMutation(putOperationWithChecksumRequest) .build(), requestBody, asyncResponseTransformer); } /** * Invokes the PutOperationWithChecksum operation asynchronously. * * @param putOperationWithChecksumRequest * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows ' * <p> * Object data. * </p> * ' * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default CompletableFuture<PutOperationWithChecksumResponse> putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, Path sourcePath, Path destinationPath) { return putOperationWithChecksum(putOperationWithChecksumRequest, AsyncRequestBody.fromFile(sourcePath), AsyncResponseTransformer.toFile(destinationPath)); } /** * Invokes the PutOperationWithChecksum operation asynchronously.<br/> * <p> * This is a convenience which creates an instance of the {@link PutOperationWithChecksumRequest.Builder} avoiding * the need to create one manually via {@link PutOperationWithChecksumRequest#builder()} * </p> * * @param putOperationWithChecksumRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest.Builder} to create a * request. * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows ' * <p> * Object data. * </p> * ' * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ default CompletableFuture<PutOperationWithChecksumResponse> putOperationWithChecksum( Consumer<PutOperationWithChecksumRequest.Builder> putOperationWithChecksumRequest, Path sourcePath, Path destinationPath) { return putOperationWithChecksum(PutOperationWithChecksumRequest.builder().applyMutation(putOperationWithChecksumRequest) .build(), sourcePath, destinationPath); } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { throw new UnsupportedOperationException(); } /** * Some operation with a streaming input<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingInputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingInputOperationRequest#builder()} * </p> * * @param streamingInputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingInputOperationRequest.Builder} to create a * request. * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( Consumer<StreamingInputOperationRequest.Builder> streamingInputOperationRequest, AsyncRequestBody requestBody) { return streamingInputOperation(StreamingInputOperationRequest.builder().applyMutation(streamingInputOperationRequest) .build(), requestBody); } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, Path sourcePath) { return streamingInputOperation(streamingInputOperationRequest, AsyncRequestBody.fromFile(sourcePath)); } /** * Some operation with a streaming input<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingInputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingInputOperationRequest#builder()} * </p> * * @param streamingInputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingInputOperationRequest.Builder} to create a * request. * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( Consumer<StreamingInputOperationRequest.Builder> streamingInputOperationRequest, Path sourcePath) { return streamingInputOperation(StreamingInputOperationRequest.builder().applyMutation(streamingInputOperationRequest) .build(), sourcePath); } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ default <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) { throw new UnsupportedOperationException(); } /** * Some operation with streaming input and streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingInputOutputOperationRequest.Builder} * avoiding the need to create one manually via {@link StreamingInputOutputOperationRequest#builder()} * </p> * * @param streamingInputOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest.Builder} to create * a request. * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ default <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation( Consumer<StreamingInputOutputOperationRequest.Builder> streamingInputOutputOperationRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) { return streamingInputOutputOperation( StreamingInputOutputOperationRequest.builder().applyMutation(streamingInputOutputOperationRequest).build(), requestBody, asyncResponseTransformer); } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows 'This be a stream' * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<StreamingInputOutputOperationResponse> streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, Path sourcePath, Path destinationPath) { return streamingInputOutputOperation(streamingInputOutputOperationRequest, AsyncRequestBody.fromFile(sourcePath), AsyncResponseTransformer.toFile(destinationPath)); } /** * Some operation with streaming input and streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingInputOutputOperationRequest.Builder} * avoiding the need to create one manually via {@link StreamingInputOutputOperationRequest#builder()} * </p> * * @param streamingInputOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest.Builder} to create * a request. * @param sourcePath * {@link Path} to file containing data to send to the service. File will be read entirely and may be read * multiple times in the event of a retry. If the file does not exist or the current user does not have * access to read it then an exception will be thrown. The service documentation for the request content is * as follows 'This be a stream' * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<StreamingInputOutputOperationResponse> streamingInputOutputOperation( Consumer<StreamingInputOutputOperationRequest.Builder> streamingInputOutputOperationRequest, Path sourcePath, Path destinationPath) { return streamingInputOutputOperation( StreamingInputOutputOperationRequest.builder().applyMutation(streamingInputOutputOperationRequest).build(), sourcePath, destinationPath); } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { throw new UnsupportedOperationException(); } /** * Some operation with a streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingOutputOperationRequest#builder()} * </p> * * @param streamingOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a * request. * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest) .build(), asyncResponseTransformer); } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<StreamingOutputOperationResponse> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, Path destinationPath) { return streamingOutputOperation(streamingOutputOperationRequest, AsyncResponseTransformer.toFile(destinationPath)); } /** * Some operation with a streaming output<br/> * <p> * This is a convenience which creates an instance of the {@link StreamingOutputOperationRequest.Builder} avoiding * the need to create one manually via {@link StreamingOutputOperationRequest#builder()} * </p> * * @param streamingOutputOperationRequest * A {@link Consumer} that will call methods on * {@link software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest.Builder} to create a * request. * @param destinationPath * {@link Path} to file that response contents will be written to. The file must not exist or this method * will throw an exception. If the file is not writable by the current user then an exception will be thrown. * The service documentation for the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ default CompletableFuture<StreamingOutputOperationResponse> streamingOutputOperation( Consumer<StreamingOutputOperationRequest.Builder> streamingOutputOperationRequest, Path destinationPath) { return streamingOutputOperation(StreamingOutputOperationRequest.builder().applyMutation(streamingOutputOperationRequest) .build(), destinationPath); } @Override default JsonServiceClientConfiguration serviceClientConfiguration() { throw new UnsupportedOperationException(); } /** * Create a {@link JsonAsyncClient} with the region loaded from the * {@link software.amazon.awssdk.regions.providers.DefaultAwsRegionProviderChain} and credentials loaded from the * {@link software.amazon.awssdk.auth.credentials.DefaultCredentialsProvider}. */ static JsonAsyncClient create() { return builder().build(); } /** * Create a builder that can be used to configure and create a {@link JsonAsyncClient}. */ static JsonAsyncClientBuilder builder() { return new DefaultJsonAsyncClientBuilder(); } /** * Create a default builder */ static CustomBuilder builderOne() { return DefaultBuilder.builder().build(); } /** * Create a default builder two */ static Builder builderTwo() { return DefaultBuilderTwo.builder2().build(); } }
3,272
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-async.java
package software.amazon.awssdk.services.endpointdiscoverytest; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.net.URI; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRefreshCache; import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRequest; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.endpointdiscoverytest.internal.EndpointDiscoveryTestServiceClientConfigurationBuilder; import software.amazon.awssdk.services.endpointdiscoverytest.model.DescribeEndpointsRequest; import software.amazon.awssdk.services.endpointdiscoverytest.model.DescribeEndpointsResponse; import software.amazon.awssdk.services.endpointdiscoverytest.model.EndpointDiscoveryTestException; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryIdentifiersRequiredRequest; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryIdentifiersRequiredResponse; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryOptionalRequest; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryOptionalResponse; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryRequiredRequest; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryRequiredResponse; import software.amazon.awssdk.services.endpointdiscoverytest.transform.DescribeEndpointsRequestMarshaller; import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryIdentifiersRequiredRequestMarshaller; import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryOptionalRequestMarshaller; import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryRequiredRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; /** * Internal implementation of {@link EndpointDiscoveryTestAsyncClient}. * * @see EndpointDiscoveryTestAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultEndpointDiscoveryTestAsyncClient implements EndpointDiscoveryTestAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultEndpointDiscoveryTestAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.AWS_JSON).build(); private final AsyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private EndpointDiscoveryRefreshCache endpointDiscoveryCache; protected DefaultEndpointDiscoveryTestAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) { this.endpointDiscoveryCache = EndpointDiscoveryRefreshCache .create(EndpointDiscoveryTestAsyncEndpointDiscoveryCacheLoader.create(this)); } } /** * Invokes the DescribeEndpoints operation asynchronously. * * @param describeEndpointsRequest * @return A Java Future containing the result of the DescribeEndpoints operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>EndpointDiscoveryTestException Base class for all service exceptions. Unknown exceptions will be * thrown as an instance of this type.</li> * </ul> * @sample EndpointDiscoveryTestAsyncClient.DescribeEndpoints */ @Override public CompletableFuture<DescribeEndpointsResponse> describeEndpoints(DescribeEndpointsRequest describeEndpointsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeEndpointsRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, describeEndpointsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeEndpoints"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<DescribeEndpointsResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, DescribeEndpointsResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<DescribeEndpointsResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<DescribeEndpointsRequest, DescribeEndpointsResponse>() .withOperationName("DescribeEndpoints").withProtocolMetadata(protocolMetadata) .withMarshaller(new DescribeEndpointsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(describeEndpointsRequest)); CompletableFuture<DescribeEndpointsResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the TestDiscoveryIdentifiersRequired operation asynchronously. * * @param testDiscoveryIdentifiersRequiredRequest * @return A Java Future containing the result of the TestDiscoveryIdentifiersRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>EndpointDiscoveryTestException Base class for all service exceptions. Unknown exceptions will be * thrown as an instance of this type.</li> * </ul> * @sample EndpointDiscoveryTestAsyncClient.TestDiscoveryIdentifiersRequired */ @Override public CompletableFuture<TestDiscoveryIdentifiersRequiredResponse> testDiscoveryIdentifiersRequired( TestDiscoveryIdentifiersRequiredRequest testDiscoveryIdentifiersRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryIdentifiersRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryIdentifiersRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryIdentifiersRequired"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<TestDiscoveryIdentifiersRequiredResponse> responseHandler = protocolFactory .createResponseHandler(operationMetadata, TestDiscoveryIdentifiersRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; if (endpointOverridden) { throw new IllegalStateException( "This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported."); } if (!endpointDiscoveryEnabled) { throw new IllegalStateException( "This operation requires endpoint discovery, but endpoint discovery was disabled on the client."); } CompletableFuture<URI> endpointFuture = CompletableFuture.completedFuture(null); if (endpointDiscoveryEnabled) { CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryIdentifiersRequiredRequest .overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider) .orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)) .resolveIdentity(); endpointFuture = identityFuture.thenApply(credentials -> { EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true) .defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)) .overrideConfiguration(testDiscoveryIdentifiersRequiredRequest.overrideConfiguration().orElse(null)) .build(); return endpointDiscoveryCache.get(credentials.accessKeyId(), endpointDiscoveryRequest); }); } CompletableFuture<TestDiscoveryIdentifiersRequiredResponse> executeFuture = endpointFuture .thenCompose(cachedEndpoint -> clientHandler .execute(new ClientExecutionParams<TestDiscoveryIdentifiersRequiredRequest, TestDiscoveryIdentifiersRequiredResponse>() .withOperationName("TestDiscoveryIdentifiersRequired").withProtocolMetadata(protocolMetadata) .withMarshaller(new TestDiscoveryIdentifiersRequiredRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryIdentifiersRequiredRequest))); CompletableFuture<TestDiscoveryIdentifiersRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the TestDiscoveryOptional operation asynchronously. * * @param testDiscoveryOptionalRequest * @return A Java Future containing the result of the TestDiscoveryOptional operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>EndpointDiscoveryTestException Base class for all service exceptions. Unknown exceptions will be * thrown as an instance of this type.</li> * </ul> * @sample EndpointDiscoveryTestAsyncClient.TestDiscoveryOptional */ @Override public CompletableFuture<TestDiscoveryOptionalResponse> testDiscoveryOptional( TestDiscoveryOptionalRequest testDiscoveryOptionalRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryOptionalRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryOptionalRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryOptional"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<TestDiscoveryOptionalResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, TestDiscoveryOptionalResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; CompletableFuture<URI> endpointFuture = CompletableFuture.completedFuture(null); if (endpointDiscoveryEnabled) { CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryOptionalRequest .overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider) .orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)) .resolveIdentity(); endpointFuture = identityFuture.thenApply(credentials -> { EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(false) .defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)) .overrideConfiguration(testDiscoveryOptionalRequest.overrideConfiguration().orElse(null)).build(); return endpointDiscoveryCache.get(credentials.accessKeyId(), endpointDiscoveryRequest); }); } CompletableFuture<TestDiscoveryOptionalResponse> executeFuture = endpointFuture .thenCompose(cachedEndpoint -> clientHandler .execute(new ClientExecutionParams<TestDiscoveryOptionalRequest, TestDiscoveryOptionalResponse>() .withOperationName("TestDiscoveryOptional").withProtocolMetadata(protocolMetadata) .withMarshaller(new TestDiscoveryOptionalRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryOptionalRequest))); CompletableFuture<TestDiscoveryOptionalResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the TestDiscoveryRequired operation asynchronously. * * @param testDiscoveryRequiredRequest * @return A Java Future containing the result of the TestDiscoveryRequired operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>EndpointDiscoveryTestException Base class for all service exceptions. Unknown exceptions will be * thrown as an instance of this type.</li> * </ul> * @sample EndpointDiscoveryTestAsyncClient.TestDiscoveryRequired */ @Override public CompletableFuture<TestDiscoveryRequiredResponse> testDiscoveryRequired( TestDiscoveryRequiredRequest testDiscoveryRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryRequiredRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryRequired"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<TestDiscoveryRequiredResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, TestDiscoveryRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; if (endpointOverridden) { throw new IllegalStateException( "This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported."); } if (!endpointDiscoveryEnabled) { throw new IllegalStateException( "This operation requires endpoint discovery, but endpoint discovery was disabled on the client."); } CompletableFuture<URI> endpointFuture = CompletableFuture.completedFuture(null); if (endpointDiscoveryEnabled) { CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryRequiredRequest .overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider) .orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)) .resolveIdentity(); endpointFuture = identityFuture.thenApply(credentials -> { EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true) .defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)) .overrideConfiguration(testDiscoveryRequiredRequest.overrideConfiguration().orElse(null)).build(); return endpointDiscoveryCache.get(credentials.accessKeyId(), endpointDiscoveryRequest); }); } CompletableFuture<TestDiscoveryRequiredResponse> executeFuture = endpointFuture .thenCompose(cachedEndpoint -> clientHandler .execute(new ClientExecutionParams<TestDiscoveryRequiredRequest, TestDiscoveryRequiredResponse>() .withOperationName("TestDiscoveryRequired").withProtocolMetadata(protocolMetadata) .withMarshaller(new TestDiscoveryRequiredRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .discoveredEndpoint(cachedEndpoint).withInput(testDiscoveryRequiredRequest))); CompletableFuture<TestDiscoveryRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final EndpointDiscoveryTestServiceClientConfiguration serviceClientConfiguration() { return new EndpointDiscoveryTestServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder.clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(EndpointDiscoveryTestException::builder).protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1"); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); EndpointDiscoveryTestServiceClientConfigurationBuilder serviceConfigBuilder = new EndpointDiscoveryTestServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }
3,273
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-endpoint-discovery-sync.java
package software.amazon.awssdk.services.endpointdiscoverytest; import java.net.URI; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.awscore.client.config.AwsClientOption; import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRefreshCache; import software.amazon.awssdk.core.endpointdiscovery.EndpointDiscoveryRequest; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.identity.spi.AwsCredentialsIdentity; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.endpointdiscoverytest.internal.EndpointDiscoveryTestServiceClientConfigurationBuilder; import software.amazon.awssdk.services.endpointdiscoverytest.model.DescribeEndpointsRequest; import software.amazon.awssdk.services.endpointdiscoverytest.model.DescribeEndpointsResponse; import software.amazon.awssdk.services.endpointdiscoverytest.model.EndpointDiscoveryTestException; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryIdentifiersRequiredRequest; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryIdentifiersRequiredResponse; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryOptionalRequest; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryOptionalResponse; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryRequiredRequest; import software.amazon.awssdk.services.endpointdiscoverytest.model.TestDiscoveryRequiredResponse; import software.amazon.awssdk.services.endpointdiscoverytest.transform.DescribeEndpointsRequestMarshaller; import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryIdentifiersRequiredRequestMarshaller; import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryOptionalRequestMarshaller; import software.amazon.awssdk.services.endpointdiscoverytest.transform.TestDiscoveryRequiredRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link EndpointDiscoveryTestClient}. * * @see EndpointDiscoveryTestClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultEndpointDiscoveryTestClient implements EndpointDiscoveryTestClient { private static final Logger log = Logger.loggerFor(DefaultEndpointDiscoveryTestClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.AWS_JSON).build(); private final SyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private EndpointDiscoveryRefreshCache endpointDiscoveryCache; protected DefaultEndpointDiscoveryTestClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsSyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); if (clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED)) { this.endpointDiscoveryCache = EndpointDiscoveryRefreshCache.create(EndpointDiscoveryTestEndpointDiscoveryCacheLoader .create(this)); } } /** * Invokes the DescribeEndpoints operation. * * @param describeEndpointsRequest * @return Result of the DescribeEndpoints operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws EndpointDiscoveryTestException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample EndpointDiscoveryTestClient.DescribeEndpoints */ @Override public DescribeEndpointsResponse describeEndpoints(DescribeEndpointsRequest describeEndpointsRequest) throws AwsServiceException, SdkClientException, EndpointDiscoveryTestException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<DescribeEndpointsResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata, DescribeEndpointsResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(describeEndpointsRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, describeEndpointsRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "DescribeEndpoints"); return clientHandler.execute(new ClientExecutionParams<DescribeEndpointsRequest, DescribeEndpointsResponse>() .withOperationName("DescribeEndpoints").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(describeEndpointsRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new DescribeEndpointsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the TestDiscoveryIdentifiersRequired operation. * * @param testDiscoveryIdentifiersRequiredRequest * @return Result of the TestDiscoveryIdentifiersRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws EndpointDiscoveryTestException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample EndpointDiscoveryTestClient.TestDiscoveryIdentifiersRequired */ @Override public TestDiscoveryIdentifiersRequiredResponse testDiscoveryIdentifiersRequired( TestDiscoveryIdentifiersRequiredRequest testDiscoveryIdentifiersRequiredRequest) throws AwsServiceException, SdkClientException, EndpointDiscoveryTestException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<TestDiscoveryIdentifiersRequiredResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, TestDiscoveryIdentifiersRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; if (endpointOverridden) { throw new IllegalStateException( "This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported."); } if (!endpointDiscoveryEnabled) { throw new IllegalStateException( "This operation requires endpoint discovery, but endpoint discovery was disabled on the client."); } URI cachedEndpoint = null; if (endpointDiscoveryEnabled) { CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryIdentifiersRequiredRequest .overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider) .orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)).resolveIdentity(); String key = CompletableFutureUtils.joinLikeSync(identityFuture).accessKeyId(); EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true) .defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)) .overrideConfiguration(testDiscoveryIdentifiersRequiredRequest.overrideConfiguration().orElse(null)).build(); cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest); } SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryIdentifiersRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryIdentifiersRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryIdentifiersRequired"); return clientHandler .execute(new ClientExecutionParams<TestDiscoveryIdentifiersRequiredRequest, TestDiscoveryIdentifiersRequiredResponse>() .withOperationName("TestDiscoveryIdentifiersRequired").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .discoveredEndpoint(cachedEndpoint).withRequestConfiguration(clientConfiguration) .withInput(testDiscoveryIdentifiersRequiredRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new TestDiscoveryIdentifiersRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the TestDiscoveryOptional operation. * * @param testDiscoveryOptionalRequest * @return Result of the TestDiscoveryOptional operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws EndpointDiscoveryTestException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample EndpointDiscoveryTestClient.TestDiscoveryOptional */ @Override public TestDiscoveryOptionalResponse testDiscoveryOptional(TestDiscoveryOptionalRequest testDiscoveryOptionalRequest) throws AwsServiceException, SdkClientException, EndpointDiscoveryTestException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<TestDiscoveryOptionalResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, TestDiscoveryOptionalResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; URI cachedEndpoint = null; if (endpointDiscoveryEnabled) { CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryOptionalRequest .overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider) .orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)).resolveIdentity(); String key = CompletableFutureUtils.joinLikeSync(identityFuture).accessKeyId(); EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(false) .defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)) .overrideConfiguration(testDiscoveryOptionalRequest.overrideConfiguration().orElse(null)).build(); cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest); } SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryOptionalRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryOptionalRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryOptional"); return clientHandler.execute(new ClientExecutionParams<TestDiscoveryOptionalRequest, TestDiscoveryOptionalResponse>() .withOperationName("TestDiscoveryOptional").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .discoveredEndpoint(cachedEndpoint).withRequestConfiguration(clientConfiguration) .withInput(testDiscoveryOptionalRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new TestDiscoveryOptionalRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the TestDiscoveryRequired operation. * * @param testDiscoveryRequiredRequest * @return Result of the TestDiscoveryRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws EndpointDiscoveryTestException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample EndpointDiscoveryTestClient.TestDiscoveryRequired */ @Override public TestDiscoveryRequiredResponse testDiscoveryRequired(TestDiscoveryRequiredRequest testDiscoveryRequiredRequest) throws AwsServiceException, SdkClientException, EndpointDiscoveryTestException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<TestDiscoveryRequiredResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, TestDiscoveryRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); boolean endpointDiscoveryEnabled = clientConfiguration.option(SdkClientOption.ENDPOINT_DISCOVERY_ENABLED); boolean endpointOverridden = clientConfiguration.option(SdkClientOption.ENDPOINT_OVERRIDDEN) == Boolean.TRUE; if (endpointOverridden) { throw new IllegalStateException( "This operation requires endpoint discovery, but an endpoint override was specified when the client was created. This is not supported."); } if (!endpointDiscoveryEnabled) { throw new IllegalStateException( "This operation requires endpoint discovery, but endpoint discovery was disabled on the client."); } URI cachedEndpoint = null; if (endpointDiscoveryEnabled) { CompletableFuture<? extends AwsCredentialsIdentity> identityFuture = testDiscoveryRequiredRequest .overrideConfiguration().flatMap(AwsRequestOverrideConfiguration::credentialsIdentityProvider) .orElseGet(() -> clientConfiguration.option(AwsClientOption.CREDENTIALS_IDENTITY_PROVIDER)).resolveIdentity(); String key = CompletableFutureUtils.joinLikeSync(identityFuture).accessKeyId(); EndpointDiscoveryRequest endpointDiscoveryRequest = EndpointDiscoveryRequest.builder().required(true) .defaultEndpoint(clientConfiguration.option(SdkClientOption.ENDPOINT)) .overrideConfiguration(testDiscoveryRequiredRequest.overrideConfiguration().orElse(null)).build(); cachedEndpoint = endpointDiscoveryCache.get(key, endpointDiscoveryRequest); } SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(testDiscoveryRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, testDiscoveryRequiredRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "AwsEndpointDiscoveryTest"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "TestDiscoveryRequired"); return clientHandler.execute(new ClientExecutionParams<TestDiscoveryRequiredRequest, TestDiscoveryRequiredResponse>() .withOperationName("TestDiscoveryRequired").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .discoveredEndpoint(cachedEndpoint).withRequestConfiguration(clientConfiguration) .withInput(testDiscoveryRequiredRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new TestDiscoveryRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } @Override public final String serviceName() { return SERVICE_NAME; } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); EndpointDiscoveryTestServiceClientConfigurationBuilder serviceConfigBuilder = new EndpointDiscoveryTestServiceClientConfigurationBuilder( configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder.clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(EndpointDiscoveryTestException::builder).protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1"); } @Override public final EndpointDiscoveryTestServiceClientConfiguration serviceClientConfiguration() { return new EndpointDiscoveryTestServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public void close() { clientHandler.close(); } }
3,274
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-query-async-client-class.java
package software.amazon.awssdk.services.query; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ScheduledExecutorService; import java.util.function.Consumer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.auth.signer.AsyncAws4Signer; import software.amazon.awssdk.auth.token.signer.aws.BearerTokenSigner; import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; import software.amazon.awssdk.core.signer.Signer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory; import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder; import software.amazon.awssdk.services.query.model.APostOperationRequest; import software.amazon.awssdk.services.query.model.APostOperationResponse; import software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.query.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.query.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.query.model.InvalidInputException; import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest; import software.amazon.awssdk.services.query.model.OperationWithContextParamResponse; import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsRequest; import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsResponse; import software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.query.model.QueryException; import software.amazon.awssdk.services.query.model.QueryRequest; import software.amazon.awssdk.services.query.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.query.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.query.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithContextParamRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithStaticContextParamsRequestMarshaller; import software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.services.query.waiters.QueryAsyncWaiter; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.Pair; /** * Internal implementation of {@link QueryAsyncClient}. * * @see QueryAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultQueryAsyncClient implements QueryAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultQueryAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.QUERY).build(); private final AsyncClientHandler clientHandler; private final AwsQueryProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private final ScheduledExecutorService executorService; protected DefaultQueryAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(); this.executorService = clientConfiguration.option(SdkClientOption.SCHEDULED_EXECUTOR_SERVICE); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory .createResponseHandler(APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); String hostPrefix = "foo-"; String resolvedHostExpression = "foo-"; CompletableFuture<APostOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture<APostOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory .createResponseHandler(APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(aPostOperationWithOutputRequest)); CompletableFuture<APostOperationWithOutputResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the BearerAuthOperation operation asynchronously. * * @param bearerAuthOperationRequest * @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation( BearerAuthOperationRequest bearerAuthOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); bearerAuthOperationRequest = applySignerOverride(bearerAuthOperationRequest, BearerTokenSigner.create()); HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory .createResponseHandler(BearerAuthOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withInput(bearerAuthOperationRequest)); CompletableFuture<BearerAuthOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the GetOperationWithChecksum operation asynchronously. * * @param getOperationWithChecksumRequest * @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory .createResponseHandler(GetOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest)); CompletableFuture<GetOperationWithChecksumResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithContextParam operation asynchronously. * * @param operationWithContextParamRequest * @return A Java Future containing the result of the OperationWithContextParam operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithContextParam * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithContextParam" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithContextParamResponse> operationWithContextParam( OperationWithContextParamRequest operationWithContextParamRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithContextParamRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithContextParamRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithContextParam"); HttpResponseHandler<OperationWithContextParamResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithContextParamResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithContextParamResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithContextParamRequest, OperationWithContextParamResponse>() .withOperationName("OperationWithContextParam").withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(operationWithContextParamRequest)); CompletableFuture<OperationWithContextParamResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithNoneAuthType operation asynchronously. * * @param operationWithNoneAuthTypeRequest * @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithNoneAuthTypeResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.IS_NONE_AUTH_TYPE_REQUEST, false) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); CompletableFuture<OperationWithRequestCompressionResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithStaticContextParams operation asynchronously. * * @param operationWithStaticContextParamsRequest * @return A Java Future containing the result of the OperationWithStaticContextParams operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithStaticContextParams * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithStaticContextParams" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithStaticContextParamsResponse> operationWithStaticContextParams( OperationWithStaticContextParamsRequest operationWithStaticContextParamsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithStaticContextParamsRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithStaticContextParamsRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithStaticContextParams"); HttpResponseHandler<OperationWithStaticContextParamsResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithStaticContextParamsResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithStaticContextParamsResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithStaticContextParamsRequest, OperationWithStaticContextParamsResponse>() .withOperationName("OperationWithStaticContextParams").withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithStaticContextParamsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(operationWithStaticContextParamsRequest)); CompletableFuture<OperationWithStaticContextParamsResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the PutOperationWithChecksum operation asynchronously. * * @param putOperationWithChecksumRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); if (!isSignerOverridden(clientConfiguration)) { putOperationWithChecksumRequest = applySignerOverride(putOperationWithChecksumRequest, AsyncAws4Signer.create()); } HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory .createResponseHandler(PutOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()).withAsyncRequestBody(requestBody) .withInput(putOperationWithChecksumRequest), asyncResponseTransformer); CompletableFuture<ReturnT> whenCompleteFuture = null; AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); if (!isSignerOverridden(clientConfiguration)) { streamingInputOperationRequest = applySignerOverride(streamingInputOperationRequest, AsyncAws4Signer.create()); } HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory .createResponseHandler(StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture<StreamingInputOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory .createResponseHandler(StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(streamingOutputOperationRequest), asyncResponseTransformer); CompletableFuture<ReturnT> whenCompleteFuture = null; AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public QueryAsyncWaiter waiter() { return QueryAsyncWaiter.builder().client(this).scheduledExecutorService(executorService).build(); } @Override public final QueryServiceClientConfiguration serviceClientConfiguration() { return new QueryServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private AwsQueryProtocolFactory init() { return AwsQueryProtocolFactory .builder() .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(QueryException::builder).build(); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private <T extends QueryRequest> T applySignerOverride(T request, Signer signer) { if (request.overrideConfiguration().flatMap(c -> c.signer()).isPresent()) { return request; } Consumer<AwsRequestOverrideConfiguration.Builder> signerOverride = b -> b.signer(signer).build(); AwsRequestOverrideConfiguration overrideConfiguration = request.overrideConfiguration() .map(c -> c.toBuilder().applyMutation(signerOverride).build()) .orElse((AwsRequestOverrideConfiguration.builder().applyMutation(signerOverride).build())); return (T) request.toBuilder().overrideConfiguration(overrideConfiguration).build(); } private static boolean isSignerOverridden(SdkClientConfiguration clientConfiguration) { return Boolean.TRUE.equals(clientConfiguration.option(SdkClientOption.SIGNER_OVERRIDDEN)); } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } @Override public void close() { clientHandler.close(); } }
3,275
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/test-abstract-sync-client-class.java
package software.amazon.awssdk.services.json; import java.util.function.Function; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkPublicApi; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.core.SdkClient; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InvalidInputException; import software.amazon.awssdk.services.json.model.JsonException; import software.amazon.awssdk.services.json.model.JsonRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.utils.Validate; @Generated("software.amazon.awssdk:codegen") @SdkPublicApi public abstract class DelegatingJsonClient implements JsonClient { private final JsonClient delegate; public DelegatingJsonClient(JsonClient delegate) { Validate.paramNotNull(delegate, "delegate"); this.delegate = delegate; } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { return invokeOperation(aPostOperationRequest, request -> delegate.aPostOperation(request)); } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return Result of the APostOperationWithOutput operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public APostOperationWithOutputResponse aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { return invokeOperation(aPostOperationWithOutputRequest, request -> delegate.aPostOperationWithOutput(request)); } /** * Invokes the BearerAuthOperation operation. * * @param bearerAuthOperationRequest * @return Result of the BearerAuthOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(bearerAuthOperationRequest, request -> delegate.bearerAuthOperation(request)); } /** * Invokes the GetOperationWithChecksum operation. * * @param getOperationWithChecksumRequest * @return Result of the GetOperationWithChecksum operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public GetOperationWithChecksumResponse getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(getOperationWithChecksumRequest, request -> delegate.getOperationWithChecksum(request)); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return Result of the GetWithoutRequiredMembers operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ @Override public GetWithoutRequiredMembersResponse getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { return invokeOperation(getWithoutRequiredMembersRequest, request -> delegate.getWithoutRequiredMembers(request)); } /** * Invokes the OperationWithChecksumRequired operation. * * @param operationWithChecksumRequiredRequest * @return Result of the OperationWithChecksumRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public OperationWithChecksumRequiredResponse operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(operationWithChecksumRequiredRequest, request -> delegate.operationWithChecksumRequired(request)); } /** * Invokes the OperationWithRequestCompression operation. * * @param operationWithRequestCompressionRequest * @return Result of the OperationWithRequestCompression operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public OperationWithRequestCompressionResponse operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(operationWithRequestCompressionRequest, request -> delegate.operationWithRequestCompression(request)); } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return Result of the PaginatedOperationWithResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ @Override public PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(paginatedOperationWithResultKeyRequest, request -> delegate.paginatedOperationWithResultKey(request)); } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return Result of the PaginatedOperationWithoutResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ @Override public PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(paginatedOperationWithoutResultKeyRequest, request -> delegate.paginatedOperationWithoutResultKey(request)); } /** * Invokes the PutOperationWithChecksum operation. * * @param putOperationWithChecksumRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(putOperationWithChecksumRequest, request -> delegate.putOperationWithChecksum(request, requestBody, responseTransformer)); } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(streamingInputOperationRequest, request -> delegate.streamingInputOperation(request, requestBody)); } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingInputOutputOperationResponse and an InputStream to the response content are provided as * parameters to the callback. The callback may return a transformed type which will be the return value of * this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing * this interface and for links to pre-canned implementations for common scenarios like downloading to a * file. The service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, RequestBody requestBody, ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(streamingInputOutputOperationRequest, request -> delegate.streamingInputOutputOperation(request, requestBody, responseTransformer)); } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { return invokeOperation(streamingOutputOperationRequest, request -> delegate.streamingOutputOperation(request, responseTransformer)); } /** * Creates an instance of {@link JsonUtilities} object with the configuration set on this client. */ @Override public JsonUtilities utilities() { return delegate.utilities(); } @Override public final String serviceName() { return delegate.serviceName(); } public SdkClient delegate() { return this.delegate; } protected <T extends JsonRequest, ReturnT> ReturnT invokeOperation(T request, Function<T, ReturnT> operation) { return operation.apply(request); } @Override public final JsonServiceClientConfiguration serviceClientConfiguration() { return delegate.serviceClientConfiguration(); } @Override public void close() { delegate.close(); } }
3,276
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-json-client-class.java
package software.amazon.awssdk.services.json; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InvalidInputException; import software.amazon.awssdk.services.json.model.JsonException; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.HostnameValidator; import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link JsonClient}. * * @see JsonClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonClient implements JsonClient { private static final Logger log = Logger.loggerFor(DefaultJsonClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_JSON).build(); private final SyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultJsonClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsSyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler(operationMetadata, APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); String hostPrefix = "{StringMember}-foo."; HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember", "aPostOperationRequest"); String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember()); return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return Result of the APostOperationWithOutput operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public APostOperationWithOutputResponse aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); return clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the BearerAuthOperation operation. * * @param bearerAuthOperationRequest * @return Result of the BearerAuthOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, BearerAuthOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the GetOperationWithChecksum operation. * * @param getOperationWithChecksumRequest * @return Result of the GetOperationWithChecksum operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public GetOperationWithChecksumResponse getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(false).build(); HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(getOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return Result of the GetWithoutRequiredMembers operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ @Override public GetWithoutRequiredMembersResponse getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) throws InvalidInputException, AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetWithoutRequiredMembersResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers"); return clientHandler .execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>() .withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(getWithoutRequiredMembersRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithChecksumRequired operation. * * @param operationWithChecksumRequiredRequest * @return Result of the OperationWithChecksumRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public OperationWithChecksumRequiredResponse operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); return clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithRequestCompression operation. * * @param operationWithRequestCompressionRequest * @return Result of the OperationWithRequestCompression operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public OperationWithRequestCompressionResponse operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); return clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return Result of the PaginatedOperationWithResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ @Override public PaginatedOperationWithResultKeyResponse paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PaginatedOperationWithResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey"); return clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>() .withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(paginatedOperationWithResultKeyRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return Result of the PaginatedOperationWithoutResultKey operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ @Override public PaginatedOperationWithoutResultKeyResponse paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey"); return clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>() .withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(paginatedOperationWithoutResultKeyRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the PutOperationWithChecksum operation. * * @param putOperationWithChecksumRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PutOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); return clientHandler.execute( new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(putOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .requestBody(requestBody).build()), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); return clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingInputOutputOperationResponse and an InputStream to the response content are provided as * parameters to the callback. The callback may return a transformed type which will be the return value of * this method. See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing * this interface and for links to pre-canned implementations for common scenarios like downloading to a * file. The service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, RequestBody requestBody, ResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOutputOperationRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation"); return clientHandler.execute( new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>() .withOperationName("StreamingInputOutputOperation") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller .builder() .delegateMarshaller( new StreamingInputOutputOperationRequestMarshaller(protocolFactory)) .requestBody(requestBody).transferEncoding(true).build()), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws JsonException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample JsonClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, JsonException { JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); return clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Creates an instance of {@link JsonUtilities} object with the configuration set on this client. */ @Override public JsonUtilities utilities() { return JsonUtilities.create(param1, param2, param3); } @Override public final String serviceName() { return SERVICE_NAME; } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(JsonException::builder) .protocol(AwsJsonProtocol.REST_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()); } @Override public final JsonServiceClientConfiguration serviceClientConfiguration() { return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public void close() { clientHandler.close(); } }
3,277
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-json-async-client-class.java
package software.amazon.awssdk.services.json; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.nio.ByteBuffer; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import org.reactivestreams.Publisher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.client.handler.AwsClientHandlerUtils; import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionJsonMarshaller; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier; import software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkPojoBuilder; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.SdkResponse; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils; import software.amazon.awssdk.core.async.SdkPublisher; import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.AttachHttpMetadataResponseHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.protocol.VoidSdkResponse; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.json.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.json.model.EventStream; import software.amazon.awssdk.services.json.model.EventStreamOperationRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InputEventStream; import software.amazon.awssdk.services.json.model.InputEventStreamTwo; import software.amazon.awssdk.services.json.model.InvalidInputException; import software.amazon.awssdk.services.json.model.JsonException; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.json.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.json.model.inputeventstream.DefaultInputEvent; import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventOne; import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventTwo; import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyInputRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller; import software.amazon.awssdk.services.json.transform.InputEventMarshaller; import software.amazon.awssdk.services.json.transform.InputEventTwoMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.HostnameValidator; import software.amazon.awssdk.utils.Pair; /** * Internal implementation of {@link JsonAsyncClient}. * * @see JsonAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonAsyncClient implements JsonAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_JSON).build(); private final AsyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private final Executor executor; protected DefaultJsonAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR); } @Override public JsonUtilities utilities() { return JsonUtilities.create(param1, param2, param3); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); String hostPrefix = "{StringMember}-foo."; HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember", "aPostOperationRequest"); String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember()); CompletableFuture<APostOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(aPostOperationWithOutputRequest)); CompletableFuture<APostOperationWithOutputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the BearerAuthOperation operation asynchronously. * * @param bearerAuthOperationRequest * @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation( BearerAuthOperationRequest bearerAuthOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, BearerAuthOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .credentialType(CredentialType.TOKEN).withInput(bearerAuthOperationRequest)); CompletableFuture<BearerAuthOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperation operation asynchronously. * * @param eventStreamOperationRequest * @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest, Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationResponse> responseHandler = new AttachHttpMetadataResponseHandler( protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder)); HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(), EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder) .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder) .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder) .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder() .putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build(); SdkPublisher<InputEventStream> eventPublisher = SdkPublisher.adapt(requestStream); Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map( AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer); CompletableFuture<Void> future = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler) .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler) .exceptionResponseHandler(errorResponseHandler).future(future).executor(executor).serviceName(serviceName()) .build(); RestEventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder() .eventStreamAsyncResponseTransformer(asyncResponseTransformer) .eventStreamResponseHandler(asyncResponseHandler).build(); CompletableFuture<Void> executeFuture = clientHandler.execute( new ClientExecutionParams<EventStreamOperationRequest, EventStreamOperationResponse>() .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory)) .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(eventStreamOperationRequest), restAsyncResponseTransformer); CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { try { asyncResponseHandler.exceptionOccurred(e); } finally { future.completeExceptionally(e); } } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return CompletableFutureUtils.forwardExceptionTo(future, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperationWithOnlyInput operation asynchronously. * * @param eventStreamOperationWithOnlyInputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyInput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput( EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest, Publisher<InputEventStreamTwo> requestStream) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationWithOnlyInputResponse> responseHandler = protocolFactory .createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder() .putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory)) .putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build(); SdkPublisher<InputEventStreamTwo> eventPublisher = SdkPublisher.adapt(requestStream); Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map( AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer); CompletableFuture<EventStreamOperationWithOnlyInputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<EventStreamOperationWithOnlyInputRequest, EventStreamOperationWithOnlyInputResponse>() .withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory)) .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationWithOnlyInputRequest)); CompletableFuture<EventStreamOperationWithOnlyInputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperationWithOnlyOutput operation asynchronously. * * @param eventStreamOperationWithOnlyOutputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperationWithOnlyOutput( EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationWithOnlyOutputResponse> responseHandler = new AttachHttpMetadataResponseHandler( protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder)); HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(), EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder) .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder) .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder) .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<Void> future = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationWithOnlyOutputResponse, EventStream> builder() .eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler) .initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).future(future) .executor(executor).serviceName(serviceName()).build(); RestEventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer .<EventStreamOperationWithOnlyOutputResponse, EventStream> builder() .eventStreamAsyncResponseTransformer(asyncResponseTransformer) .eventStreamResponseHandler(asyncResponseHandler).build(); CompletableFuture<Void> executeFuture = clientHandler .execute( new ClientExecutionParams<EventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponse>() .withOperationName("EventStreamOperationWithOnlyOutput") .withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(eventStreamOperationWithOnlyOutputRequest), restAsyncResponseTransformer); CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { try { asyncResponseHandler.exceptionOccurred(e); } finally { future.completeExceptionally(e); } } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return CompletableFutureUtils.forwardExceptionTo(future, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the GetOperationWithChecksum operation asynchronously. * * @param getOperationWithChecksumRequest * @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(false).build(); HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest)); CompletableFuture<GetOperationWithChecksumResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetWithoutRequiredMembersResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<GetWithoutRequiredMembersResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>() .withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getWithoutRequiredMembersRequest)); CompletableFuture<GetWithoutRequiredMembersResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); CompletableFuture<OperationWithRequestCompressionResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PaginatedOperationWithResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<PaginatedOperationWithResultKeyResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>() .withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(paginatedOperationWithResultKeyRequest)); CompletableFuture<PaginatedOperationWithResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory .createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<PaginatedOperationWithoutResultKeyResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>() .withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(paginatedOperationWithoutResultKeyRequest)); CompletableFuture<PaginatedOperationWithoutResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the PutOperationWithChecksum operation asynchronously. * * @param putOperationWithChecksumRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PutOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .withAsyncRequestBody(requestBody) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()).withInput(putOperationWithChecksumRequest), asyncResponseTransformer); AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture<StreamingInputOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOutputOperationRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation"); Pair<AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>() .withOperationName("StreamingInputOutputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller .builder() .delegateMarshaller( new StreamingInputOutputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).transferEncoding(true).build()) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(streamingOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final JsonServiceClientConfiguration serviceClientConfiguration() { return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(JsonException::builder) .protocol(AwsJsonProtocol.REST_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }
3,278
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-aws-json-async-client-class.java
package software.amazon.awssdk.services.json; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.nio.ByteBuffer; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import org.reactivestreams.Publisher; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.client.handler.AwsClientHandlerUtils; import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionJsonMarshaller; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkPojoBuilder; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.SdkResponse; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils; import software.amazon.awssdk.core.async.SdkPublisher; import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.AttachHttpMetadataResponseHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.protocol.VoidSdkResponse; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.json.AwsJsonProtocol; import software.amazon.awssdk.protocols.json.AwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.BaseAwsJsonProtocolFactory; import software.amazon.awssdk.protocols.json.JsonOperationMetadata; import software.amazon.awssdk.services.json.internal.JsonServiceClientConfigurationBuilder; import software.amazon.awssdk.services.json.model.APostOperationRequest; import software.amazon.awssdk.services.json.model.APostOperationResponse; import software.amazon.awssdk.services.json.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.json.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.json.model.EventStream; import software.amazon.awssdk.services.json.model.EventStreamOperationRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationResponseHandler; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyInputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputRequest; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponse; import software.amazon.awssdk.services.json.model.EventStreamOperationWithOnlyOutputResponseHandler; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersRequest; import software.amazon.awssdk.services.json.model.GetWithoutRequiredMembersResponse; import software.amazon.awssdk.services.json.model.InputEventStream; import software.amazon.awssdk.services.json.model.InputEventStreamTwo; import software.amazon.awssdk.services.json.model.InvalidInputException; import software.amazon.awssdk.services.json.model.JsonException; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.json.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.json.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.json.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.json.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithResultKeyResponse; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyRequest; import software.amazon.awssdk.services.json.model.PaginatedOperationWithoutResultKeyResponse; import software.amazon.awssdk.services.json.model.ServiceFaultException; import software.amazon.awssdk.services.json.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingInputOutputOperationResponse; import software.amazon.awssdk.services.json.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.json.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.json.model.inputeventstream.DefaultInputEvent; import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventOne; import software.amazon.awssdk.services.json.model.inputeventstreamtwo.DefaultInputEventTwo; import software.amazon.awssdk.services.json.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyInputRequestMarshaller; import software.amazon.awssdk.services.json.transform.EventStreamOperationWithOnlyOutputRequestMarshaller; import software.amazon.awssdk.services.json.transform.GetWithoutRequiredMembersRequestMarshaller; import software.amazon.awssdk.services.json.transform.InputEventMarshaller; import software.amazon.awssdk.services.json.transform.InputEventTwoMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.json.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.PaginatedOperationWithoutResultKeyRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingInputOutputOperationRequestMarshaller; import software.amazon.awssdk.services.json.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.HostnameValidator; import software.amazon.awssdk.utils.Pair; /** * Internal implementation of {@link JsonAsyncClient}. * * @see JsonAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultJsonAsyncClient implements JsonAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultJsonAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.AWS_JSON).build(); private final AsyncClientHandler clientHandler; private final AwsJsonProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private final Executor executor; protected DefaultJsonAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(AwsJsonProtocolFactory.builder()).build(); this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR); } @Override public JsonUtilities utilities() { return JsonUtilities.create(param1, param2, param3); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); String hostPrefix = "{StringMember}-foo."; HostnameValidator.validateHostnameCompliant(aPostOperationRequest.stringMember(), "StringMember", "aPostOperationRequest"); String resolvedHostExpression = String.format("%s-foo.", aPostOperationRequest.stringMember()); CompletableFuture<APostOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture<APostOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>ServiceFaultException</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(aPostOperationWithOutputRequest)); CompletableFuture<APostOperationWithOutputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperation operation asynchronously. * * @param eventStreamOperationRequest * @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest, Publisher<InputEventStream> requestStream, EventStreamOperationResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationResponse> responseHandler = new AttachHttpMetadataResponseHandler( protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationResponse::builder)); HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(), EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder) .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder) .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder) .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder() .putMarshaller(DefaultInputEvent.class, new InputEventMarshaller(protocolFactory)).build(); SdkPublisher<InputEventStream> eventPublisher = SdkPublisher.adapt(requestStream); Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map( AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer); CompletableFuture<Void> future = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler) .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler) .exceptionResponseHandler(errorResponseHandler).future(future).executor(executor).serviceName(serviceName()) .build(); CompletableFuture<Void> executeFuture = clientHandler.execute( new ClientExecutionParams<EventStreamOperationRequest, SdkResponse>() .withOperationName("EventStreamOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory)) .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withFullDuplex(true) .withInitialRequestEvent(true).withResponseHandler(voidResponseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest), asyncResponseTransformer); CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { try { asyncResponseHandler.exceptionOccurred(e); } finally { future.completeExceptionally(e); } } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return CompletableFutureUtils.forwardExceptionTo(future, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperationWithOnlyInput operation asynchronously. * * @param eventStreamOperationWithOnlyInputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyInput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyInput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyInput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<EventStreamOperationWithOnlyInputResponse> eventStreamOperationWithOnlyInput( EventStreamOperationWithOnlyInputRequest eventStreamOperationWithOnlyInputRequest, Publisher<InputEventStreamTwo> requestStream) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyInputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationWithOnlyInputRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyInput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationWithOnlyInputResponse> responseHandler = protocolFactory .createResponseHandler(operationMetadata, EventStreamOperationWithOnlyInputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); EventStreamTaggedUnionJsonMarshaller eventMarshaller = EventStreamTaggedUnionJsonMarshaller.builder() .putMarshaller(DefaultInputEventOne.class, new InputEventMarshaller(protocolFactory)) .putMarshaller(DefaultInputEventTwo.class, new InputEventTwoMarshaller(protocolFactory)).build(); SdkPublisher<InputEventStreamTwo> eventPublisher = SdkPublisher.adapt(requestStream); Publisher<ByteBuffer> adapted = eventPublisher.map(event -> eventMarshaller.marshall(event)).map( AwsClientHandlerUtils::encodeEventStreamRequestToByteBuffer); CompletableFuture<EventStreamOperationWithOnlyInputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<EventStreamOperationWithOnlyInputRequest, EventStreamOperationWithOnlyInputResponse>() .withOperationName("EventStreamOperationWithOnlyInput").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyInputRequestMarshaller(protocolFactory)) .withAsyncRequestBody(AsyncRequestBody.fromPublisher(adapted)).withInitialRequestEvent(true) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(eventStreamOperationWithOnlyInputRequest)); CompletableFuture<EventStreamOperationWithOnlyInputResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperationWithOnlyOutput operation asynchronously. * * @param eventStreamOperationWithOnlyOutputRequest * @return A Java Future containing the result of the EventStreamOperationWithOnlyOutput operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.EventStreamOperationWithOnlyOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/EventStreamOperationWithOnlyOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperationWithOnlyOutput( EventStreamOperationWithOnlyOutputRequest eventStreamOperationWithOnlyOutputRequest, EventStreamOperationWithOnlyOutputResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationWithOnlyOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationWithOnlyOutputRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperationWithOnlyOutput"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<EventStreamOperationWithOnlyOutputResponse> responseHandler = new AttachHttpMetadataResponseHandler( protocolFactory.createResponseHandler(operationMetadata, EventStreamOperationWithOnlyOutputResponse::builder)); HttpResponseHandler<SdkResponse> voidResponseHandler = protocolFactory.createResponseHandler(JsonOperationMetadata .builder().isPayloadJson(false).hasStreamingSuccessResponse(true).build(), VoidSdkResponse::builder); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( JsonOperationMetadata.builder().isPayloadJson(true).hasStreamingSuccessResponse(false).build(), EventStreamTaggedUnionPojoSupplier.builder().putSdkPojoSupplier("EventOne", EventStream::eventOneBuilder) .putSdkPojoSupplier("EventTheSecond", EventStream::eventTheSecondBuilder) .putSdkPojoSupplier("secondEventOne", EventStream::secondEventOneBuilder) .putSdkPojoSupplier("eventThree", EventStream::eventThreeBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<Void> future = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationWithOnlyOutputResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationWithOnlyOutputResponse, EventStream> builder() .eventStreamResponseHandler(asyncResponseHandler).eventResponseHandler(eventResponseHandler) .initialResponseHandler(responseHandler).exceptionResponseHandler(errorResponseHandler).future(future) .executor(executor).serviceName(serviceName()).build(); CompletableFuture<Void> executeFuture = clientHandler.execute( new ClientExecutionParams<EventStreamOperationWithOnlyOutputRequest, SdkResponse>() .withOperationName("EventStreamOperationWithOnlyOutput").withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationWithOnlyOutputRequestMarshaller(protocolFactory)) .withResponseHandler(voidResponseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(eventStreamOperationWithOnlyOutputRequest), asyncResponseTransformer); CompletableFuture<Void> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { try { asyncResponseHandler.exceptionOccurred(e); } finally { future.completeExceptionally(e); } } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return CompletableFutureUtils.forwardExceptionTo(future, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param getWithoutRequiredMembersRequest * @return A Java Future containing the result of the GetWithoutRequiredMembers operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.GetWithoutRequiredMembers * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/GetWithoutRequiredMembers" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetWithoutRequiredMembersResponse> getWithoutRequiredMembers( GetWithoutRequiredMembersRequest getWithoutRequiredMembersRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getWithoutRequiredMembersRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getWithoutRequiredMembersRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetWithoutRequiredMembers"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<GetWithoutRequiredMembersResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, GetWithoutRequiredMembersResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<GetWithoutRequiredMembersResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetWithoutRequiredMembersRequest, GetWithoutRequiredMembersResponse>() .withOperationName("GetWithoutRequiredMembers").withProtocolMetadata(protocolMetadata) .withMarshaller(new GetWithoutRequiredMembersRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(getWithoutRequiredMembersRequest)); CompletableFuture<GetWithoutRequiredMembersResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithNoneAuthType operation asynchronously. * * @param operationWithNoneAuthTypeRequest * @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithNoneAuthTypeResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); CompletableFuture<OperationWithRequestCompressionResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some paginated operation with result_key in paginators.json file * * @param paginatedOperationWithResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithResultKeyResponse> paginatedOperationWithResultKey( PaginatedOperationWithResultKeyRequest paginatedOperationWithResultKeyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithResultKey"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithResultKeyResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, PaginatedOperationWithResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<PaginatedOperationWithResultKeyResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithResultKeyRequest, PaginatedOperationWithResultKeyResponse>() .withOperationName("PaginatedOperationWithResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithResultKeyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(paginatedOperationWithResultKeyRequest)); CompletableFuture<PaginatedOperationWithResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some paginated operation without result_key in paginators.json file * * @param paginatedOperationWithoutResultKeyRequest * @return A Java Future containing the result of the PaginatedOperationWithoutResultKey operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.PaginatedOperationWithoutResultKey * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/PaginatedOperationWithoutResultKey" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<PaginatedOperationWithoutResultKeyResponse> paginatedOperationWithoutResultKey( PaginatedOperationWithoutResultKeyRequest paginatedOperationWithoutResultKeyRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(paginatedOperationWithoutResultKeyRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, paginatedOperationWithoutResultKeyRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PaginatedOperationWithoutResultKey"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<PaginatedOperationWithoutResultKeyResponse> responseHandler = protocolFactory .createResponseHandler(operationMetadata, PaginatedOperationWithoutResultKeyResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<PaginatedOperationWithoutResultKeyResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<PaginatedOperationWithoutResultKeyRequest, PaginatedOperationWithoutResultKeyResponse>() .withOperationName("PaginatedOperationWithoutResultKey").withProtocolMetadata(protocolMetadata) .withMarshaller(new PaginatedOperationWithoutResultKeyRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(paginatedOperationWithoutResultKeyRequest)); CompletableFuture<PaginatedOperationWithoutResultKeyResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(false) .isPayloadJson(true).build(); HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture<StreamingInputOperationResponse> whenCompleted = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with streaming input and streaming output * * @param streamingInputOutputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingInputOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingInputOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingInputOutputOperation( StreamingInputOutputOperationRequest streamingInputOutputOperationRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOutputOperationRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOutputOperation"); Pair<AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingInputOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingInputOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingInputOutputOperationRequest, StreamingInputOutputOperationResponse>() .withOperationName("StreamingInputOutputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller .builder() .delegateMarshaller( new StreamingInputOutputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).transferEncoding(true).build()) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withAsyncRequestBody(requestBody).withInput(streamingInputOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<StreamingInputOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>JsonException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample JsonAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/json-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Json Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); JsonOperationMetadata operationMetadata = JsonOperationMetadata.builder().hasStreamingSuccessResponse(true) .isPayloadJson(false).build(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( operationMetadata, StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = createErrorResponseHandler(protocolFactory, operationMetadata); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(streamingOutputOperationRequest), asyncResponseTransformer); AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; CompletableFuture<ReturnT> whenCompleted = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); executeFuture = CompletableFutureUtils.forwardExceptionTo(whenCompleted, executeFuture); return executeFuture; } catch (Throwable t) { AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final JsonServiceClientConfiguration serviceClientConfiguration() { return new JsonServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private <T extends BaseAwsJsonProtocolFactory.Builder<T>> T init(T builder) { return builder .clientConfiguration(clientConfiguration) .defaultServiceExceptionSupplier(JsonException::builder) .protocol(AwsJsonProtocol.AWS_JSON) .protocolVersion("1.1") .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInputException") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .registerModeledException( ExceptionMetadata.builder().errorCode("ServiceFaultException") .exceptionBuilderSupplier(ServiceFaultException::builder).httpStatusCode(500).build()); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); JsonServiceClientConfigurationBuilder serviceConfigBuilder = new JsonServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private HttpResponseHandler<AwsServiceException> createErrorResponseHandler(BaseAwsJsonProtocolFactory protocolFactory, JsonOperationMetadata operationMetadata) { return protocolFactory.createErrorResponseHandler(operationMetadata); } @Override public void close() { clientHandler.close(); } }
3,279
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-query-client-class.java
package software.amazon.awssdk.services.query; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory; import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder; import software.amazon.awssdk.services.query.model.APostOperationRequest; import software.amazon.awssdk.services.query.model.APostOperationResponse; import software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.query.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.query.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.query.model.InvalidInputException; import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest; import software.amazon.awssdk.services.query.model.OperationWithContextParamResponse; import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsRequest; import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsResponse; import software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.query.model.QueryException; import software.amazon.awssdk.services.query.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.query.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.query.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithContextParamRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithStaticContextParamsRequestMarshaller; import software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.services.query.waiters.QueryWaiter; import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link QueryClient}. * * @see QueryClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultQueryClient implements QueryClient { private static final Logger log = Logger.loggerFor(DefaultQueryClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.QUERY).build(); private final SyncClientHandler clientHandler; private final AwsQueryProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultQueryClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsSyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory .createResponseHandler(APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); String hostPrefix = "foo-"; String resolvedHostExpression = "foo-"; return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return Result of the APostOperationWithOutput operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public APostOperationWithOutputResponse aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory .createResponseHandler(APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); return clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the BearerAuthOperation operation. * * @param bearerAuthOperationRequest * @return Result of the BearerAuthOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory .createResponseHandler(BearerAuthOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withInput(bearerAuthOperationRequest).withMetricCollector(apiCallMetricCollector) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the GetOperationWithChecksum operation. * * @param getOperationWithChecksumRequest * @return Result of the GetOperationWithChecksum operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public GetOperationWithChecksumResponse getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory .createResponseHandler(GetOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(getOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithChecksumRequired operation. * * @param operationWithChecksumRequiredRequest * @return Result of the OperationWithChecksumRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public OperationWithChecksumRequiredResponse operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); return clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithContextParam operation. * * @param operationWithContextParamRequest * @return Result of the OperationWithContextParam operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithContextParam * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithContextParam" * target="_top">AWS API Documentation</a> */ @Override public OperationWithContextParamResponse operationWithContextParam( OperationWithContextParamRequest operationWithContextParamRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithContextParamResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithContextParamResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithContextParamRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithContextParamRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithContextParam"); return clientHandler .execute(new ClientExecutionParams<OperationWithContextParamRequest, OperationWithContextParamResponse>() .withOperationName("OperationWithContextParam").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithContextParamRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithNoneAuthType operation. * * @param operationWithNoneAuthTypeRequest * @return Result of the OperationWithNoneAuthType operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public OperationWithNoneAuthTypeResponse operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithNoneAuthTypeResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); return clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithRequestCompression operation. * * @param operationWithRequestCompressionRequest * @return Result of the OperationWithRequestCompression operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public OperationWithRequestCompressionResponse operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); return clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithStaticContextParams operation. * * @param operationWithStaticContextParamsRequest * @return Result of the OperationWithStaticContextParams operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.OperationWithStaticContextParams * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithStaticContextParams" * target="_top">AWS API Documentation</a> */ @Override public OperationWithStaticContextParamsResponse operationWithStaticContextParams( OperationWithStaticContextParamsRequest operationWithStaticContextParamsRequest) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<OperationWithStaticContextParamsResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithStaticContextParamsResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithStaticContextParamsRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithStaticContextParamsRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithStaticContextParams"); return clientHandler .execute(new ClientExecutionParams<OperationWithStaticContextParamsRequest, OperationWithStaticContextParamsResponse>() .withOperationName("OperationWithStaticContextParams").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(operationWithStaticContextParamsRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new OperationWithStaticContextParamsRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the PutOperationWithChecksum operation. * * @param putOperationWithChecksumRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory .createResponseHandler(PutOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(putOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory .createResponseHandler(StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); return clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws QueryException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample QueryClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, QueryException { HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory .createResponseHandler(StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); return clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Create an instance of {@link QueryWaiter} using this client. * <p> * Waiters created via this method are managed by the SDK and resources will be released when the service client is * closed. * * @return an instance of {@link QueryWaiter} */ @Override public QueryWaiter waiter() { return QueryWaiter.builder().client(this).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private AwsQueryProtocolFactory init() { return AwsQueryProtocolFactory .builder() .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(QueryException::builder).build(); } @Override public final QueryServiceClientConfiguration serviceClientConfiguration() { return new QueryServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public void close() { clientHandler.close(); } }
3,280
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-xml-async-client-class.java
package software.amazon.awssdk.services.xml; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.Executor; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.eventstream.EventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.eventstream.EventStreamTaggedUnionPojoSupplier; import software.amazon.awssdk.awscore.eventstream.RestEventStreamAsyncResponseTransformer; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.Response; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkPojoBuilder; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils; import software.amazon.awssdk.core.client.config.SdkAdvancedAsyncClientOption; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.xml.AwsXmlProtocolFactory; import software.amazon.awssdk.protocols.xml.XmlOperationMetadata; import software.amazon.awssdk.services.xml.internal.XmlServiceClientConfigurationBuilder; import software.amazon.awssdk.services.xml.model.APostOperationRequest; import software.amazon.awssdk.services.xml.model.APostOperationResponse; import software.amazon.awssdk.services.xml.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.xml.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.xml.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.xml.model.EventStream; import software.amazon.awssdk.services.xml.model.EventStreamOperationRequest; import software.amazon.awssdk.services.xml.model.EventStreamOperationResponse; import software.amazon.awssdk.services.xml.model.EventStreamOperationResponseHandler; import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.xml.model.InvalidInputException; import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.xml.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.xml.model.XmlException; import software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.xml.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.EventStreamOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.xml.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.Pair; /** * Internal implementation of {@link XmlAsyncClient}. * * @see XmlAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultXmlAsyncClient implements XmlAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultXmlAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_XML).build(); private final AsyncClientHandler clientHandler; private final AwsXmlProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private final Executor executor; protected DefaultXmlAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(); this.executor = clientConfiguration.option(SdkAdvancedAsyncClientOption.FUTURE_COMPLETION_EXECUTOR); } /** * <p> * Performs a post operation to the xml service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(APostOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); String hostPrefix = "foo-"; String resolvedHostExpression = "foo-"; CompletableFuture<APostOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).hostPrefixExpression(resolvedHostExpression) .withMetricCollector(apiCallMetricCollector).withInput(aPostOperationRequest)); CompletableFuture<APostOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the xml service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); HttpResponseHandler<Response<APostOperationWithOutputResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(APostOperationWithOutputResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .withInput(aPostOperationWithOutputRequest)); CompletableFuture<APostOperationWithOutputResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the BearerAuthOperation operation asynchronously. * * @param bearerAuthOperationRequest * @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation( BearerAuthOperationRequest bearerAuthOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); HttpResponseHandler<Response<BearerAuthOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(BearerAuthOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).credentialType(CredentialType.TOKEN) .withMetricCollector(apiCallMetricCollector).withInput(bearerAuthOperationRequest)); CompletableFuture<BearerAuthOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the EventStreamOperation operation asynchronously. * * @param eventStreamOperationRequest * @return A Java Future containing the result of the EventStreamOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.EventStreamOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/EventStreamOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<Void> eventStreamOperation(EventStreamOperationRequest eventStreamOperationRequest, EventStreamOperationResponseHandler asyncResponseHandler) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(eventStreamOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, eventStreamOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "EventStreamOperation"); HttpResponseHandler<EventStreamOperationResponse> responseHandler = protocolFactory.createResponseHandler( EventStreamOperationResponse::builder, XmlOperationMetadata.builder().hasStreamingSuccessResponse(true) .build()); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); HttpResponseHandler<? extends EventStream> eventResponseHandler = protocolFactory.createResponseHandler( EventStreamTaggedUnionPojoSupplier.builder() .putSdkPojoSupplier("EventPayloadEvent", EventStream::eventPayloadEventBuilder) .putSdkPojoSupplier("NonEventPayloadEvent", EventStream::nonEventPayloadEventBuilder) .putSdkPojoSupplier("SecondEventPayloadEvent", EventStream::secondEventPayloadEventBuilder) .defaultSdkPojoSupplier(() -> new SdkPojoBuilder(EventStream.UNKNOWN)).build(), XmlOperationMetadata .builder().hasStreamingSuccessResponse(false).build()); CompletableFuture<Void> eventStreamTransformFuture = new CompletableFuture<>(); EventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> asyncResponseTransformer = EventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder().eventStreamResponseHandler(asyncResponseHandler) .eventResponseHandler(eventResponseHandler).initialResponseHandler(responseHandler) .exceptionResponseHandler(errorResponseHandler).future(eventStreamTransformFuture).executor(executor) .serviceName(serviceName()).build(); RestEventStreamAsyncResponseTransformer<EventStreamOperationResponse, EventStream> restAsyncResponseTransformer = RestEventStreamAsyncResponseTransformer .<EventStreamOperationResponse, EventStream> builder() .eventStreamAsyncResponseTransformer(asyncResponseTransformer) .eventStreamResponseHandler(asyncResponseHandler).build(); CompletableFuture<Void> executeFuture = clientHandler.execute( new ClientExecutionParams<EventStreamOperationRequest, EventStreamOperationResponse>() .withOperationName("EventStreamOperation").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new EventStreamOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withMetricCollector(apiCallMetricCollector).withInput(eventStreamOperationRequest), restAsyncResponseTransformer); CompletableFuture<Void> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(e)); eventStreamTransformFuture.completeExceptionally(e); } metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return CompletableFutureUtils.forwardExceptionTo(eventStreamTransformFuture, executeFuture); } catch (Throwable t) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> asyncResponseHandler.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the GetOperationWithChecksum operation asynchronously. * * @param getOperationWithChecksumRequest * @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); HttpResponseHandler<Response<GetOperationWithChecksumResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(GetOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest)); CompletableFuture<GetOperationWithChecksumResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithNoneAuthType operation asynchronously. * * @param operationWithNoneAuthTypeRequest * @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); HttpResponseHandler<Response<OperationWithNoneAuthTypeResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithNoneAuthTypeResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); HttpResponseHandler<Response<OperationWithRequestCompressionResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithRequestCompressionResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); CompletableFuture<OperationWithRequestCompressionResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the PutOperationWithChecksum operation asynchronously. * * @param putOperationWithChecksumRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true)); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()).withAsyncRequestBody(requestBody) .withInput(putOperationWithChecksumRequest), asyncResponseTransformer); CompletableFuture<ReturnT> whenCompleteFuture = null; AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); HttpResponseHandler<Response<StreamingInputOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(StreamingInputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withRequestConfiguration(clientConfiguration) .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()).withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture<StreamingInputOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); return whenCompleteFuture; } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>XmlException Base class for all service exceptions. Unknown exceptions will be thrown as an instance * of this type.</li> * </ul> * @sample XmlAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( StreamingOutputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true)); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(streamingOutputOperationRequest), asyncResponseTransformer); CompletableFuture<ReturnT> whenCompleteFuture = null; AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public final XmlServiceClientConfiguration serviceClientConfiguration() { return new XmlServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private AwsXmlProtocolFactory init() { return AwsXmlProtocolFactory .builder() .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(XmlException::builder).build(); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); XmlServiceClientConfigurationBuilder serviceConfigBuilder = new XmlServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } @Override public void close() { clientHandler.close(); } }
3,281
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-xml-client-class.java
package software.amazon.awssdk.services.xml; import java.util.Collections; import java.util.List; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsSyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.Response; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.client.handler.SyncClientHandler; import software.amazon.awssdk.core.exception.SdkClientException; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.StreamingRequestMarshaller; import software.amazon.awssdk.core.sync.RequestBody; import software.amazon.awssdk.core.sync.ResponseTransformer; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.xml.AwsXmlProtocolFactory; import software.amazon.awssdk.protocols.xml.XmlOperationMetadata; import software.amazon.awssdk.services.xml.internal.XmlServiceClientConfigurationBuilder; import software.amazon.awssdk.services.xml.model.APostOperationRequest; import software.amazon.awssdk.services.xml.model.APostOperationResponse; import software.amazon.awssdk.services.xml.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.xml.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.xml.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.xml.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.xml.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.xml.model.InvalidInputException; import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.xml.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.xml.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.xml.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.xml.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.xml.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.xml.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.xml.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.xml.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.xml.model.XmlException; import software.amazon.awssdk.services.xml.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.xml.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.xml.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.xml.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.xml.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.xml.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.utils.Logger; /** * Internal implementation of {@link XmlClient}. * * @see XmlClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultXmlClient implements XmlClient { private static final Logger log = Logger.loggerFor(DefaultXmlClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.REST_XML).build(); private final SyncClientHandler clientHandler; private final AwsXmlProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; protected DefaultXmlClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsSyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(); } /** * <p> * Performs a post operation to the xml service and has no output * </p> * * @param aPostOperationRequest * @return Result of the APostOperation operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public APostOperationResponse aPostOperation(APostOperationRequest aPostOperationRequest) throws InvalidInputException, AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<APostOperationResponse>> responseHandler = protocolFactory.createCombinedResponseHandler( APostOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); String hostPrefix = "foo-"; String resolvedHostExpression = "foo-"; return clientHandler.execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withRequestConfiguration(clientConfiguration) .withInput(aPostOperationRequest).withMarshaller(new APostOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * <p> * Performs a post operation to the xml service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return Result of the APostOperationWithOutput operation returned by the service. * @throws InvalidInputException * The request was rejected because an invalid or out-of-range value was supplied for an input parameter. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public APostOperationWithOutputResponse aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) throws InvalidInputException, AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<APostOperationWithOutputResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(APostOperationWithOutputResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); return clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration).withInput(aPostOperationWithOutputRequest) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the BearerAuthOperation operation. * * @param bearerAuthOperationRequest * @return Result of the BearerAuthOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public BearerAuthOperationResponse bearerAuthOperation(BearerAuthOperationRequest bearerAuthOperationRequest) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<BearerAuthOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(BearerAuthOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); return clientHandler.execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withInput(bearerAuthOperationRequest) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the GetOperationWithChecksum operation. * * @param getOperationWithChecksumRequest * @return Result of the GetOperationWithChecksum operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public GetOperationWithChecksumResponse getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<GetOperationWithChecksumResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(GetOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(getOperationWithChecksumRequest) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithChecksumRequired operation. * * @param operationWithChecksumRequiredRequest * @return Result of the OperationWithChecksumRequired operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public OperationWithChecksumRequiredResponse operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<OperationWithChecksumRequiredResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithChecksumRequiredResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); return clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(operationWithChecksumRequiredRequest) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithNoneAuthType operation. * * @param operationWithNoneAuthTypeRequest * @return Result of the OperationWithNoneAuthType operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public OperationWithNoneAuthTypeResponse operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<OperationWithNoneAuthTypeResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithNoneAuthTypeResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); return clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler).withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration).withInput(operationWithNoneAuthTypeRequest) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the OperationWithRequestCompression operation. * * @param operationWithRequestCompressionRequest * @return Result of the OperationWithRequestCompression operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public OperationWithRequestCompressionResponse operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<OperationWithRequestCompressionResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(OperationWithRequestCompressionResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); return clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(operationWithRequestCompressionRequest) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory))); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Invokes the PutOperationWithChecksum operation. * * @param putOperationWithChecksumRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * PutOperationWithChecksumResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows ' * <p> * Object data. * </p> * '. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT putOperationWithChecksum(PutOperationWithChecksumRequest putOperationWithChecksumRequest, RequestBody requestBody, ResponseTransformer<PutOperationWithChecksumResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory.createResponseHandler( PutOperationWithChecksumResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true)); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); return clientHandler .execute(new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withInput(putOperationWithChecksumRequest) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * The content to send to the service. A {@link RequestBody} can be created using one of several factory * methods for various sources of data. For example, to create a request body from a file you can do the * following. * * <pre> * {@code RequestBody.fromFile(new File("myfile.txt"))} * </pre> * * See documentation in {@link RequestBody} for additional details and which sources of data are supported. * The service documentation for the request content is as follows 'This be a stream' * @return Result of the StreamingInputOperation operation returned by the service. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public StreamingInputOperationResponse streamingInputOperation(StreamingInputOperationRequest streamingInputOperationRequest, RequestBody requestBody) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<Response<StreamingInputOperationResponse>> responseHandler = protocolFactory .createCombinedResponseHandler(StreamingInputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(false)); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); return clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withCombinedResponseHandler(responseHandler) .withMetricCollector(apiCallMetricCollector) .withRequestConfiguration(clientConfiguration) .withInput(streamingInputOperationRequest) .withRequestBody(requestBody) .withMarshaller( StreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .requestBody(requestBody).build())); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param responseTransformer * Functional interface for processing the streamed response content. The unmarshalled * StreamingOutputOperationResponse and an InputStream to the response content are provided as parameters to * the callback. The callback may return a transformed type which will be the return value of this method. * See {@link software.amazon.awssdk.core.sync.ResponseTransformer} for details on implementing this * interface and for links to pre-canned implementations for common scenarios like downloading to a file. The * service documentation for the response content is as follows 'This be a stream'. * @return The transformed result of the ResponseTransformer. * @throws SdkException * Base class for all exceptions that can be thrown by the SDK (both service and client). Can be used for * catch all scenarios. * @throws SdkClientException * If any client side error occurs such as an IO related failure, failure to get credentials, etc. * @throws XmlException * Base class for all service exceptions. Unknown exceptions will be thrown as an instance of this type. * @sample XmlClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/xml-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> ReturnT streamingOutputOperation(StreamingOutputOperationRequest streamingOutputOperationRequest, ResponseTransformer<StreamingOutputOperationResponse, ReturnT> responseTransformer) throws AwsServiceException, SdkClientException, XmlException { HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory.createResponseHandler( StreamingOutputOperationResponse::builder, new XmlOperationMetadata().withHasStreamingSuccessResponse(true)); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Xml Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); return clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withInput(streamingOutputOperationRequest) .withMetricCollector(apiCallMetricCollector) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)), responseTransformer); } finally { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); } } @Override public final String serviceName() { return SERVICE_NAME; } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); XmlServiceClientConfigurationBuilder serviceConfigBuilder = new XmlServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } private AwsXmlProtocolFactory init() { return AwsXmlProtocolFactory .builder() .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(XmlException::builder).build(); } @Override public final XmlServiceClientConfiguration serviceClientConfiguration() { return new XmlServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public void close() { clientHandler.close(); } }
3,282
0
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client
Create_ds/aws-sdk-java-v2/codegen/src/test/resources/software/amazon/awssdk/codegen/poet/client/sra/test-query-async-client-class.java
package software.amazon.awssdk.services.query; import static software.amazon.awssdk.utils.FunctionalUtils.runAndLogError; import java.util.Collections; import java.util.List; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ScheduledExecutorService; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import software.amazon.awssdk.annotations.Generated; import software.amazon.awssdk.annotations.SdkInternalApi; import software.amazon.awssdk.awscore.client.handler.AwsAsyncClientHandler; import software.amazon.awssdk.awscore.exception.AwsServiceException; import software.amazon.awssdk.awscore.internal.AwsProtocolMetadata; import software.amazon.awssdk.awscore.internal.AwsServiceProtocol; import software.amazon.awssdk.core.CredentialType; import software.amazon.awssdk.core.RequestOverrideConfiguration; import software.amazon.awssdk.core.SdkPlugin; import software.amazon.awssdk.core.SdkRequest; import software.amazon.awssdk.core.async.AsyncRequestBody; import software.amazon.awssdk.core.async.AsyncResponseTransformer; import software.amazon.awssdk.core.async.AsyncResponseTransformerUtils; import software.amazon.awssdk.core.client.config.SdkClientConfiguration; import software.amazon.awssdk.core.client.config.SdkClientOption; import software.amazon.awssdk.core.client.handler.AsyncClientHandler; import software.amazon.awssdk.core.client.handler.ClientExecutionParams; import software.amazon.awssdk.core.http.HttpResponseHandler; import software.amazon.awssdk.core.interceptor.SdkInternalExecutionAttribute; import software.amazon.awssdk.core.interceptor.trait.HttpChecksum; import software.amazon.awssdk.core.interceptor.trait.HttpChecksumRequired; import software.amazon.awssdk.core.internal.interceptor.trait.RequestCompression; import software.amazon.awssdk.core.metrics.CoreMetric; import software.amazon.awssdk.core.runtime.transform.AsyncStreamingRequestMarshaller; import software.amazon.awssdk.metrics.MetricCollector; import software.amazon.awssdk.metrics.MetricPublisher; import software.amazon.awssdk.metrics.NoOpMetricCollector; import software.amazon.awssdk.protocols.core.ExceptionMetadata; import software.amazon.awssdk.protocols.query.AwsQueryProtocolFactory; import software.amazon.awssdk.services.query.internal.QueryServiceClientConfigurationBuilder; import software.amazon.awssdk.services.query.model.APostOperationRequest; import software.amazon.awssdk.services.query.model.APostOperationResponse; import software.amazon.awssdk.services.query.model.APostOperationWithOutputRequest; import software.amazon.awssdk.services.query.model.APostOperationWithOutputResponse; import software.amazon.awssdk.services.query.model.BearerAuthOperationRequest; import software.amazon.awssdk.services.query.model.BearerAuthOperationResponse; import software.amazon.awssdk.services.query.model.GetOperationWithChecksumRequest; import software.amazon.awssdk.services.query.model.GetOperationWithChecksumResponse; import software.amazon.awssdk.services.query.model.InvalidInputException; import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredRequest; import software.amazon.awssdk.services.query.model.OperationWithChecksumRequiredResponse; import software.amazon.awssdk.services.query.model.OperationWithContextParamRequest; import software.amazon.awssdk.services.query.model.OperationWithContextParamResponse; import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeRequest; import software.amazon.awssdk.services.query.model.OperationWithNoneAuthTypeResponse; import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionRequest; import software.amazon.awssdk.services.query.model.OperationWithRequestCompressionResponse; import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsRequest; import software.amazon.awssdk.services.query.model.OperationWithStaticContextParamsResponse; import software.amazon.awssdk.services.query.model.PutOperationWithChecksumRequest; import software.amazon.awssdk.services.query.model.PutOperationWithChecksumResponse; import software.amazon.awssdk.services.query.model.QueryException; import software.amazon.awssdk.services.query.model.StreamingInputOperationRequest; import software.amazon.awssdk.services.query.model.StreamingInputOperationResponse; import software.amazon.awssdk.services.query.model.StreamingOutputOperationRequest; import software.amazon.awssdk.services.query.model.StreamingOutputOperationResponse; import software.amazon.awssdk.services.query.transform.APostOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.APostOperationWithOutputRequestMarshaller; import software.amazon.awssdk.services.query.transform.BearerAuthOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.GetOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithChecksumRequiredRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithContextParamRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithNoneAuthTypeRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithRequestCompressionRequestMarshaller; import software.amazon.awssdk.services.query.transform.OperationWithStaticContextParamsRequestMarshaller; import software.amazon.awssdk.services.query.transform.PutOperationWithChecksumRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingInputOperationRequestMarshaller; import software.amazon.awssdk.services.query.transform.StreamingOutputOperationRequestMarshaller; import software.amazon.awssdk.services.query.waiters.QueryAsyncWaiter; import software.amazon.awssdk.utils.CompletableFutureUtils; import software.amazon.awssdk.utils.Pair; /** * Internal implementation of {@link QueryAsyncClient}. * * @see QueryAsyncClient#builder() */ @Generated("software.amazon.awssdk:codegen") @SdkInternalApi final class DefaultQueryAsyncClient implements QueryAsyncClient { private static final Logger log = LoggerFactory.getLogger(DefaultQueryAsyncClient.class); private static final AwsProtocolMetadata protocolMetadata = AwsProtocolMetadata.builder() .serviceProtocol(AwsServiceProtocol.QUERY).build(); private final AsyncClientHandler clientHandler; private final AwsQueryProtocolFactory protocolFactory; private final SdkClientConfiguration clientConfiguration; private final ScheduledExecutorService executorService; protected DefaultQueryAsyncClient(SdkClientConfiguration clientConfiguration) { this.clientHandler = new AwsAsyncClientHandler(clientConfiguration); this.clientConfiguration = clientConfiguration; this.protocolFactory = init(); this.executorService = clientConfiguration.option(SdkClientOption.SCHEDULED_EXECUTOR_SERVICE); } /** * <p> * Performs a post operation to the query service and has no output * </p> * * @param aPostOperationRequest * @return A Java Future containing the result of the APostOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.APostOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperation" target="_top">AWS * API Documentation</a> */ @Override public CompletableFuture<APostOperationResponse> aPostOperation(APostOperationRequest aPostOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperation"); HttpResponseHandler<APostOperationResponse> responseHandler = protocolFactory .createResponseHandler(APostOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); String hostPrefix = "foo-"; String resolvedHostExpression = "foo-"; CompletableFuture<APostOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationRequest, APostOperationResponse>() .withOperationName("APostOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .hostPrefixExpression(resolvedHostExpression).withInput(aPostOperationRequest)); CompletableFuture<APostOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * <p> * Performs a post operation to the query service and has modelled output * </p> * * @param aPostOperationWithOutputRequest * @return A Java Future containing the result of the APostOperationWithOutput operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>InvalidInputException The request was rejected because an invalid or out-of-range value was supplied * for an input parameter.</li> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.APostOperationWithOutput * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/APostOperationWithOutput" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<APostOperationWithOutputResponse> aPostOperationWithOutput( APostOperationWithOutputRequest aPostOperationWithOutputRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(aPostOperationWithOutputRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, aPostOperationWithOutputRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "APostOperationWithOutput"); HttpResponseHandler<APostOperationWithOutputResponse> responseHandler = protocolFactory .createResponseHandler(APostOperationWithOutputResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<APostOperationWithOutputResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<APostOperationWithOutputRequest, APostOperationWithOutputResponse>() .withOperationName("APostOperationWithOutput").withProtocolMetadata(protocolMetadata) .withMarshaller(new APostOperationWithOutputRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(aPostOperationWithOutputRequest)); CompletableFuture<APostOperationWithOutputResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the BearerAuthOperation operation asynchronously. * * @param bearerAuthOperationRequest * @return A Java Future containing the result of the BearerAuthOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.BearerAuthOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/BearerAuthOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<BearerAuthOperationResponse> bearerAuthOperation( BearerAuthOperationRequest bearerAuthOperationRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(bearerAuthOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, bearerAuthOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "BearerAuthOperation"); HttpResponseHandler<BearerAuthOperationResponse> responseHandler = protocolFactory .createResponseHandler(BearerAuthOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<BearerAuthOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<BearerAuthOperationRequest, BearerAuthOperationResponse>() .withOperationName("BearerAuthOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new BearerAuthOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .credentialType(CredentialType.TOKEN).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withInput(bearerAuthOperationRequest)); CompletableFuture<BearerAuthOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the GetOperationWithChecksum operation asynchronously. * * @param getOperationWithChecksumRequest * @return A Java Future containing the result of the GetOperationWithChecksum operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.GetOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/GetOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<GetOperationWithChecksumResponse> getOperationWithChecksum( GetOperationWithChecksumRequest getOperationWithChecksumRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(getOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, getOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "GetOperationWithChecksum"); HttpResponseHandler<GetOperationWithChecksumResponse> responseHandler = protocolFactory .createResponseHandler(GetOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<GetOperationWithChecksumResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<GetOperationWithChecksumRequest, GetOperationWithChecksumResponse>() .withOperationName("GetOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller(new GetOperationWithChecksumRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(true) .requestAlgorithm(getOperationWithChecksumRequest.checksumAlgorithmAsString()) .isRequestStreaming(false).build()).withInput(getOperationWithChecksumRequest)); CompletableFuture<GetOperationWithChecksumResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithChecksumRequired operation asynchronously. * * @param operationWithChecksumRequiredRequest * @return A Java Future containing the result of the OperationWithChecksumRequired operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithChecksumRequired * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithChecksumRequired" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithChecksumRequiredResponse> operationWithChecksumRequired( OperationWithChecksumRequiredRequest operationWithChecksumRequiredRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithChecksumRequiredRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithChecksumRequiredRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithChecksumRequired"); HttpResponseHandler<OperationWithChecksumRequiredResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithChecksumRequiredResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithChecksumRequiredResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithChecksumRequiredRequest, OperationWithChecksumRequiredResponse>() .withOperationName("OperationWithChecksumRequired") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithChecksumRequiredRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.HTTP_CHECKSUM_REQUIRED, HttpChecksumRequired.create()).withInput(operationWithChecksumRequiredRequest)); CompletableFuture<OperationWithChecksumRequiredResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithContextParam operation asynchronously. * * @param operationWithContextParamRequest * @return A Java Future containing the result of the OperationWithContextParam operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithContextParam * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithContextParam" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithContextParamResponse> operationWithContextParam( OperationWithContextParamRequest operationWithContextParamRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithContextParamRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithContextParamRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithContextParam"); HttpResponseHandler<OperationWithContextParamResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithContextParamResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithContextParamResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithContextParamRequest, OperationWithContextParamResponse>() .withOperationName("OperationWithContextParam").withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithContextParamRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(operationWithContextParamRequest)); CompletableFuture<OperationWithContextParamResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithNoneAuthType operation asynchronously. * * @param operationWithNoneAuthTypeRequest * @return A Java Future containing the result of the OperationWithNoneAuthType operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithNoneAuthType * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithNoneAuthType" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithNoneAuthTypeResponse> operationWithNoneAuthType( OperationWithNoneAuthTypeRequest operationWithNoneAuthTypeRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithNoneAuthTypeRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithNoneAuthTypeRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithNoneAuthType"); HttpResponseHandler<OperationWithNoneAuthTypeResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithNoneAuthTypeResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithNoneAuthTypeResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithNoneAuthTypeRequest, OperationWithNoneAuthTypeResponse>() .withOperationName("OperationWithNoneAuthType").withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithNoneAuthTypeRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(operationWithNoneAuthTypeRequest)); CompletableFuture<OperationWithNoneAuthTypeResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithRequestCompression operation asynchronously. * * @param operationWithRequestCompressionRequest * @return A Java Future containing the result of the OperationWithRequestCompression operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithRequestCompression * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithRequestCompression" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithRequestCompressionResponse> operationWithRequestCompression( OperationWithRequestCompressionRequest operationWithRequestCompressionRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithRequestCompressionRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithRequestCompressionRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithRequestCompression"); HttpResponseHandler<OperationWithRequestCompressionResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithRequestCompressionResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithRequestCompressionResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithRequestCompressionRequest, OperationWithRequestCompressionResponse>() .withOperationName("OperationWithRequestCompression") .withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithRequestCompressionRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute(SdkInternalExecutionAttribute.REQUEST_COMPRESSION, RequestCompression.builder().encodings("gzip").isStreaming(false).build()) .withInput(operationWithRequestCompressionRequest)); CompletableFuture<OperationWithRequestCompressionResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the OperationWithStaticContextParams operation asynchronously. * * @param operationWithStaticContextParamsRequest * @return A Java Future containing the result of the OperationWithStaticContextParams operation returned by the * service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.OperationWithStaticContextParams * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/OperationWithStaticContextParams" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<OperationWithStaticContextParamsResponse> operationWithStaticContextParams( OperationWithStaticContextParamsRequest operationWithStaticContextParamsRequest) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(operationWithStaticContextParamsRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, operationWithStaticContextParamsRequest.overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "OperationWithStaticContextParams"); HttpResponseHandler<OperationWithStaticContextParamsResponse> responseHandler = protocolFactory .createResponseHandler(OperationWithStaticContextParamsResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<OperationWithStaticContextParamsResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<OperationWithStaticContextParamsRequest, OperationWithStaticContextParamsResponse>() .withOperationName("OperationWithStaticContextParams").withProtocolMetadata(protocolMetadata) .withMarshaller(new OperationWithStaticContextParamsRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(operationWithStaticContextParamsRequest)); CompletableFuture<OperationWithStaticContextParamsResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Invokes the PutOperationWithChecksum operation asynchronously. * * @param putOperationWithChecksumRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows ' * <p> * Object data. * </p> * ' * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows ' * <p> * Object data. * </p> * '. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.PutOperationWithChecksum * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/PutOperationWithChecksum" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> putOperationWithChecksum( PutOperationWithChecksumRequest putOperationWithChecksumRequest, AsyncRequestBody requestBody, AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(putOperationWithChecksumRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, putOperationWithChecksumRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "PutOperationWithChecksum"); Pair<AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); HttpResponseHandler<PutOperationWithChecksumResponse> responseHandler = protocolFactory .createResponseHandler(PutOperationWithChecksumResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<PutOperationWithChecksumRequest, PutOperationWithChecksumResponse>() .withOperationName("PutOperationWithChecksum") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new PutOperationWithChecksumRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()) .withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector) .putExecutionAttribute( SdkInternalExecutionAttribute.HTTP_CHECKSUM, HttpChecksum.builder().requestChecksumRequired(false) .requestValidationMode(putOperationWithChecksumRequest.checksumModeAsString()) .responseAlgorithms("CRC32C", "CRC32", "SHA1", "SHA256").isRequestStreaming(true) .build()).withAsyncRequestBody(requestBody) .withInput(putOperationWithChecksumRequest), asyncResponseTransformer); CompletableFuture<ReturnT> whenCompleteFuture = null; AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { AsyncResponseTransformer<PutOperationWithChecksumResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming input * * @param streamingInputOperationRequest * @param requestBody * Functional interface that can be implemented to produce the request content in a non-blocking manner. The * size of the content is expected to be known up front. See {@link AsyncRequestBody} for specific details on * implementing this interface as well as links to precanned implementations for common scenarios like * uploading from a file. The service documentation for the request content is as follows 'This be a stream' * @return A Java Future containing the result of the StreamingInputOperation operation returned by the service.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.StreamingInputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingInputOperation" * target="_top">AWS API Documentation</a> */ @Override public CompletableFuture<StreamingInputOperationResponse> streamingInputOperation( StreamingInputOperationRequest streamingInputOperationRequest, AsyncRequestBody requestBody) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingInputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingInputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingInputOperation"); HttpResponseHandler<StreamingInputOperationResponse> responseHandler = protocolFactory .createResponseHandler(StreamingInputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<StreamingInputOperationResponse> executeFuture = clientHandler .execute(new ClientExecutionParams<StreamingInputOperationRequest, StreamingInputOperationResponse>() .withOperationName("StreamingInputOperation") .withProtocolMetadata(protocolMetadata) .withMarshaller( AsyncStreamingRequestMarshaller.builder() .delegateMarshaller(new StreamingInputOperationRequestMarshaller(protocolFactory)) .asyncRequestBody(requestBody).build()).withResponseHandler(responseHandler) .withErrorResponseHandler(errorResponseHandler).withRequestConfiguration(clientConfiguration) .withMetricCollector(apiCallMetricCollector).withAsyncRequestBody(requestBody) .withInput(streamingInputOperationRequest)); CompletableFuture<StreamingInputOperationResponse> whenCompleteFuture = null; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } /** * Some operation with a streaming output * * @param streamingOutputOperationRequest * @param asyncResponseTransformer * The response transformer for processing the streaming response in a non-blocking manner. See * {@link AsyncResponseTransformer} for details on how this callback should be implemented and for links to * precanned implementations for common scenarios like downloading to a file. The service documentation for * the response content is as follows 'This be a stream'. * @return A future to the transformed result of the AsyncResponseTransformer.<br/> * The CompletableFuture returned by this method can be completed exceptionally with the following * exceptions. * <ul> * <li>SdkException Base class for all exceptions that can be thrown by the SDK (both service and client). * Can be used for catch all scenarios.</li> * <li>SdkClientException If any client side error occurs such as an IO related failure, failure to get * credentials, etc.</li> * <li>QueryException Base class for all service exceptions. Unknown exceptions will be thrown as an * instance of this type.</li> * </ul> * @sample QueryAsyncClient.StreamingOutputOperation * @see <a href="https://docs.aws.amazon.com/goto/WebAPI/query-service-2010-05-08/StreamingOutputOperation" * target="_top">AWS API Documentation</a> */ @Override public <ReturnT> CompletableFuture<ReturnT> streamingOutputOperation( StreamingOutputOperationRequest streamingOutputOperationRequest, AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> asyncResponseTransformer) { SdkClientConfiguration clientConfiguration = updateSdkClientConfiguration(streamingOutputOperationRequest, this.clientConfiguration); List<MetricPublisher> metricPublishers = resolveMetricPublishers(clientConfiguration, streamingOutputOperationRequest .overrideConfiguration().orElse(null)); MetricCollector apiCallMetricCollector = metricPublishers.isEmpty() ? NoOpMetricCollector.create() : MetricCollector .create("ApiCall"); try { apiCallMetricCollector.reportMetric(CoreMetric.SERVICE_ID, "Query Service"); apiCallMetricCollector.reportMetric(CoreMetric.OPERATION_NAME, "StreamingOutputOperation"); Pair<AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT>, CompletableFuture<Void>> pair = AsyncResponseTransformerUtils .wrapWithEndOfStreamFuture(asyncResponseTransformer); asyncResponseTransformer = pair.left(); CompletableFuture<Void> endOfStreamFuture = pair.right(); HttpResponseHandler<StreamingOutputOperationResponse> responseHandler = protocolFactory .createResponseHandler(StreamingOutputOperationResponse::builder); HttpResponseHandler<AwsServiceException> errorResponseHandler = protocolFactory.createErrorResponseHandler(); CompletableFuture<ReturnT> executeFuture = clientHandler.execute( new ClientExecutionParams<StreamingOutputOperationRequest, StreamingOutputOperationResponse>() .withOperationName("StreamingOutputOperation").withProtocolMetadata(protocolMetadata) .withMarshaller(new StreamingOutputOperationRequestMarshaller(protocolFactory)) .withResponseHandler(responseHandler).withErrorResponseHandler(errorResponseHandler) .withRequestConfiguration(clientConfiguration).withMetricCollector(apiCallMetricCollector) .withInput(streamingOutputOperationRequest), asyncResponseTransformer); CompletableFuture<ReturnT> whenCompleteFuture = null; AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; whenCompleteFuture = executeFuture.whenComplete((r, e) -> { if (e != null) { runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(e)); } endOfStreamFuture.whenComplete((r2, e2) -> { metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); }); }); return CompletableFutureUtils.forwardExceptionTo(whenCompleteFuture, executeFuture); } catch (Throwable t) { AsyncResponseTransformer<StreamingOutputOperationResponse, ReturnT> finalAsyncResponseTransformer = asyncResponseTransformer; runAndLogError(log, "Exception thrown in exceptionOccurred callback, ignoring", () -> finalAsyncResponseTransformer.exceptionOccurred(t)); metricPublishers.forEach(p -> p.publish(apiCallMetricCollector.collect())); return CompletableFutureUtils.failedFuture(t); } } @Override public QueryAsyncWaiter waiter() { return QueryAsyncWaiter.builder().client(this).scheduledExecutorService(executorService).build(); } @Override public final QueryServiceClientConfiguration serviceClientConfiguration() { return new QueryServiceClientConfigurationBuilder(this.clientConfiguration.toBuilder()).build(); } @Override public final String serviceName() { return SERVICE_NAME; } private AwsQueryProtocolFactory init() { return AwsQueryProtocolFactory .builder() .registerModeledException( ExceptionMetadata.builder().errorCode("InvalidInput") .exceptionBuilderSupplier(InvalidInputException::builder).httpStatusCode(400).build()) .clientConfiguration(clientConfiguration).defaultServiceExceptionSupplier(QueryException::builder).build(); } private static List<MetricPublisher> resolveMetricPublishers(SdkClientConfiguration clientConfiguration, RequestOverrideConfiguration requestOverrideConfiguration) { List<MetricPublisher> publishers = null; if (requestOverrideConfiguration != null) { publishers = requestOverrideConfiguration.metricPublishers(); } if (publishers == null || publishers.isEmpty()) { publishers = clientConfiguration.option(SdkClientOption.METRIC_PUBLISHERS); } if (publishers == null) { publishers = Collections.emptyList(); } return publishers; } private SdkClientConfiguration updateSdkClientConfiguration(SdkRequest request, SdkClientConfiguration clientConfiguration) { List<SdkPlugin> plugins = request.overrideConfiguration().map(c -> c.plugins()).orElse(Collections.emptyList()); if (plugins.isEmpty()) { return clientConfiguration; } SdkClientConfiguration.Builder configuration = clientConfiguration.toBuilder(); QueryServiceClientConfigurationBuilder serviceConfigBuilder = new QueryServiceClientConfigurationBuilder(configuration); for (SdkPlugin plugin : plugins) { plugin.configureClient(serviceConfigBuilder); } return configuration.build(); } @Override public void close() { clientHandler.close(); } }
3,283
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/AddShapesTest.java
/* * 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.codegen; import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.intermediate.MemberModel; import software.amazon.awssdk.codegen.model.intermediate.ShapeModel; import software.amazon.awssdk.codegen.model.service.Location; import software.amazon.awssdk.codegen.model.service.ServiceModel; import software.amazon.awssdk.codegen.poet.model.AwsModelSpecTest; import software.amazon.awssdk.codegen.utils.ModelLoaderUtils; class AddShapesTest { private static IntermediateModel intermediateModel; @BeforeAll public static void setUp() throws IOException { File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile()); File customizationConfigFile = new File(AwsModelSpecTest.class .getResource("customization.config") .getFile()); intermediateModel = new IntermediateModelBuilder( C2jModels.builder() .serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile)) .customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile)) .build()) .build(); } @Test void generateShapeModel_memberRequiredByShape_setsMemberModelAsRequired() { String requestShapeName = "QueryParameterOperationRequest"; String queryParamName = "QueryParamOne"; ShapeModel requestShapeModel = intermediateModel.getShapes().get(requestShapeName); MemberModel requiredMemberModel = requestShapeModel.findMemberModelByC2jName(queryParamName); assertThat(requestShapeModel.getRequired()).contains(queryParamName); assertThat(requiredMemberModel.getHttp().getLocation()).isEqualTo(Location.QUERY_STRING); assertThat(requiredMemberModel.isRequired()).isTrue(); } @Test void generateShapeModel_memberNotRequiredByShape_doesNotSetMemberModelAsRequired() { String requestShapeName = "QueryParameterOperationRequest"; String queryParamName = "QueryParamTwo"; ShapeModel requestShapeModel = intermediateModel.getShapes().get(requestShapeName); MemberModel requiredMemberModel = requestShapeModel.findMemberModelByC2jName(queryParamName); assertThat(requestShapeModel.getRequired()).doesNotContain(queryParamName); assertThat(requiredMemberModel.getHttp().getLocation()).isEqualTo(Location.QUERY_STRING); assertThat(requiredMemberModel.isRequired()).isFalse(); } @Test void generateShapeModel_memberRequiredByNestedShape_setsMemberModelAsRequired() { String requestShapeName = "NestedQueryParameterOperation"; String queryParamName = "QueryParamOne"; ShapeModel requestShapeModel = intermediateModel.getShapes().get(requestShapeName); MemberModel requiredMemberModel = requestShapeModel.findMemberModelByC2jName(queryParamName); assertThat(requestShapeModel.getRequired()).contains(queryParamName); assertThat(requiredMemberModel.getHttp().getLocation()).isEqualTo(Location.QUERY_STRING); assertThat(requiredMemberModel.isRequired()).isTrue(); } }
3,284
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/TestStringUtils.java
package software.amazon.awssdk.codegen; import software.amazon.awssdk.codegen.internal.Constant; /** * Various convenience methods for strings manipulation required in Code Generator tests. */ public final class TestStringUtils { /** * Not intended to be constructed directly. */ private TestStringUtils() { } /** * Replaces all the newline (line feed/LF) characters ('&#x5c;u000A' or '\n') with the platform-dependent line separator char * (e.g. "&#x5c;u000D&#x5c;u000A" or "\r\n" on Windows systems). * * @param str string, containing '\n' chars to be replaced * @return original string with '\n' chars replaced with platform-dependent line separator chars * @see Constant#LF */ public static String toPlatformLfs(String str) { return str.replaceAll("\n", Constant.LF); } }
3,285
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/IntermediateModelBuilderTest.java
/* * 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.codegen; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertNotNull; import java.io.File; import org.junit.jupiter.api.Test; import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.intermediate.ShapeModel; import software.amazon.awssdk.codegen.model.service.ServiceModel; import software.amazon.awssdk.codegen.utils.ModelLoaderUtils; public class IntermediateModelBuilderTest { @Test public void testServiceAndShapeNameCollisions() throws Exception { final File modelFile = new File(IntermediateModelBuilderTest.class .getResource("poet/client/c2j/collision/service-2.json").getFile()); IntermediateModel testModel = new IntermediateModelBuilder( C2jModels.builder() .serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile)) .customizationConfig(CustomizationConfig.create()) .build()) .build(); assertThat(testModel.getShapes().values()) .extracting(ShapeModel::getShapeName) .containsExactlyInAnyOrder("DefaultCollisionException", "DefaultCollisionRequest", "DefaultCollisionResponse"); } @Test public void sharedOutputShapesLinkCorrectlyToOperationOutputs() { final File modelFile = new File(IntermediateModelBuilderTest.class .getResource("poet/client/c2j/shared-output/service-2.json").getFile()); IntermediateModel testModel = new IntermediateModelBuilder( C2jModels.builder() .serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile)) .customizationConfig(CustomizationConfig.create()) .build()) .build(); assertEquals("PingResponse", testModel.getOperation("Ping").getOutputShape().getShapeName()); assertEquals("SecurePingResponse", testModel.getOperation("SecurePing").getOutputShape().getShapeName()); } @Test public void defaultEndpointDiscovery_true() { final File modelFile = new File(IntermediateModelBuilderTest.class .getResource("poet/client/c2j/endpointdiscovery/service-2.json").getFile()); IntermediateModel testModel = new IntermediateModelBuilder( C2jModels.builder() .serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile)) .customizationConfig(CustomizationConfig.create()) .build()) .build(); assertTrue(testModel.getEndpointOperation().get().isEndpointCacheRequired()); } @Test public void defaultEndpointDiscovery_false() { final File modelFile = new File(IntermediateModelBuilderTest.class .getResource("poet/client/c2j/endpointdiscoveryoptional/service-2.json").getFile()); IntermediateModel testModel = new IntermediateModelBuilder( C2jModels.builder() .serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile)) .customizationConfig(CustomizationConfig.create()) .build()) .build(); assertFalse(testModel.getEndpointOperation().get().isEndpointCacheRequired()); } @Test public void assertAwsQueryCompatibleTrait_notNull() { final File modelFile = new File(IntermediateModelBuilderTest.class .getResource("poet/client/c2j/query-to-json-errorcode/service-2.json").getFile()); IntermediateModel testModel = new IntermediateModelBuilder( C2jModels.builder() .serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, modelFile)) .customizationConfig(CustomizationConfig.create()) .build()) .build(); assertNotNull(testModel.getMetadata().getAwsQueryCompatible()); } }
3,286
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization/processors/UseLegacyEventGenerationSchemeProcessorTest.java
/* * 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.codegen.customization.processors; import java.io.File; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; import org.junit.rules.ExpectedException; import software.amazon.awssdk.codegen.C2jModels; import software.amazon.awssdk.codegen.IntermediateModelBuilder; import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.service.ServiceModel; import software.amazon.awssdk.codegen.utils.ModelLoaderUtils; /** * Tests for {@link UseLegacyEventGenerationSchemeProcessor} */ public class UseLegacyEventGenerationSchemeProcessorTest { private static final String RESOURCE_ROOT = "/software/amazon/awssdk/codegen/emitters/customizations/processors/uselegacyeventgenerationscheme"; private static final UseLegacyEventGenerationSchemeProcessor processor = new UseLegacyEventGenerationSchemeProcessor(); @Rule public ExpectedException thrown = ExpectedException.none(); private static ServiceModel serviceModel; @BeforeClass public static void setup() { String c2jFilePath = UseLegacyEventGenerationSchemeProcessorTest.class.getResource(RESOURCE_ROOT + "/service-2.json").getFile(); File c2jFile = new File(c2jFilePath); serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, c2jFile); } @Test public void testPostProcess_customizationDeclaredForMultipleMembersWithSameShape_throws() { thrown.expect(IllegalArgumentException.class); thrown.expectMessage("targets more than one member with the shape"); IntermediateModel intermediateModel = intermediateModelWithConfig("multiple-event-types-same-shape.config"); processor.postprocess(intermediateModel); } @Test public void testPostProcess_customizationIsValid_succeeds() { IntermediateModel intermediateModel = intermediateModelWithConfig("happy-case-customization.config"); processor.postprocess(intermediateModel); } private static IntermediateModel intermediateModelWithConfig(String configName) { return new IntermediateModelBuilder(C2jModels.builder() .serviceModel(serviceModel) .customizationConfig(loadCustomizationConfig(configName)) .build()) .build(); } private static CustomizationConfig loadCustomizationConfig(String configName) { String c2jFilePath = UseLegacyEventGenerationSchemeProcessorTest.class.getResource(RESOURCE_ROOT + "/" + configName).getFile(); File file = new File(c2jFilePath); return ModelLoaderUtils.loadModel(CustomizationConfig.class, file); } }
3,287
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization/processors/S3RemoveBucketFromUriProcessorTest.java
/* * 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.codegen.customization.processors; import static org.assertj.core.api.Assertions.assertThat; import java.util.HashMap; import java.util.Map; import org.junit.Test; import software.amazon.awssdk.codegen.model.service.Http; import software.amazon.awssdk.codegen.model.service.Operation; import software.amazon.awssdk.codegen.model.service.ServiceMetadata; import software.amazon.awssdk.codegen.model.service.ServiceModel; public class S3RemoveBucketFromUriProcessorTest { private static final String WITH_BUCKET_URI_OPERATION = "WithBucketInUri"; private static final String WITHOUT_BUCKET_URI_OPERATION = "WithoutBucketInUri"; private static final String WITH_BUCKET_URI = "/{Bucket}/{Key+}"; private static final String WITHOUT_BUCKET_URI = "/{Key+}"; private final S3RemoveBucketFromUriProcessor processor = new S3RemoveBucketFromUriProcessor(); @Test public void preprocess_serviceNotS3_doesNotModifyUri() { ServiceModel nonS3 = createServiceModel("NonS3"); processor.preprocess(nonS3); Map<String, Operation> operations = nonS3.getOperations(); assertThat(operations.get(WITH_BUCKET_URI_OPERATION).getHttp().getRequestUri()).isEqualTo(WITH_BUCKET_URI); assertThat(operations.get(WITHOUT_BUCKET_URI_OPERATION).getHttp().getRequestUri()).isEqualTo(WITHOUT_BUCKET_URI); } @Test public void preprocess_serviceIsS3_operationHasBucket_modifiesUri() { ServiceModel s3 = createServiceModel("S3"); processor.preprocess(s3); Map<String, Operation> operations = s3.getOperations(); assertThat(operations.get(WITH_BUCKET_URI_OPERATION).getHttp().getRequestUri()).isEqualTo("/{Key+}"); } @Test public void preprocess_serviceIsS3_operationDoesNotHaveBucket_noModification() { ServiceModel s3 = createServiceModel("S3"); processor.preprocess(s3); Map<String, Operation> operations = s3.getOperations(); assertThat(operations.get(WITHOUT_BUCKET_URI_OPERATION).getHttp().getRequestUri()).isEqualTo(WITHOUT_BUCKET_URI); } private static ServiceModel createServiceModel(String serviceId) { ServiceModel model = new ServiceModel(); ServiceMetadata serviceMetadata = new ServiceMetadata(); serviceMetadata.setServiceId(serviceId); model.setMetadata(serviceMetadata); Operation operationWithBucketInUri = new Operation() .withHttp(new Http().withRequestUri(WITH_BUCKET_URI)); Operation operationWithoutBucketInUri = new Operation() .withHttp(new Http().withRequestUri(WITHOUT_BUCKET_URI)); Map<String, Operation> operations = new HashMap<>(); operations.put(WITH_BUCKET_URI_OPERATION, operationWithBucketInUri); operations.put(WITHOUT_BUCKET_URI_OPERATION, operationWithoutBucketInUri); model.setOperations(operations); return model; } }
3,288
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization/processors/S3ControlRemoveAccountIdHostPrefixProcessorTest.java
/* * 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.codegen.customization.processors; import static org.assertj.core.api.Assertions.assertThat; import java.util.HashMap; import java.util.Map; import org.junit.Test; import software.amazon.awssdk.codegen.model.service.EndpointTrait; import software.amazon.awssdk.codegen.model.service.Operation; import software.amazon.awssdk.codegen.model.service.ServiceMetadata; import software.amazon.awssdk.codegen.model.service.ServiceModel; public class S3ControlRemoveAccountIdHostPrefixProcessorTest { private static final String WITH_ACCOUNT_ID_PREFIX = "WithBucketInUri"; private static final String WITHOUT_ACCOUNT_ID_PREFIX = "WithoutBucketInUri"; private static final String ACCOUNT_ID_PREFIX = "{AccountId}."; private final S3ControlRemoveAccountIdHostPrefixProcessor processor = new S3ControlRemoveAccountIdHostPrefixProcessor(); @Test public void preprocess_serviceNotS3Control_doesNotModify() { ServiceModel nonS3 = createServiceModel("NonS3Control"); processor.preprocess(nonS3); Map<String, Operation> operations = nonS3.getOperations(); assertThat(operations.get(WITH_ACCOUNT_ID_PREFIX).getEndpoint().getHostPrefix()).isEqualTo(ACCOUNT_ID_PREFIX); assertThat(operations.get(WITHOUT_ACCOUNT_ID_PREFIX).getEndpoint()).isNull(); } @Test public void preprocess_serviceIsS3Control_operationAccountIdPrefix_modifiesPrefix() { ServiceModel s3Control = createServiceModel("S3 Control"); processor.preprocess(s3Control); Map<String, Operation> operations = s3Control.getOperations(); assertThat(operations.get(WITH_ACCOUNT_ID_PREFIX).getEndpoint().getHostPrefix()).isNull(); } @Test public void preprocess_serviceIsS3Control_operationDoesNotAccountIdPrefix_noModification() { ServiceModel s3Control = createServiceModel("S3 Control"); processor.preprocess(s3Control); Map<String, Operation> operations = s3Control.getOperations(); assertThat(operations.get(WITHOUT_ACCOUNT_ID_PREFIX).getEndpoint()).isNull();; } private static ServiceModel createServiceModel(String serviceId) { ServiceModel model = new ServiceModel(); ServiceMetadata serviceMetadata = new ServiceMetadata(); serviceMetadata.setServiceId(serviceId); model.setMetadata(serviceMetadata); Operation operationWithoutAccountIdPrefix = new Operation(); Operation operationWithAccountIdPrefix = new Operation(); EndpointTrait endpointTrait = new EndpointTrait(); endpointTrait.setHostPrefix(ACCOUNT_ID_PREFIX); operationWithAccountIdPrefix.setEndpoint(endpointTrait); Map<String, Operation> operations = new HashMap<>(); operations.put(WITH_ACCOUNT_ID_PREFIX, operationWithAccountIdPrefix); operations.put(WITHOUT_ACCOUNT_ID_PREFIX, operationWithoutAccountIdPrefix); model.setOperations(operations); return model; } }
3,289
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/customization/processors/CustomSdkShapesProcessorTest.java
/* * 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.codegen.customization.processors; import static org.assertj.core.api.Assertions.assertThatNullPointerException; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; import java.io.File; import java.io.IOException; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import software.amazon.awssdk.codegen.C2jModels; import software.amazon.awssdk.codegen.IntermediateModelBuilder; import software.amazon.awssdk.codegen.model.config.customization.CustomSdkShapes; import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig; import software.amazon.awssdk.codegen.model.service.Member; import software.amazon.awssdk.codegen.model.service.ServiceModel; import software.amazon.awssdk.codegen.model.service.Shape; import software.amazon.awssdk.codegen.poet.model.AwsModelSpecTest; import software.amazon.awssdk.codegen.utils.ModelLoaderUtils; public class CustomSdkShapesProcessorTest { CustomizationConfig config; ServiceModel serviceModel; @BeforeEach public void setUp() throws IOException { File serviceModelFile = new File(AwsModelSpecTest.class.getResource("service-2.json").getFile()); File customizationConfigFile = new File(AwsModelSpecTest.class.getResource("customization.config").getFile()); serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile); config = ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile); } @Test public void setCustomStringShape_isAddedToModel() { CustomSdkShapes customSdkShapes = config.getCustomSdkShapes(); Map<String, Shape> shapes = new HashMap<>(); shapes.putAll(customSdkShapes.getShapes()); Shape stringShape = new Shape(); stringShape.setType("string"); String shapeName = "StringShape"; shapes.put(shapeName, stringShape); customSdkShapes.setShapes(shapes); config.setCustomSdkShapes(customSdkShapes); new IntermediateModelBuilder(C2jModels.builder() .serviceModel(serviceModel) .customizationConfig(config) .build()) .build(); assertThat(serviceModel.getShapes()).containsKey(shapeName); assertThat(serviceModel.getShapes()).containsValue(stringShape); assertThat(serviceModel.getShape(shapeName).getType()).isEqualTo("string"); } @Test public void setCustomListShape_isAddedToModel() { CustomSdkShapes customSdkShapes = config.getCustomSdkShapes(); Map<String, Shape> shapes = new HashMap<>(); shapes.putAll(customSdkShapes.getShapes()); Shape listShape = new Shape(); listShape.setType("list"); Member member = new Member(); String memberName = "Event"; member.setShape(memberName); listShape.setMember(member); String shapeName = "ListShape"; shapes.put(shapeName, listShape); customSdkShapes.setShapes(shapes); config.setCustomSdkShapes(customSdkShapes); new IntermediateModelBuilder(C2jModels.builder() .serviceModel(serviceModel) .customizationConfig(config) .build()) .build(); assertThat(serviceModel.getShapes()).containsKey(shapeName); assertThat(serviceModel.getShapes()).containsValue(listShape); assertThat(serviceModel.getShape(shapeName).getType()).isEqualTo("list"); assertThat(serviceModel.getShape(shapeName).getListMember()).isEqualTo(member); assertThat(serviceModel.getShape(shapeName).getListMember().getShape()).isEqualTo("Event"); } @Test public void setCustomCustomizedShape_isAddedToModel() { CustomSdkShapes customSdkShapes = config.getCustomSdkShapes(); Map<String, Shape> shapes = new HashMap<>(); shapes.putAll(customSdkShapes.getShapes()); Shape stringShape = new Shape(); stringShape.setType("string"); String shapeName = "StringShape"; shapes.put(shapeName, stringShape); Shape customizedShape = new Shape(); customizedShape.setType(shapeName); String customizedShapeName = "CustomizedShape"; shapes.put(customizedShapeName, customizedShape); customSdkShapes.setShapes(shapes); config.setCustomSdkShapes(customSdkShapes); new IntermediateModelBuilder(C2jModels.builder() .serviceModel(serviceModel) .customizationConfig(config) .build()) .build(); assertThat(serviceModel.getShapes()).containsKey(customizedShapeName); assertThat(serviceModel.getShapes()).containsValue(customizedShape); assertThat(serviceModel.getShape(customizedShapeName).getType()).isEqualTo(shapeName); } @Test public void setCustomNullShape_throwsNullPointerException() { CustomSdkShapes customSdkShapes = config.getCustomSdkShapes(); Map<String, Shape> shapes = new HashMap<>(); shapes.putAll(customSdkShapes.getShapes()); Shape stringShape = new Shape(); stringShape.setType(null); String shapeName = "NullShape"; shapes.put(shapeName, stringShape); customSdkShapes.setShapes(shapes); config.setCustomSdkShapes(customSdkShapes); assertThatNullPointerException() .isThrownBy(() -> new IntermediateModelBuilder(C2jModels.builder() .serviceModel(serviceModel) .customizationConfig(config) .build()). build()); } }
3,290
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/internal/UtilsTest.java
/* * 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.codegen.internal; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.is; import java.util.HashMap; import java.util.Map; import org.junit.jupiter.api.Test; public class UtilsTest { final Map<String,String> capitalizedToUncapitalized = new HashMap<String,String>() {{ put("A", "a"); put("AB", "ab"); put("ABC", "abc"); put("ABCD", "abcd"); put("AToken", "aToken"); put("MFAToken", "mfaToken"); put("AWSRequest", "awsRequest"); put("MfaToken", "mfaToken"); put("AwsRequest", "awsRequest"); }}; @Test public void testUnCapitalize() { capitalizedToUncapitalized.forEach((capitalized,unCapitalized) -> assertThat(Utils.unCapitalize(capitalized), is(equalTo(unCapitalized)))); } }
3,291
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/internal/DocumentationUtilsTest.java
/* * 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.codegen.internal; import static org.hamcrest.MatcherAssert.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; public class DocumentationUtilsTest { @Test public void strip_html_tags_null_or_empty_input_returns_empty_string() { assertThat(DocumentationUtils.stripHtmlTags(null), Matchers .isEmptyString()); assertThat(DocumentationUtils.stripHtmlTags(""), Matchers .isEmptyString()); } @Test public void html_tags_at_start_of_string_are_removed() { assertEquals("foo", DocumentationUtils.stripHtmlTags ("<bar>foo</bar>")); } @Test public void empty_html_tags_at_start_are_removed() { assertThat(DocumentationUtils.stripHtmlTags("<p></p>"), Matchers .isEmptyString()); assertThat(DocumentationUtils.stripHtmlTags("<p/>"), Matchers .isEmptyString()); } }
3,292
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/PoetCollectorsTest.java
/* * 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.codegen.poet; import static org.assertj.core.api.Assertions.assertThat; import com.squareup.javapoet.CodeBlock; import java.util.stream.Stream; import org.junit.jupiter.api.Test; /** * Validate functionality of the {@link PoetCollectors}. */ public class PoetCollectorsTest { @Test public void emptyCollectIsEmptyCodeBlock() { CodeBlock result = Stream.<CodeBlock>of().collect(PoetCollectors.toCodeBlock()); assertThat(result).isEqualTo(CodeBlock.builder().build()); } @Test public void emptyDelimitedCollectIsEmptyCodeBlock() { CodeBlock result = Stream.<CodeBlock>of().collect(PoetCollectors.toDelimitedCodeBlock(",")); assertThat(result).isEqualTo(CodeBlock.builder().build()); } @Test public void codeBlocksJoined() { CodeBlock a = CodeBlock.of("a"); CodeBlock b = CodeBlock.of("b"); CodeBlock ab = CodeBlock.builder().add(a).add(b).build(); CodeBlock result = Stream.of(a, b).collect(PoetCollectors.toCodeBlock()); assertThat(result).isEqualTo(ab); } @Test public void delimitedCodeBlocksJoined() { CodeBlock a = CodeBlock.of("a"); CodeBlock b = CodeBlock.of("b"); CodeBlock delimeter = CodeBlock.of(","); CodeBlock ab = CodeBlock.builder().add(a).add(delimeter).add(b).build(); CodeBlock result = Stream.of(a, b).collect(PoetCollectors.toDelimitedCodeBlock(",")); assertThat(result).isEqualTo(ab); } }
3,293
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/PoetMatchers.java
/* * 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.codegen.poet; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalToIgnoringWhiteSpace; import static software.amazon.awssdk.codegen.poet.PoetUtils.buildJavaFile; import java.io.IOException; import java.io.InputStream; import org.hamcrest.Description; import org.hamcrest.Matcher; import org.hamcrest.TypeSafeMatcher; import org.junit.ComparisonFailure; import software.amazon.awssdk.codegen.emitters.CodeTransformer; import software.amazon.awssdk.codegen.emitters.JavaCodeFormatter; import software.amazon.awssdk.utils.IoUtils; import software.amazon.awssdk.utils.Validate; public final class PoetMatchers { private static final CodeTransformer processor = CodeTransformer.chain(new CopyrightRemover(), new JavaCodeFormatter()); private static final CodeTransformer formattingDisabledProcessor = CodeTransformer.chain(new CopyrightRemover()); public static Matcher<ClassSpec> generatesTo(String expectedTestFile, boolean disableFormatting) { return new TypeSafeMatcher<ClassSpec>() { @Override protected boolean matchesSafely(ClassSpec spec) { String expectedClass = getExpectedClass(spec, expectedTestFile, disableFormatting); String actualClass = generateClass(spec); try { assertThat(actualClass, equalToIgnoringWhiteSpace(expectedClass)); } catch (AssertionError e) { //Unfortunately for string comparisons Hamcrest doesn't really give us a nice diff. On the other hand //IDEs know how to nicely display JUnit's ComparisonFailure - makes debugging tests much easier throw new ComparisonFailure(String.format("Output class does not match expected [test-file: %s]", expectedTestFile), expectedClass, actualClass); } return true; } @Override public void describeTo(Description description) { //Since we bubble an exception this will never actually get called } }; } public static Matcher<ClassSpec> generatesTo(String expectedTestFile) { return new TypeSafeMatcher<ClassSpec>() { @Override protected boolean matchesSafely(ClassSpec spec) { String expectedClass = getExpectedClass(spec, expectedTestFile, false); String actualClass = generateClass(spec); try { assertThat(actualClass, equalToIgnoringWhiteSpace(expectedClass)); } catch (AssertionError e) { //Unfortunately for string comparisons Hamcrest doesn't really give us a nice diff. On the other hand //IDEs know how to nicely display JUnit's ComparisonFailure - makes debugging tests much easier throw new ComparisonFailure(String.format("Output class does not match expected [test-file: %s]", expectedTestFile), expectedClass, actualClass); } return true; } @Override public void describeTo(Description description) { //Since we bubble an exception this will never actually get called } }; } private static String getExpectedClass(ClassSpec spec, String testFile, boolean disableFormatting) { try { InputStream resource = spec.getClass().getResourceAsStream(testFile); Validate.notNull(resource, "Failed to load test file " + testFile + " with " + spec.getClass()); if (disableFormatting) { return formattingDisabledProcessor.apply(IoUtils.toUtf8String(resource)); } return processor.apply(IoUtils.toUtf8String(resource)); } catch (IOException e) { throw new RuntimeException(e); } } private static String generateClass(ClassSpec spec) { StringBuilder output = new StringBuilder(); try { buildJavaFile(spec).writeTo(output); } catch (IOException e) { throw new RuntimeException("Failed to generate class", e); } return processor.apply(output.toString()); } private static class CopyrightRemover implements CodeTransformer { @Override public String apply(String input) { return input.substring(input.indexOf("package")); } } }
3,294
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/ClientTestModels.java
/* * 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.codegen.poet; import java.io.File; import software.amazon.awssdk.codegen.C2jModels; import software.amazon.awssdk.codegen.IntermediateModelBuilder; import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.rules.endpoints.EndpointTestSuiteModel; import software.amazon.awssdk.codegen.model.service.EndpointRuleSetModel; import software.amazon.awssdk.codegen.model.service.Paginators; import software.amazon.awssdk.codegen.model.service.ServiceModel; import software.amazon.awssdk.codegen.model.service.Waiters; import software.amazon.awssdk.codegen.utils.ModelLoaderUtils; /** * A static set of service models that can be used for testing purposes. */ public class ClientTestModels { private ClientTestModels() {} public static IntermediateModel awsJsonServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/json/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/json/customization.config").getFile()); File paginatorsModel = new File(ClientTestModels.class.getResource("client/c2j/json/paginators.json").getFile()); C2jModels models = C2jModels.builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .paginatorsModel(getPaginatorsModel(paginatorsModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel awsQueryCompatibleJsonServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/query-to-json-errorcode/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/query-to-json-errorcode/customization.config").getFile()); File paginatorsModel = new File(ClientTestModels.class.getResource("client/c2j/query-to-json-errorcode/paginators.json").getFile()); C2jModels models = C2jModels.builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .paginatorsModel(getPaginatorsModel(paginatorsModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel bearerAuthServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/json-bearer-auth/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/json-bearer-auth/customization.config").getFile()); File paginatorsModel = new File(ClientTestModels.class.getResource("client/c2j/json-bearer-auth/paginators.json").getFile()); C2jModels models = C2jModels.builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .paginatorsModel(getPaginatorsModel(paginatorsModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel restJsonServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/rest-json/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/rest-json/customization.config").getFile()); File paginatorsModel = new File(ClientTestModels.class.getResource("client/c2j/rest-json/paginators.json").getFile()); C2jModels models = C2jModels.builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .paginatorsModel(getPaginatorsModel(paginatorsModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel queryServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/query/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/query/customization.config").getFile()); File waitersModel = new File(ClientTestModels.class.getResource("client/c2j/query/waiters-2.json").getFile()); File endpointRuleSetModel = new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-rule-set.json").getFile()); File endpointTestsModel = new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-tests.json").getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .waitersModel(getWaiters(waitersModel)) .endpointRuleSetModel(getEndpointRuleSet(endpointRuleSetModel)) .endpointTestSuiteModel(getEndpointTestSuite(endpointTestsModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel queryServiceModelsEndpointAuthParamsWithAllowList() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/query/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/query/customization-endpoint-auth-params-with-allowed.config") .getFile()); File waitersModel = new File(ClientTestModels.class.getResource("client/c2j/query/waiters-2.json").getFile()); File endpointRuleSetModel = new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-rule-set.json").getFile()); File endpointTestsModel = new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-tests.json").getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .waitersModel(getWaiters(waitersModel)) .endpointRuleSetModel(getEndpointRuleSet(endpointRuleSetModel)) .endpointTestSuiteModel(getEndpointTestSuite(endpointTestsModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel queryServiceModelsEndpointAuthParamsWithoutAllowList() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/query/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/query/customization-endpoint-auth-params-without-allowed" + ".config") .getFile()); File waitersModel = new File(ClientTestModels.class.getResource("client/c2j/query/waiters-2.json").getFile()); File endpointRuleSetModel = new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-rule-set.json").getFile()); File endpointTestsModel = new File(ClientTestModels.class.getResource("client/c2j/query/endpoint-tests.json").getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .waitersModel(getWaiters(waitersModel)) .endpointRuleSetModel(getEndpointRuleSet(endpointRuleSetModel)) .endpointTestSuiteModel(getEndpointTestSuite(endpointTestsModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel granularAuthProvidersServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/fine-grained-auth/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/fine-grained-auth/customization.config") .getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel granularAuthWithLegacyTraitServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/fine-grained-auth-legacy-trait/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/fine-grained-auth-legacy-trait/customization.config") .getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel allOperationsWithAuthSameValueServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/all-ops-with-auth-same-value/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/all-ops-with-auth-same-value/customization.config") .getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel allOperationsWithAuthDifferentValueServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/all-ops-with-auth-different-value/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/all-ops-with-auth-different-value/customization.config") .getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel operationWithNoAuth() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/ops-with-no-auth/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/ops-with-no-auth/customization.config") .getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel serviceWithNoAuth() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/service-with-no-auth/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/service-with-no-auth/customization.config") .getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel serviceMiniS3() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/mini-s3/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/mini-s3/customization.config") .getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel xmlServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/xml/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/xml/customization.config").getFile()); C2jModels models = C2jModels .builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel endpointDiscoveryModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/endpointdiscovery/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/endpointdiscovery/customization.config").getFile()); C2jModels models = C2jModels.builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel customContentTypeModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/customservicemetadata/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/customservicemetadata/customization.config").getFile()); C2jModels models = C2jModels.builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel composedClientJsonServiceModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/rest-json/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/composedclient/customization.config").getFile()); CustomizationConfig customizationConfig = getCustomizationConfig(customizationModel); C2jModels models = C2jModels.builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(customizationConfig) .build(); return new IntermediateModelBuilder(models).build(); } public static IntermediateModel internalConfigModels() { File serviceModel = new File(ClientTestModels.class.getResource("client/c2j/internalconfig/service-2.json").getFile()); File customizationModel = new File(ClientTestModels.class.getResource("client/c2j/internalconfig/customization.config").getFile()); C2jModels models = C2jModels.builder() .serviceModel(getServiceModel(serviceModel)) .customizationConfig(getCustomizationConfig(customizationModel)) .build(); return new IntermediateModelBuilder(models).build(); } private static ServiceModel getServiceModel(File file) { return ModelLoaderUtils.loadModel(ServiceModel.class, file); } private static CustomizationConfig getCustomizationConfig(File file) { return ModelLoaderUtils.loadModel(CustomizationConfig.class, file); } private static Waiters getWaiters(File file) { return ModelLoaderUtils.loadModel(Waiters.class, file); } private static EndpointRuleSetModel getEndpointRuleSet(File file) { return ModelLoaderUtils.loadModel(EndpointRuleSetModel.class, file); } private static EndpointTestSuiteModel getEndpointTestSuite(File file) { return ModelLoaderUtils.loadModel(EndpointTestSuiteModel.class, file); } private static Paginators getPaginatorsModel(File file) { return ModelLoaderUtils.loadModel(Paginators.class, file); } }
3,295
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/eventstream/EventStreamFunctionalTests.java
/* * 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.codegen.poet.eventstream; import static org.hamcrest.MatcherAssert.assertThat; import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo; import java.util.function.BiFunction; import org.junit.jupiter.api.Test; import software.amazon.awssdk.codegen.emitters.GeneratorTaskParams; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.intermediate.OperationModel; import software.amazon.awssdk.codegen.poet.ClassSpec; import software.amazon.awssdk.codegen.poet.ClientTestModels; public class EventStreamFunctionalTests { @Test public void visitorBuilder() throws Exception { runTest(EventStreamVisitorBuilderImplSpec::new, "test-visitor-builder.java"); } @Test public void responseHandler() throws Exception { runTest(EventStreamResponseHandlerSpec::new, "test-response-handler.java"); } @Test public void responseHandlerBuilder() throws Exception { runTest(EventStreamResponseHandlerBuilderImplSpec::new, "test-response-handler-builder.java"); } private void runTest(BiFunction<GeneratorTaskParams, OperationModel, ClassSpec> specFactory, String expectedTestFile) { IntermediateModel model = ClientTestModels.restJsonServiceModels(); GeneratorTaskParams dependencies = GeneratorTaskParams.create(model, "sources/", "tests/", "resources/"); ClassSpec classSpec = specFactory.apply(dependencies, model.getOperation("EventStreamOperation")); assertThat(classSpec, generatesTo(expectedTestFile)); } }
3,296
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/eventstream/EventModelSpecTest.java
package software.amazon.awssdk.codegen.poet.eventstream; import static java.util.stream.Collectors.toList; import static org.hamcrest.MatcherAssert.assertThat; import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo; import static software.amazon.awssdk.utils.FunctionalUtils.invokeSafely; import java.io.File; import java.io.IOException; import java.util.Collection; import java.util.Locale; import java.util.Objects; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.runners.Parameterized; import software.amazon.awssdk.codegen.C2jModels; import software.amazon.awssdk.codegen.IntermediateModelBuilder; import software.amazon.awssdk.codegen.customization.processors.UseLegacyEventGenerationSchemeProcessorTest; import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.intermediate.MemberModel; import software.amazon.awssdk.codegen.model.intermediate.OperationModel; import software.amazon.awssdk.codegen.model.intermediate.ShapeModel; import software.amazon.awssdk.codegen.model.service.ServiceModel; import software.amazon.awssdk.codegen.poet.model.AwsModelSpecTest; import software.amazon.awssdk.codegen.poet.model.EventModelSpec; import software.amazon.awssdk.codegen.utils.ModelLoaderUtils; @RunWith(Parameterized.class) public class EventModelSpecTest { private static IntermediateModel intermediateModel; private final MemberModel event; private final ShapeModel eventStream; @Parameterized.Parameters(name = "{0}") public static Collection<Object[]> data() { invokeSafely(EventModelSpecTest::setUp); return intermediateModel.getShapes().values().stream() .filter(ShapeModel::isEventStream) .flatMap(eventStream -> eventStream.getMembers().stream() .filter(m -> m.getShape().isEvent()) .map(e -> new Object[]{e, eventStream})) .collect(toList()); } public EventModelSpecTest(MemberModel event, ShapeModel eventStream) { this.event = event; this.eventStream = eventStream; } @Test public void basicGeneration() { assertThat(new EventModelSpec(event, eventStream, intermediateModel), generatesTo(referenceFileForShape())); } private String referenceFileForShape() { String className = "Default" + intermediateModel.getNamingStrategy().getShapeClassName(event.getName()); String fileName = className.toLowerCase(Locale.ENGLISH) + ".java"; return "/software/amazon/awssdk/codegen/poet/eventstream/" + fileName; } private static void setUp() { File serviceModelFile = new File(EventModelSpecTest.class.getResource("service-2.json").getFile()); ServiceModel serviceModel = ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile); intermediateModel = new IntermediateModelBuilder( C2jModels.builder() .serviceModel(serviceModel) .customizationConfig(loadCustomizationConfig("customization.config")) .build()) .build(); } private static CustomizationConfig loadCustomizationConfig(String configName) { String c2jFilePath = EventModelSpecTest.class.getResource(configName).getFile(); File file = new File(c2jFilePath); return ModelLoaderUtils.loadModel(CustomizationConfig.class, file); } }
3,297
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/paginators/PaginatedResponseClassSpecTest.java
/* * 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.codegen.poet.paginators; import static org.hamcrest.MatcherAssert.assertThat; import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo; import java.io.File; import java.io.IOException; import java.util.Map; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import software.amazon.awssdk.codegen.C2jModels; import software.amazon.awssdk.codegen.IntermediateModelBuilder; import software.amazon.awssdk.codegen.model.config.customization.CustomizationConfig; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.model.service.PaginatorDefinition; import software.amazon.awssdk.codegen.model.service.Paginators; import software.amazon.awssdk.codegen.model.service.ServiceModel; import software.amazon.awssdk.codegen.poet.ClassSpec; import software.amazon.awssdk.codegen.poet.paginators.customizations.SameTokenAsyncResponseClassSpec; import software.amazon.awssdk.codegen.poet.paginators.customizations.SameTokenSyncResponseClassSpec; import software.amazon.awssdk.codegen.utils.ModelLoaderUtils; public class PaginatedResponseClassSpecTest { private static final String SAME_TOKEN_CUSTOMIZATION = "LastPageHasPreviousToken"; private static IntermediateModel intermediateModel; private static Paginators paginators; private static Map<String, String> paginationCustomization; @BeforeAll public static void setUp() throws IOException { File serviceModelFile = new File(PaginatedResponseClassSpecTest.class.getResource("service-2.json").getFile()); File customizationConfigFile = new File(PaginatedResponseClassSpecTest.class.getResource("customization.config") .getFile()); File paginatorsModel = new File(PaginatedResponseClassSpecTest.class.getResource("paginators.json") .getFile()); paginators = getPaginatorsModel(paginatorsModel); intermediateModel = new IntermediateModelBuilder( C2jModels.builder() .serviceModel(ModelLoaderUtils.loadModel(ServiceModel.class, serviceModelFile)) .customizationConfig(ModelLoaderUtils.loadModel(CustomizationConfig.class, customizationConfigFile)) .paginatorsModel(paginators) .build()) .build(); paginationCustomization = intermediateModel.getCustomizationConfig().getPaginationCustomization(); } private static Paginators getPaginatorsModel(File file) { return ModelLoaderUtils.loadModel(Paginators.class, file); } @Test public void testGeneratedResponseForSyncOperations() { paginators.getPagination().entrySet() .stream() .filter(entry -> entry.getValue().isValid()) .forEach(entry -> { ClassSpec classSpec = getSyncResponseSpec(entry); assertThat(classSpec, generatesTo(classSpec.className().simpleName() + ".java")); }); } @Test public void testGeneratedResponseForAsyncOperations() { paginators.getPagination().entrySet() .stream() .filter(entry -> entry.getValue().isValid()) .forEach(entry -> { ClassSpec classSpec = getAsyncResponseSpec(entry); assertThat(classSpec, generatesTo(classSpec.className().simpleName() + ".java")); }); } private ClassSpec getSyncResponseSpec(Map.Entry<String, PaginatorDefinition> entry) { ClassSpec classSpec = new SyncResponseClassSpec(intermediateModel, entry.getKey(), entry.getValue()); if (paginationCustomization != null && paginationCustomization.containsKey(entry.getKey())) { String customvalue = paginationCustomization.get(entry.getKey()); switch (customvalue) { case SAME_TOKEN_CUSTOMIZATION: classSpec = new SameTokenSyncResponseClassSpec(intermediateModel, entry.getKey(), entry.getValue()); break; default: throw new IllegalArgumentException("Unknown paginationCustomization value: " + customvalue); } } return classSpec; } private ClassSpec getAsyncResponseSpec(Map.Entry<String, PaginatorDefinition> entry) { ClassSpec classSpec = new AsyncResponseClassSpec(intermediateModel, entry.getKey(), entry.getValue()); if (paginationCustomization != null && paginationCustomization.containsKey(entry.getKey())) { String customvalue = paginationCustomization.get(entry.getKey()); switch (customvalue) { case SAME_TOKEN_CUSTOMIZATION: classSpec = new SameTokenAsyncResponseClassSpec(intermediateModel, entry.getKey(), entry.getValue()); break; default: throw new IllegalArgumentException("Unknown paginationCustomization value: " + customvalue); } } return classSpec; } }
3,298
0
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/auth
Create_ds/aws-sdk-java-v2/codegen/src/test/java/software/amazon/awssdk/codegen/poet/auth/scheme/AuthSchemeSpecTest.java
/* * 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.codegen.poet.auth.scheme; import static org.hamcrest.MatcherAssert.assertThat; import static software.amazon.awssdk.codegen.poet.PoetMatchers.generatesTo; import java.util.Arrays; import java.util.List; import java.util.function.Function; import java.util.function.Supplier; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.MethodSource; import software.amazon.awssdk.codegen.model.intermediate.IntermediateModel; import software.amazon.awssdk.codegen.poet.ClassSpec; import software.amazon.awssdk.codegen.poet.ClientTestModels; public class AuthSchemeSpecTest { @ParameterizedTest @MethodSource("parameters") void testCase(TestCase testCase) { ClassSpec classSpec = testCase.classSpecProvider.apply(testCase.modelProvider.get()); String expectedFileName = testCase.caseName + "-auth-scheme-" + testCase.outputFileSuffix + ".java"; assertThat("Generated class must match " + expectedFileName, classSpec, generatesTo(expectedFileName)); } static List<TestCase> parameters() { return Arrays.asList( // query TestCase.builder() .modelProvider(ClientTestModels::queryServiceModels) .classSpecProvider(AuthSchemeProviderSpec::new) .caseName("query") .outputFileSuffix("provider") .build(), TestCase.builder() .modelProvider(ClientTestModels::queryServiceModels) .classSpecProvider(AuthSchemeParamsSpec::new) .caseName("query") .outputFileSuffix("params") .build(), TestCase.builder() .modelProvider(ClientTestModels::queryServiceModels) .classSpecProvider(ModelBasedAuthSchemeProviderSpec::new) .caseName("query") .outputFileSuffix("default-provider") .build(), TestCase.builder() .modelProvider(ClientTestModels::queryServiceModels) .classSpecProvider(DefaultAuthSchemeParamsSpec::new) .caseName("query") .outputFileSuffix("default-params") .build(), // query-endpoint-auth-params TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList) .classSpecProvider(AuthSchemeProviderSpec::new) .caseName("query-endpoint-auth-params") .outputFileSuffix("provider") .build(), // Endpoint based AuthScheme provider WITH allow list // - Endpoint Provider TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList) .classSpecProvider(EndpointBasedAuthSchemeProviderSpec::new) .caseName("query-endpoint-auth-params") .outputFileSuffix("endpoint-provider") .build(), // - Modeled provider TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList) .classSpecProvider(ModelBasedAuthSchemeProviderSpec::new) .caseName("query-endpoint-auth-params") .outputFileSuffix("modeled-provider") .build(), // Endpoint based AuthScheme provider WITHOUT allow list // - Endpoint Provider TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithoutAllowList) .classSpecProvider(EndpointBasedAuthSchemeProviderSpec::new) .caseName("query-endpoint-auth-params") .outputFileSuffix("endpoint-provider-without-allowlist") .build(), // Auth scheme params from endpoint WITH allow list, MUST include ONLY the params in the allow list. // - Interface TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList) .classSpecProvider(AuthSchemeParamsSpec::new) .caseName("query-endpoint-auth-params") .outputFileSuffix("params-with-allowlist") .build(), // - Implementation TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList) .classSpecProvider(DefaultAuthSchemeParamsSpec::new) .caseName("query-endpoint-auth-params") .outputFileSuffix("default-params-with-allowlist") .build(), // Auth scheme params from endpoint WITHOUT allow list, it MUST include all the endpoint params except for the // default params. // - Interface TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithoutAllowList) .classSpecProvider(AuthSchemeParamsSpec::new) .caseName("query-endpoint-auth-params") .outputFileSuffix("params-without-allowlist") .build(), // - Implementation TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithoutAllowList) .classSpecProvider(DefaultAuthSchemeParamsSpec::new) .caseName("query-endpoint-auth-params") .outputFileSuffix("default-params-without-allowlist") .build(), // Granular auth TestCase.builder() .modelProvider(ClientTestModels::granularAuthProvidersServiceModels) .classSpecProvider(ModelBasedAuthSchemeProviderSpec::new) .caseName("granular") .outputFileSuffix("default-provider") .build(), // All operations with auth with the same values TestCase.builder() .modelProvider(ClientTestModels::allOperationsWithAuthSameValueServiceModels) .classSpecProvider(ModelBasedAuthSchemeProviderSpec::new) .caseName("all-ops-auth-same-value") .outputFileSuffix("default-provider") .build(), // All operations with auth with different values TestCase.builder() .modelProvider(ClientTestModels::allOperationsWithAuthDifferentValueServiceModels) .classSpecProvider(ModelBasedAuthSchemeProviderSpec::new) .caseName("all-ops-auth-different-value") .outputFileSuffix("default-provider") .build(), // Service with operations with auth none TestCase.builder() .modelProvider(ClientTestModels::operationWithNoAuth) .classSpecProvider(ModelBasedAuthSchemeProviderSpec::new) .caseName("ops-with-no-auth") .outputFileSuffix("default-provider") .build(), // Service with signature version with the same value as S3 TestCase.builder() .modelProvider(ClientTestModels::serviceMiniS3) .classSpecProvider(ModelBasedAuthSchemeProviderSpec::new) .caseName("mini-s3") .outputFileSuffix("default-provider") .build(), TestCase.builder() .modelProvider(ClientTestModels::granularAuthWithLegacyTraitServiceModels) .classSpecProvider(ModelBasedAuthSchemeProviderSpec::new) .caseName("auth-with-legacy-trait") .outputFileSuffix("default-provider") .build(), // Interceptors // - Normal case TestCase.builder() .modelProvider(ClientTestModels::queryServiceModels) .classSpecProvider(AuthSchemeInterceptorSpec::new) .caseName("query") .outputFileSuffix("interceptor") .build(), // - Endpoints based params with allow list TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithAllowList) .classSpecProvider(AuthSchemeInterceptorSpec::new) .caseName("query-endpoint-auth-params-with-allowlist") .outputFileSuffix("interceptor") .build(), // - Endpoints based params without allow list TestCase.builder() .modelProvider(ClientTestModels::queryServiceModelsEndpointAuthParamsWithoutAllowList) .classSpecProvider(AuthSchemeInterceptorSpec::new) .caseName("query-endpoint-auth-params-without-allowlist") .outputFileSuffix("interceptor") .build() ); } static class TestCase { private final Supplier<IntermediateModel> modelProvider; private final Function<IntermediateModel, ClassSpec> classSpecProvider; private final String outputFileSuffix; private final String caseName; TestCase(Builder builder) { this.modelProvider = builder.modelProvider; this.classSpecProvider = builder.classSpecProvider; this.outputFileSuffix = builder.outputFileSuffix; this.caseName = builder.caseName; } static Builder builder() { return new Builder(); } static class Builder { private Supplier<IntermediateModel> modelProvider; private Function<IntermediateModel, ClassSpec> classSpecProvider; private String outputFileSuffix; private String caseName; Builder modelProvider(Supplier<IntermediateModel> modelProvider) { this.modelProvider = modelProvider; return this; } Builder classSpecProvider(Function<IntermediateModel, ClassSpec> classSpecProvider) { this.classSpecProvider = classSpecProvider; return this; } Builder outputFileSuffix(String outputFileSuffix) { this.outputFileSuffix = outputFileSuffix; return this; } Builder caseName(String caseName) { this.caseName = caseName; return this; } TestCase build() { return new TestCase(this); } } } }
3,299