org.jboss.pnc.client.BuildConfigurationClient Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of rest-api Show documentation
Show all versions of rest-api Show documentation
Module with REST API bidings.
package org.jboss.pnc.client;
import java.lang.String;
import java.util.Optional;
import java.util.Set;
import javax.ws.rs.NotAuthorizedException;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.WebApplicationException;
import org.jboss.pnc.dto.Build;
import org.jboss.pnc.dto.BuildConfiguration;
import org.jboss.pnc.dto.BuildConfigurationRef;
import org.jboss.pnc.dto.BuildConfigurationRevision;
import org.jboss.pnc.dto.BuildConfigurationWithLatestBuild;
import org.jboss.pnc.dto.GroupConfiguration;
import org.jboss.pnc.dto.requests.BuildConfigWithSCMRequest;
import org.jboss.pnc.dto.response.AlignmentParameters;
import org.jboss.pnc.dto.response.BuildConfigCreationResponse;
import org.jboss.pnc.dto.response.Parameter;
import org.jboss.pnc.rest.api.endpoints.BuildConfigurationEndpoint;
import org.jboss.pnc.rest.api.parameters.BuildParameters;
import org.jboss.pnc.rest.api.parameters.BuildsFilterParameters;
public class BuildConfigurationClient extends ClientBase {
public BuildConfigurationClient(Configuration configuration) {
super(configuration, BuildConfigurationEndpoint.class);
}
public RemoteCollection getAll(Optional sort, Optional query)
throws RemoteResourceException {
try {
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getAll(pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getAll(pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getAll() throws RemoteResourceException {
try {
return getAll(Optional.empty(), Optional.empty());
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getAll(Optional.empty(), Optional.empty());
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getAllWithLatestBuild(
Optional sort, Optional query) throws RemoteResourceException {
try {
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getAllWithLatestBuild(pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getAllWithLatestBuild(pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getAllWithLatestBuild() throws
RemoteResourceException {
try {
return getAllWithLatestBuild(Optional.empty(), Optional.empty());
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getAllWithLatestBuild(Optional.empty(), Optional.empty());
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public BuildConfiguration createNew(BuildConfiguration buildConfig) throws
RemoteResourceException {
try {
return getEndpoint().createNew(buildConfig);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().createNew(buildConfig);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public BuildConfiguration getSpecific(String id) throws RemoteResourceException {
try {
return getEndpoint().getSpecific(id);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().getSpecific(id);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public void update(String id, BuildConfiguration buildConfig) throws RemoteResourceException,
RemoteResourceNotFoundException {
try {
getEndpoint().update(id, buildConfig);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
getEndpoint().update(id, buildConfig);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public Build trigger(String id, BuildParameters buildParams) throws RemoteResourceException {
try {
return getEndpoint().trigger(id, buildParams);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().trigger(id, buildParams);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getBuilds(String id, BuildsFilterParameters buildsFilter,
Optional sort, Optional query) throws RemoteResourceException {
try {
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getBuilds(id, pageParameters, buildsFilter);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getBuilds(id, pageParameters, buildsFilter);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getBuilds(String id, BuildsFilterParameters buildsFilter) throws
RemoteResourceException {
try {
return getBuilds(id, buildsFilter, Optional.empty(), Optional.empty());
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getBuilds(id, buildsFilter, Optional.empty(), Optional.empty());
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public BuildConfiguration clone(String id) throws RemoteResourceException {
try {
return getEndpoint().clone(id);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().clone(id);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getGroupConfigs(String id, Optional sort,
Optional query) throws RemoteResourceException {
try {
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getGroupConfigs(id, pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getGroupConfigs(id, pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getGroupConfigs(String id) throws
RemoteResourceException {
try {
return getGroupConfigs(id, Optional.empty(), Optional.empty());
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getGroupConfigs(id, Optional.empty(), Optional.empty());
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getDependencies(String id, Optional sort,
Optional query) throws RemoteResourceException {
try {
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getDependencies(id, pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getDependencies(id, pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getDependencies(String id) throws
RemoteResourceException {
try {
return getDependencies(id, Optional.empty(), Optional.empty());
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getDependencies(id, Optional.empty(), Optional.empty());
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getDependants(String id, Optional sort,
Optional query) throws RemoteResourceException {
try {
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getDependants(id, pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getDependants(id, pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getDependants(String id) throws
RemoteResourceException {
try {
return getDependants(id, Optional.empty(), Optional.empty());
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getDependants(id, Optional.empty(), Optional.empty());
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public void addDependency(String id, BuildConfigurationRef dependency) throws
RemoteResourceException, RemoteResourceNotFoundException {
try {
getEndpoint().addDependency(id, dependency);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
getEndpoint().addDependency(id, dependency);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public void removeDependency(String id, String dependencyId) throws RemoteResourceException,
RemoteResourceNotFoundException {
try {
getEndpoint().removeDependency(id, dependencyId);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
getEndpoint().removeDependency(id, dependencyId);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getRevisions(String id, Optional sort,
Optional query) throws RemoteResourceException {
try {
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getRevisions(id, pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
PageReader pageLoader = new PageReader<>((pageParameters) -> { setSortAndQuery(pageParameters, sort, query); return getEndpoint().getRevisions(id, pageParameters);}, getRemoteCollectionConfig());
return pageLoader.getCollection();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public RemoteCollection getRevisions(String id) throws
RemoteResourceException {
try {
return getRevisions(id, Optional.empty(), Optional.empty());
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getRevisions(id, Optional.empty(), Optional.empty());
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public BuildConfigurationRevision createRevision(String id, BuildConfiguration buildConfig) throws
RemoteResourceException {
try {
return getEndpoint().createRevision(id, buildConfig);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().createRevision(id, buildConfig);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public BuildConfigurationRevision getRevision(String id, int rev) throws RemoteResourceException {
try {
return getEndpoint().getRevision(id, rev);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().getRevision(id, rev);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public Build triggerRevision(String id, int rev, BuildParameters buildParams) throws
RemoteResourceException {
try {
return getEndpoint().triggerRevision(id, rev, buildParams);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().triggerRevision(id, rev, buildParams);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public BuildConfiguration restoreRevision(String id, int rev) throws RemoteResourceException {
try {
return getEndpoint().restoreRevision(id, rev);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().restoreRevision(id, rev);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public BuildConfigCreationResponse createWithSCM(BuildConfigWithSCMRequest request) throws
RemoteResourceException {
try {
return getEndpoint().createWithSCM(request);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().createWithSCM(request);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public Set getSupportedParameters() throws RemoteResourceException {
try {
return getEndpoint().getSupportedParameters();
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().getSupportedParameters();
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
public AlignmentParameters getBuildTypeDefaultAlignmentParameters(String buildType) throws
RemoteResourceException {
try {
return getEndpoint().getBuildTypeDefaultAlignmentParameters(buildType);
} catch (NotFoundException e) {
throw new RemoteResourceNotFoundException(e);
} catch (NotAuthorizedException e) {
if (configuration.getBearerTokenSupplier() != null) {
try {
bearerAuthentication.setToken(configuration.getBearerTokenSupplier().get());
return getEndpoint().getBuildTypeDefaultAlignmentParameters(buildType);
} catch (WebApplicationException wae) {
throw new RemoteResourceException(readErrorResponse(wae), wae);
}
} else {
throw new RemoteResourceException(readErrorResponse(e), e);
}
} catch (WebApplicationException e) {
throw new RemoteResourceException(readErrorResponse(e), e);
}
}
}