software.amazon.awssdk.services.chime.model.SipRule Maven / Gradle / Ivy
/*
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
* the License. A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
* and limitations under the License.
*/
package software.amazon.awssdk.services.chime.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.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.TimestampFormatTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* The SIP rule details, including name, triggers, and target applications. An AWS account can have multiple SIP rules.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SipRule implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField SIP_RULE_ID_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("SipRuleId").getter(getter(SipRule::sipRuleId)).setter(setter(Builder::sipRuleId))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("SipRuleId").build()).build();
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("Name")
.getter(getter(SipRule::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Name").build()).build();
private static final SdkField DISABLED_FIELD = SdkField. builder(MarshallingType.BOOLEAN)
.memberName("Disabled").getter(getter(SipRule::disabled)).setter(setter(Builder::disabled))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Disabled").build()).build();
private static final SdkField TRIGGER_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TriggerType").getter(getter(SipRule::triggerTypeAsString)).setter(setter(Builder::triggerType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TriggerType").build()).build();
private static final SdkField TRIGGER_VALUE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("TriggerValue").getter(getter(SipRule::triggerValue)).setter(setter(Builder::triggerValue))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TriggerValue").build()).build();
private static final SdkField> TARGET_APPLICATIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("TargetApplications")
.getter(getter(SipRule::targetApplications))
.setter(setter(Builder::targetApplications))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TargetApplications").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(SipRuleTargetApplication::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField CREATED_TIMESTAMP_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("CreatedTimestamp")
.getter(getter(SipRule::createdTimestamp))
.setter(setter(Builder::createdTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("CreatedTimestamp").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final SdkField UPDATED_TIMESTAMP_FIELD = SdkField
. builder(MarshallingType.INSTANT)
.memberName("UpdatedTimestamp")
.getter(getter(SipRule::updatedTimestamp))
.setter(setter(Builder::updatedTimestamp))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("UpdatedTimestamp").build(),
TimestampFormatTrait.create(TimestampFormatTrait.Format.ISO_8601)).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SIP_RULE_ID_FIELD, NAME_FIELD,
DISABLED_FIELD, TRIGGER_TYPE_FIELD, TRIGGER_VALUE_FIELD, TARGET_APPLICATIONS_FIELD, CREATED_TIMESTAMP_FIELD,
UPDATED_TIMESTAMP_FIELD));
private static final long serialVersionUID = 1L;
private final String sipRuleId;
private final String name;
private final Boolean disabled;
private final String triggerType;
private final String triggerValue;
private final List targetApplications;
private final Instant createdTimestamp;
private final Instant updatedTimestamp;
private SipRule(BuilderImpl builder) {
this.sipRuleId = builder.sipRuleId;
this.name = builder.name;
this.disabled = builder.disabled;
this.triggerType = builder.triggerType;
this.triggerValue = builder.triggerValue;
this.targetApplications = builder.targetApplications;
this.createdTimestamp = builder.createdTimestamp;
this.updatedTimestamp = builder.updatedTimestamp;
}
/**
*
* The SIP rule ID.
*
*
* @return The SIP rule ID.
*/
public final String sipRuleId() {
return sipRuleId;
}
/**
*
* The name of the SIP rule.
*
*
* @return The name of the SIP rule.
*/
public final String name() {
return name;
}
/**
*
* Indicates whether the SIP rule is enabled or disabled. You must disable a rule before you can delete it.
*
*
* @return Indicates whether the SIP rule is enabled or disabled. You must disable a rule before you can delete it.
*/
public final Boolean disabled() {
return disabled;
}
/**
*
* The type of trigger assigned to the SIP rule in TriggerValue, currently
* RequestUriHostname or ToPhoneNumber.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #triggerType} will
* return {@link SipRuleTriggerType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #triggerTypeAsString}.
*
*
* @return The type of trigger assigned to the SIP rule in TriggerValue, currently
* RequestUriHostname or ToPhoneNumber.
* @see SipRuleTriggerType
*/
public final SipRuleTriggerType triggerType() {
return SipRuleTriggerType.fromValue(triggerType);
}
/**
*
* The type of trigger assigned to the SIP rule in TriggerValue, currently
* RequestUriHostname or ToPhoneNumber.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #triggerType} will
* return {@link SipRuleTriggerType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #triggerTypeAsString}.
*
*
* @return The type of trigger assigned to the SIP rule in TriggerValue, currently
* RequestUriHostname or ToPhoneNumber.
* @see SipRuleTriggerType
*/
public final String triggerTypeAsString() {
return triggerType;
}
/**
*
* If TriggerType is RequestUriHostname, then the value can be the outbound host name of
* the Amazon Chime Voice Connector. If TriggerType is ToPhoneNumber, then the value can
* be a customer-owned phone number in E164 format. SipRule is triggered when a SIP rule requests host
* name or ToPhoneNumber matches in the incoming SIP request.
*
*
* @return If TriggerType is RequestUriHostname, then the value can be the outbound host
* name of the Amazon Chime Voice Connector. If TriggerType is ToPhoneNumber, then
* the value can be a customer-owned phone number in E164 format. SipRule is triggered when a
* SIP rule requests host name or ToPhoneNumber matches in the incoming SIP request.
*/
public final String triggerValue() {
return triggerValue;
}
/**
* For responses, this returns true if the service returned a value for the TargetApplications property. This DOES
* NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the property).
* This is useful because the SDK will never return a null collection or map, but you may need to differentiate
* between the service returning nothing (or null) and the service returning an empty collection or map. For
* requests, this returns true if a value for the property was specified in the request builder, and false if a
* value was not specified.
*/
public final boolean hasTargetApplications() {
return targetApplications != null && !(targetApplications instanceof SdkAutoConstructList);
}
/**
*
* Target SIP media application and other details, such as priority and AWS Region, to be specified in the SIP rule.
* Only one SIP rule per AWS Region can be provided.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* This method will never return null. If you would like to know whether the service returned this field (so that
* you can differentiate between null and empty), you can use the {@link #hasTargetApplications} method.
*
*
* @return Target SIP media application and other details, such as priority and AWS Region, to be specified in the
* SIP rule. Only one SIP rule per AWS Region can be provided.
*/
public final List targetApplications() {
return targetApplications;
}
/**
*
* The time at which the SIP rule was created, in ISO 8601 format.
*
*
* @return The time at which the SIP rule was created, in ISO 8601 format.
*/
public final Instant createdTimestamp() {
return createdTimestamp;
}
/**
*
* The time at which the SIP rule was last updated, in ISO 8601 format.
*
*
* @return The time at which the SIP rule was last updated, in ISO 8601 format.
*/
public final Instant updatedTimestamp() {
return updatedTimestamp;
}
@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(sipRuleId());
hashCode = 31 * hashCode + Objects.hashCode(name());
hashCode = 31 * hashCode + Objects.hashCode(disabled());
hashCode = 31 * hashCode + Objects.hashCode(triggerTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(triggerValue());
hashCode = 31 * hashCode + Objects.hashCode(hasTargetApplications() ? targetApplications() : null);
hashCode = 31 * hashCode + Objects.hashCode(createdTimestamp());
hashCode = 31 * hashCode + Objects.hashCode(updatedTimestamp());
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 SipRule)) {
return false;
}
SipRule other = (SipRule) obj;
return Objects.equals(sipRuleId(), other.sipRuleId()) && Objects.equals(name(), other.name())
&& Objects.equals(disabled(), other.disabled())
&& Objects.equals(triggerTypeAsString(), other.triggerTypeAsString())
&& Objects.equals(triggerValue(), other.triggerValue())
&& hasTargetApplications() == other.hasTargetApplications()
&& Objects.equals(targetApplications(), other.targetApplications())
&& Objects.equals(createdTimestamp(), other.createdTimestamp())
&& Objects.equals(updatedTimestamp(), other.updatedTimestamp());
}
/**
* 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("SipRule").add("SipRuleId", sipRuleId()).add("Name", name()).add("Disabled", disabled())
.add("TriggerType", triggerTypeAsString()).add("TriggerValue", triggerValue())
.add("TargetApplications", hasTargetApplications() ? targetApplications() : null)
.add("CreatedTimestamp", createdTimestamp()).add("UpdatedTimestamp", updatedTimestamp()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "SipRuleId":
return Optional.ofNullable(clazz.cast(sipRuleId()));
case "Name":
return Optional.ofNullable(clazz.cast(name()));
case "Disabled":
return Optional.ofNullable(clazz.cast(disabled()));
case "TriggerType":
return Optional.ofNullable(clazz.cast(triggerTypeAsString()));
case "TriggerValue":
return Optional.ofNullable(clazz.cast(triggerValue()));
case "TargetApplications":
return Optional.ofNullable(clazz.cast(targetApplications()));
case "CreatedTimestamp":
return Optional.ofNullable(clazz.cast(createdTimestamp()));
case "UpdatedTimestamp":
return Optional.ofNullable(clazz.cast(updatedTimestamp()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function