software.amazon.awssdk.services.codebuild.model.SourceCredentialsInfo Maven / Gradle / Ivy
Show all versions of codebuild Show documentation
/*
* 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.codebuild.model;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* Information about the credentials for a GitHub, GitHub Enterprise, GitLab, GitLab Self Managed, or Bitbucket
* repository.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class SourceCredentialsInfo implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("arn")
.getter(getter(SourceCredentialsInfo::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("arn").build()).build();
private static final SdkField SERVER_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("serverType").getter(getter(SourceCredentialsInfo::serverTypeAsString))
.setter(setter(Builder::serverType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("serverType").build()).build();
private static final SdkField AUTH_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("authType").getter(getter(SourceCredentialsInfo::authTypeAsString)).setter(setter(Builder::authType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("authType").build()).build();
private static final SdkField RESOURCE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("resource").getter(getter(SourceCredentialsInfo::resource)).setter(setter(Builder::resource))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("resource").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(ARN_FIELD, SERVER_TYPE_FIELD,
AUTH_TYPE_FIELD, RESOURCE_FIELD));
private static final Map> SDK_NAME_TO_FIELD = memberNameToFieldInitializer();
private static final long serialVersionUID = 1L;
private final String arn;
private final String serverType;
private final String authType;
private final String resource;
private SourceCredentialsInfo(BuilderImpl builder) {
this.arn = builder.arn;
this.serverType = builder.serverType;
this.authType = builder.authType;
this.resource = builder.resource;
}
/**
*
* The Amazon Resource Name (ARN) of the token.
*
*
* @return The Amazon Resource Name (ARN) of the token.
*/
public final String arn() {
return arn;
}
/**
*
* The type of source provider. The valid options are GITHUB, GITHUB_ENTERPRISE, GITLAB, GITLAB_SELF_MANAGED, or
* BITBUCKET.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #serverType} will
* return {@link ServerType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #serverTypeAsString}.
*
*
* @return The type of source provider. The valid options are GITHUB, GITHUB_ENTERPRISE, GITLAB,
* GITLAB_SELF_MANAGED, or BITBUCKET.
* @see ServerType
*/
public final ServerType serverType() {
return ServerType.fromValue(serverType);
}
/**
*
* The type of source provider. The valid options are GITHUB, GITHUB_ENTERPRISE, GITLAB, GITLAB_SELF_MANAGED, or
* BITBUCKET.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #serverType} will
* return {@link ServerType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #serverTypeAsString}.
*
*
* @return The type of source provider. The valid options are GITHUB, GITHUB_ENTERPRISE, GITLAB,
* GITLAB_SELF_MANAGED, or BITBUCKET.
* @see ServerType
*/
public final String serverTypeAsString() {
return serverType;
}
/**
*
* The type of authentication used by the credentials. Valid options are OAUTH, BASIC_AUTH, PERSONAL_ACCESS_TOKEN,
* CODECONNECTIONS, or SECRETS_MANAGER.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #authType} will
* return {@link AuthType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #authTypeAsString}.
*
*
* @return The type of authentication used by the credentials. Valid options are OAUTH, BASIC_AUTH,
* PERSONAL_ACCESS_TOKEN, CODECONNECTIONS, or SECRETS_MANAGER.
* @see AuthType
*/
public final AuthType authType() {
return AuthType.fromValue(authType);
}
/**
*
* The type of authentication used by the credentials. Valid options are OAUTH, BASIC_AUTH, PERSONAL_ACCESS_TOKEN,
* CODECONNECTIONS, or SECRETS_MANAGER.
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #authType} will
* return {@link AuthType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the service is available from
* {@link #authTypeAsString}.
*
*
* @return The type of authentication used by the credentials. Valid options are OAUTH, BASIC_AUTH,
* PERSONAL_ACCESS_TOKEN, CODECONNECTIONS, or SECRETS_MANAGER.
* @see AuthType
*/
public final String authTypeAsString() {
return authType;
}
/**
*
* The connection ARN if your authType is CODECONNECTIONS or SECRETS_MANAGER.
*
*
* @return The connection ARN if your authType is CODECONNECTIONS or SECRETS_MANAGER.
*/
public final String resource() {
return resource;
}
@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(arn());
hashCode = 31 * hashCode + Objects.hashCode(serverTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(authTypeAsString());
hashCode = 31 * hashCode + Objects.hashCode(resource());
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 SourceCredentialsInfo)) {
return false;
}
SourceCredentialsInfo other = (SourceCredentialsInfo) obj;
return Objects.equals(arn(), other.arn()) && Objects.equals(serverTypeAsString(), other.serverTypeAsString())
&& Objects.equals(authTypeAsString(), other.authTypeAsString()) && Objects.equals(resource(), other.resource());
}
/**
* 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("SourceCredentialsInfo").add("Arn", arn()).add("ServerType", serverTypeAsString())
.add("AuthType", authTypeAsString()).add("Resource", resource()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "arn":
return Optional.ofNullable(clazz.cast(arn()));
case "serverType":
return Optional.ofNullable(clazz.cast(serverTypeAsString()));
case "authType":
return Optional.ofNullable(clazz.cast(authTypeAsString()));
case "resource":
return Optional.ofNullable(clazz.cast(resource()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Map> memberNameToFieldInitializer() {
Map> map = new HashMap<>();
map.put("arn", ARN_FIELD);
map.put("serverType", SERVER_TYPE_FIELD);
map.put("authType", AUTH_TYPE_FIELD);
map.put("resource", RESOURCE_FIELD);
return Collections.unmodifiableMap(map);
}
private static Function