tags;
private final String logGroupClass;
private CreateLogGroupRequest(BuilderImpl builder) {
super(builder);
this.logGroupName = builder.logGroupName;
this.kmsKeyId = builder.kmsKeyId;
this.tags = builder.tags;
this.logGroupClass = builder.logGroupClass;
}
/**
*
* A name for the log group.
*
*
* @return A name for the log group.
*/
public final String logGroupName() {
return logGroupName;
}
/**
*
* The Amazon Resource Name (ARN) of the KMS key to use when encrypting log data. For more information, see Amazon Resource
* Names .
*
*
* @return The Amazon Resource Name (ARN) of the KMS key to use when encrypting log data. For more information, see
* Amazon
* Resource Names .
*/
public final String kmsKeyId() {
return kmsKeyId;
}
/**
* For responses, this returns true if the service returned a value for the Tags 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 hasTags() {
return tags != null && !(tags instanceof SdkAutoConstructMap);
}
/**
*
* The key-value pairs to use for the tags.
*
*
* You can grant users access to certain log groups while preventing them from accessing other log groups. To do so,
* tag your groups and use IAM policies that refer to those tags. To assign tags when you create a log group, you
* must have either the logs:TagResource
or logs:TagLogGroup
permission. For more
* information about tagging, see Tagging
* Amazon Web Services resources . For more information about using tags to control access, see Controlling access to Amazon Web
* Services resources using tags .
*
*
* 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 #hasTags} method.
*
*
* @return The key-value pairs to use for the tags.
*
* You can grant users access to certain log groups while preventing them from accessing other log groups.
* To do so, tag your groups and use IAM policies that refer to those tags. To assign tags when you create a
* log group, you must have either the logs:TagResource
or logs:TagLogGroup
* permission. For more information about tagging, see Tagging Amazon Web Services
* resources . For more information about using tags to control access, see Controlling access to Amazon Web
* Services resources using tags .
*/
public final Map tags() {
return tags;
}
/**
*
* Use this parameter to specify the log group class for this log group. There are two classes:
*
*
*
* If you omit this parameter, the default of STANDARD
is used.
*
*
*
* After a log group is created, its class can't be changed.
*
*
*
* For details about the features supported by each class, see Log classes
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #logGroupClass}
* will return {@link LogGroupClass#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #logGroupClassAsString}.
*
*
* @return Use this parameter to specify the log group class for this log group. There are two classes:
*
*
* If you omit this parameter, the default of STANDARD
is used.
*
*
*
* After a log group is created, its class can't be changed.
*
*
*
* For details about the features supported by each class, see Log
* classes
* @see LogGroupClass
*/
public final LogGroupClass logGroupClass() {
return LogGroupClass.fromValue(logGroupClass);
}
/**
*
* Use this parameter to specify the log group class for this log group. There are two classes:
*
*
*
* If you omit this parameter, the default of STANDARD
is used.
*
*
*
* After a log group is created, its class can't be changed.
*
*
*
* For details about the features supported by each class, see Log classes
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #logGroupClass}
* will return {@link LogGroupClass#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #logGroupClassAsString}.
*
*
* @return Use this parameter to specify the log group class for this log group. There are two classes:
*
*
* If you omit this parameter, the default of STANDARD
is used.
*
*
*
* After a log group is created, its class can't be changed.
*
*
*
* For details about the features supported by each class, see Log
* classes
* @see LogGroupClass
*/
public final String logGroupClassAsString() {
return logGroupClass;
}
@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(logGroupName());
hashCode = 31 * hashCode + Objects.hashCode(kmsKeyId());
hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null);
hashCode = 31 * hashCode + Objects.hashCode(logGroupClassAsString());
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 CreateLogGroupRequest)) {
return false;
}
CreateLogGroupRequest other = (CreateLogGroupRequest) obj;
return Objects.equals(logGroupName(), other.logGroupName()) && Objects.equals(kmsKeyId(), other.kmsKeyId())
&& hasTags() == other.hasTags() && Objects.equals(tags(), other.tags())
&& Objects.equals(logGroupClassAsString(), other.logGroupClassAsString());
}
/**
* 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("CreateLogGroupRequest").add("LogGroupName", logGroupName()).add("KmsKeyId", kmsKeyId())
.add("Tags", hasTags() ? tags() : null).add("LogGroupClass", logGroupClassAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "logGroupName":
return Optional.ofNullable(clazz.cast(logGroupName()));
case "kmsKeyId":
return Optional.ofNullable(clazz.cast(kmsKeyId()));
case "tags":
return Optional.ofNullable(clazz.cast(tags()));
case "logGroupClass":
return Optional.ofNullable(clazz.cast(logGroupClassAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function getter(Function g) {
return obj -> g.apply((CreateLogGroupRequest) obj);
}
private static BiConsumer setter(BiConsumer s) {
return (obj, val) -> s.accept((Builder) obj, val);
}
public interface Builder extends CloudWatchLogsRequest.Builder, SdkPojo, CopyableBuilder {
/**
*
* A name for the log group.
*
*
* @param logGroupName
* A name for the log group.
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder logGroupName(String logGroupName);
/**
*
* The Amazon Resource Name (ARN) of the KMS key to use when encrypting log data. For more information, see Amazon
* Resource Names .
*
*
* @param kmsKeyId
* The Amazon Resource Name (ARN) of the KMS key to use when encrypting log data. For more information,
* see Amazon Resource Names .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder kmsKeyId(String kmsKeyId);
/**
*
* The key-value pairs to use for the tags.
*
*
* You can grant users access to certain log groups while preventing them from accessing other log groups. To do
* so, tag your groups and use IAM policies that refer to those tags. To assign tags when you create a log
* group, you must have either the logs:TagResource
or logs:TagLogGroup
permission.
* For more information about tagging, see Tagging Amazon Web Services
* resources . For more information about using tags to control access, see Controlling access to Amazon Web
* Services resources using tags .
*
*
* @param tags
* The key-value pairs to use for the tags.
*
* You can grant users access to certain log groups while preventing them from accessing other log
* groups. To do so, tag your groups and use IAM policies that refer to those tags. To assign tags when
* you create a log group, you must have either the logs:TagResource
or
* logs:TagLogGroup
permission. For more information about tagging, see Tagging Amazon Web Services
* resources . For more information about using tags to control access, see Controlling access to Amazon
* Web Services resources using tags .
* @return Returns a reference to this object so that method calls can be chained together.
*/
Builder tags(Map tags);
/**
*
* Use this parameter to specify the log group class for this log group. There are two classes:
*
*
*
* If you omit this parameter, the default of STANDARD
is used.
*
*
*
* After a log group is created, its class can't be changed.
*
*
*
* For details about the features supported by each class, see Log
* classes
*
*
* @param logGroupClass
* Use this parameter to specify the log group class for this log group. There are two classes:
*
*
* If you omit this parameter, the default of STANDARD
is used.
*
*
*
* After a log group is created, its class can't be changed.
*
*
*
* For details about the features supported by each class, see Log
* classes
* @see LogGroupClass
* @return Returns a reference to this object so that method calls can be chained together.
* @see LogGroupClass
*/
Builder logGroupClass(String logGroupClass);
/**
*
* Use this parameter to specify the log group class for this log group. There are two classes:
*
*
*
* If you omit this parameter, the default of STANDARD
is used.
*
*
*
* After a log group is created, its class can't be changed.
*
*
*
* For details about the features supported by each class, see Log
* classes
*
*
* @param logGroupClass
* Use this parameter to specify the log group class for this log group. There are two classes:
*
*
* If you omit this parameter, the default of STANDARD
is used.
*
*
*
* After a log group is created, its class can't be changed.
*
*
*
* For details about the features supported by each class, see Log
* classes
* @see LogGroupClass
* @return Returns a reference to this object so that method calls can be chained together.
* @see LogGroupClass
*/
Builder logGroupClass(LogGroupClass logGroupClass);
@Override
Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration);
@Override
Builder overrideConfiguration(Consumer builderConsumer);
}
static final class BuilderImpl extends CloudWatchLogsRequest.BuilderImpl implements Builder {
private String logGroupName;
private String kmsKeyId;
private Map tags = DefaultSdkAutoConstructMap.getInstance();
private String logGroupClass;
private BuilderImpl() {
}
private BuilderImpl(CreateLogGroupRequest model) {
super(model);
logGroupName(model.logGroupName);
kmsKeyId(model.kmsKeyId);
tags(model.tags);
logGroupClass(model.logGroupClass);
}
public final String getLogGroupName() {
return logGroupName;
}
public final void setLogGroupName(String logGroupName) {
this.logGroupName = logGroupName;
}
@Override
public final Builder logGroupName(String logGroupName) {
this.logGroupName = logGroupName;
return this;
}
public final String getKmsKeyId() {
return kmsKeyId;
}
public final void setKmsKeyId(String kmsKeyId) {
this.kmsKeyId = kmsKeyId;
}
@Override
public final Builder kmsKeyId(String kmsKeyId) {
this.kmsKeyId = kmsKeyId;
return this;
}
public final Map getTags() {
if (tags instanceof SdkAutoConstructMap) {
return null;
}
return tags;
}
public final void setTags(Map tags) {
this.tags = TagsCopier.copy(tags);
}
@Override
public final Builder tags(Map tags) {
this.tags = TagsCopier.copy(tags);
return this;
}
public final String getLogGroupClass() {
return logGroupClass;
}
public final void setLogGroupClass(String logGroupClass) {
this.logGroupClass = logGroupClass;
}
@Override
public final Builder logGroupClass(String logGroupClass) {
this.logGroupClass = logGroupClass;
return this;
}
@Override
public final Builder logGroupClass(LogGroupClass logGroupClass) {
this.logGroupClass(logGroupClass == null ? null : logGroupClass.toString());
return this;
}
@Override
public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) {
super.overrideConfiguration(overrideConfiguration);
return this;
}
@Override
public Builder overrideConfiguration(Consumer builderConsumer) {
super.overrideConfiguration(builderConsumer);
return this;
}
@Override
public CreateLogGroupRequest build() {
return new CreateLogGroupRequest(this);
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
}
}