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.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.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 AWS 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 AWS 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 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));
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 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;
}
/**
*
* The name of the repository.
*
*
* @return The name of the repository.
*/
public String name() {
return name;
}
/**
*
* The 12-digit account number of the AWS account that manages the repository.
*
*
* @return The 12-digit account number of the AWS account that manages the repository.
*/
public String administratorAccount() {
return administratorAccount;
}
/**
*
* The name of the domain that contains the repository.
*
*
* @return The name of the domain that contains the repository.
*/
public String domainName() {
return domainName;
}
/**
*
* The 12-digit account number of the AWS account that owns the domain that contains the repository. It does not
* include dashes or spaces.
*
*
* @return The 12-digit account number of the AWS account that owns the domain that contains the repository. It does
* not include dashes or spaces.
*/
public String domainOwner() {
return domainOwner;
}
/**
*
* The Amazon Resource Name (ARN) of the repository.
*
*
* @return The Amazon Resource Name (ARN) of the repository.
*/
public String arn() {
return arn;
}
/**
*
* A text description of the repository.
*
*
* @return A text description of the repository.
*/
public String description() {
return description;
}
/**
* Returns true if the Upstreams 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 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 AWS 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.
*
*
* You can use {@link #hasUpstreams()} to see if a value was sent in this field.
*
*
* @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 AWS CodeArtifact looks for a requested package version.
* For more information, see Working with upstream
* repositories.
*/
public List upstreams() {
return upstreams;
}
/**
* Returns true if the ExternalConnections 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 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.
*
*
* You can use {@link #hasExternalConnections()} to see if a value was sent in this field.
*
*
* @return An array of external connections associated with the repository.
*/
public List externalConnections() {
return externalConnections;
}
@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 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(upstreams());
hashCode = 31 * hashCode + Objects.hashCode(externalConnections());
return hashCode;
}
@Override
public boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public 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())
&& Objects.equals(upstreams(), other.upstreams())
&& Objects.equals(externalConnections(), other.externalConnections());
}
/**
* 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 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", upstreams())
.add("ExternalConnections", externalConnections()).build();
}
public 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()));
default:
return Optional.empty();
}
}
@Override
public List> sdkFields() {
return SDK_FIELDS;
}
private static Function