software.amazon.awssdk.services.codeartifact.model.RepositoryDescription Maven / Gradle / Ivy
Show all versions of codeartifact 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.codeartifact.model;
import java.io.Serializable;
import java.time.Instant;
import java.util.Arrays;
import java.util.Collection;
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.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.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 details of a repository stored in CodeArtifact. A CodeArtifact repository contains a set of package versions,
* each of which maps to a set of assets. Repositories are polyglot—a single repository can contain packages of any
* supported type. Each repository exposes endpoints for fetching and publishing packages using tools like the
* npm
CLI, the Maven CLI (mvn
), and pip
. You can create up to 100 repositories
* per Amazon Web Services account.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class RepositoryDescription implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField NAME_FIELD = SdkField. builder(MarshallingType.STRING).memberName("name")
.getter(getter(RepositoryDescription::name)).setter(setter(Builder::name))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("name").build()).build();
private static final SdkField ADMINISTRATOR_ACCOUNT_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("administratorAccount").getter(getter(RepositoryDescription::administratorAccount))
.setter(setter(Builder::administratorAccount))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("administratorAccount").build())
.build();
private static final SdkField DOMAIN_NAME_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("domainName").getter(getter(RepositoryDescription::domainName)).setter(setter(Builder::domainName))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("domainName").build()).build();
private static final SdkField DOMAIN_OWNER_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("domainOwner").getter(getter(RepositoryDescription::domainOwner)).setter(setter(Builder::domainOwner))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("domainOwner").build()).build();
private static final SdkField ARN_FIELD = SdkField. builder(MarshallingType.STRING).memberName("arn")
.getter(getter(RepositoryDescription::arn)).setter(setter(Builder::arn))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("arn").build()).build();
private static final SdkField DESCRIPTION_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("description").getter(getter(RepositoryDescription::description)).setter(setter(Builder::description))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("description").build()).build();
private static final SdkField> UPSTREAMS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("upstreams")
.getter(getter(RepositoryDescription::upstreams))
.setter(setter(Builder::upstreams))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("upstreams").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(UpstreamRepositoryInfo::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField> EXTERNAL_CONNECTIONS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("externalConnections")
.getter(getter(RepositoryDescription::externalConnections))
.setter(setter(Builder::externalConnections))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("externalConnections").build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(RepositoryExternalConnectionInfo::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField CREATED_TIME_FIELD = SdkField. builder(MarshallingType.INSTANT)
.memberName("createdTime").getter(getter(RepositoryDescription::createdTime)).setter(setter(Builder::createdTime))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("createdTime").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(NAME_FIELD,
ADMINISTRATOR_ACCOUNT_FIELD, DOMAIN_NAME_FIELD, DOMAIN_OWNER_FIELD, ARN_FIELD, DESCRIPTION_FIELD, UPSTREAMS_FIELD,
EXTERNAL_CONNECTIONS_FIELD, CREATED_TIME_FIELD));
private static final Map> SDK_NAME_TO_FIELD = Collections
.unmodifiableMap(new HashMap>() {
{
put("name", NAME_FIELD);
put("administratorAccount", ADMINISTRATOR_ACCOUNT_FIELD);
put("domainName", DOMAIN_NAME_FIELD);
put("domainOwner", DOMAIN_OWNER_FIELD);
put("arn", ARN_FIELD);
put("description", DESCRIPTION_FIELD);
put("upstreams", UPSTREAMS_FIELD);
put("externalConnections", EXTERNAL_CONNECTIONS_FIELD);
put("createdTime", CREATED_TIME_FIELD);
}
});
private static final long serialVersionUID = 1L;
private final String name;
private final String administratorAccount;
private final String domainName;
private final String domainOwner;
private final String arn;
private final String description;
private final List upstreams;
private final List externalConnections;
private final Instant createdTime;
private RepositoryDescription(BuilderImpl builder) {
this.name = builder.name;
this.administratorAccount = builder.administratorAccount;
this.domainName = builder.domainName;
this.domainOwner = builder.domainOwner;
this.arn = builder.arn;
this.description = builder.description;
this.upstreams = builder.upstreams;
this.externalConnections = builder.externalConnections;
this.createdTime = builder.createdTime;
}
/**
*
* The name of the repository.
*
*
* @return The name of the repository.
*/
public final String name() {
return name;
}
/**
*
* The 12-digit account number of the Amazon Web Services account that manages the repository.
*
*
* @return The 12-digit account number of the Amazon Web Services account that manages the repository.
*/
public final String administratorAccount() {
return administratorAccount;
}
/**
*
* The name of the domain that contains the repository.
*
*
* @return The name of the domain that contains the repository.
*/
public final String domainName() {
return domainName;
}
/**
*
* The 12-digit account number of the Amazon Web Services account that owns the domain that contains the repository.
* It does not include dashes or spaces.
*
*
* @return The 12-digit account number of the Amazon Web Services account that owns the domain that contains the
* repository. It does not include dashes or spaces.
*/
public final String domainOwner() {
return domainOwner;
}
/**
*
* The Amazon Resource Name (ARN) of the repository.
*
*
* @return The Amazon Resource Name (ARN) of the repository.
*/
public final String arn() {
return arn;
}
/**
*
* A text description of the repository.
*
*
* @return A text description of the repository.
*/
public final String description() {
return description;
}
/**
* For responses, this returns true if the service returned a value for the Upstreams 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 hasUpstreams() {
return upstreams != null && !(upstreams instanceof SdkAutoConstructList);
}
/**
*
* A list of upstream repositories to associate with the repository. The order of the upstream repositories in the
* list determines their priority order when CodeArtifact looks for a requested package version. For more
* information, see Working with
* upstream repositories.
*
*
* 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 #hasUpstreams} method.
*
*
* @return A list of upstream repositories to associate with the repository. The order of the upstream repositories
* in the list determines their priority order when CodeArtifact looks for a requested package version. For
* more information, see Working with upstream
* repositories.
*/
public final List upstreams() {
return upstreams;
}
/**
* For responses, this returns true if the service returned a value for the ExternalConnections 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 hasExternalConnections() {
return externalConnections != null && !(externalConnections instanceof SdkAutoConstructList);
}
/**
*
* An array of external connections associated with the repository.
*
*
* 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 #hasExternalConnections} method.
*
*
* @return An array of external connections associated with the repository.
*/
public final List externalConnections() {
return externalConnections;
}
/**
*
* A timestamp that represents the date and time the repository was created.
*
*
* @return A timestamp that represents the date and time the repository was created.
*/
public final Instant createdTime() {
return createdTime;
}
@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(administratorAccount());
hashCode = 31 * hashCode + Objects.hashCode(domainName());
hashCode = 31 * hashCode + Objects.hashCode(domainOwner());
hashCode = 31 * hashCode + Objects.hashCode(arn());
hashCode = 31 * hashCode + Objects.hashCode(description());
hashCode = 31 * hashCode + Objects.hashCode(hasUpstreams() ? upstreams() : null);
hashCode = 31 * hashCode + Objects.hashCode(hasExternalConnections() ? externalConnections() : null);
hashCode = 31 * hashCode + Objects.hashCode(createdTime());
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 RepositoryDescription)) {
return false;
}
RepositoryDescription other = (RepositoryDescription) obj;
return Objects.equals(name(), other.name()) && Objects.equals(administratorAccount(), other.administratorAccount())
&& Objects.equals(domainName(), other.domainName()) && Objects.equals(domainOwner(), other.domainOwner())
&& Objects.equals(arn(), other.arn()) && Objects.equals(description(), other.description())
&& hasUpstreams() == other.hasUpstreams() && Objects.equals(upstreams(), other.upstreams())
&& hasExternalConnections() == other.hasExternalConnections()
&& Objects.equals(externalConnections(), other.externalConnections())
&& Objects.equals(createdTime(), other.createdTime());
}
/**
* 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("RepositoryDescription").add("Name", name()).add("AdministratorAccount", administratorAccount())
.add("DomainName", domainName()).add("DomainOwner", domainOwner()).add("Arn", arn())
.add("Description", description()).add("Upstreams", hasUpstreams() ? upstreams() : null)
.add("ExternalConnections", hasExternalConnections() ? externalConnections() : null)
.add("CreatedTime", createdTime()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "name":
return Optional.ofNullable(clazz.cast(name()));
case "administratorAccount":
return Optional.ofNullable(clazz.cast(administratorAccount()));
case "domainName":
return Optional.ofNullable(clazz.cast(domainName()));
case "domainOwner":
return Optional.ofNullable(clazz.cast(domainOwner()));
case "arn":
return Optional.ofNullable(clazz.cast(arn()));
case "description":
return Optional.ofNullable(clazz.cast(description()));
case "upstreams":
return Optional.ofNullable(clazz.cast(upstreams()));
case "externalConnections":
return Optional.ofNullable(clazz.cast(externalConnections()));
case "createdTime":
return Optional.ofNullable(clazz.cast(createdTime()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
@Override
public final Map> sdkFieldNameToField() {
return SDK_NAME_TO_FIELD;
}
private static Function