Nexus Swagger code to search components etc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.juliusbaer.nexus.nexusswaggerclient; | |
import java.util.List; | |
import io.swagger.client.ApiClient; | |
import io.swagger.client.ApiException; | |
import io.swagger.client.api.AssetsApi; | |
import io.swagger.client.api.ComponentsApi; | |
import io.swagger.client.api.SearchApi; | |
import io.swagger.client.model.AssetXO; | |
import io.swagger.client.model.ComponentXO; | |
import io.swagger.client.model.PageAssetXO; | |
import io.swagger.client.model.PageComponentXO; | |
public class NexucClientTest { | |
private static final String BASE_PATH = "http://localhost:8081/service/rest"; | |
public static void main(String[] args) throws Exception { | |
NexucClientTest nexucClientTest = new NexucClientTest(); | |
//nexucClientTest.testAssets(); | |
System.out.println("\n\n"); | |
//nexucClientTest.testComponents(); | |
System.out.println("\n\n"); | |
nexucClientTest.testSearchComponents(); | |
} | |
private void testComponents() throws ApiException { | |
String continuationToken = ""; | |
ComponentsApi componentsApi = new ComponentsApi(); | |
ApiClient componentApiClient = componentsApi.getApiClient(); | |
componentApiClient.setBasePath(BASE_PATH); | |
PageComponentXO components = componentsApi.getComponents("central", continuationToken); | |
List<ComponentXO> list = components.getItems(); | |
for (ComponentXO component : list) { | |
System.out.println(component); | |
} | |
} | |
private void testAssets() throws ApiException { | |
String continuationToken = ""; | |
AssetsApi assetsApi = new AssetsApi(); | |
ApiClient assetsApiClient = assetsApi.getApiClient(); | |
System.out.println(assetsApiClient.getAuthentications()); | |
assetsApiClient.setBasePath(BASE_PATH); | |
//apiClient.setUsername("admin"); | |
//apiClient.setPassword("admin123"); | |
PageAssetXO assets = assetsApi.getAssets("central", continuationToken); | |
for (AssetXO asset : assets.getItems()) { | |
System.out.println(asset.toString()); | |
} | |
} | |
private void testSearchComponents() throws Exception { | |
String continuationToken = null; | |
SearchApi searchApi = new SearchApi(); | |
searchApi.getApiClient().setBasePath(BASE_PATH); | |
String dockerContentDigest = null; | |
String sha256 = null; | |
String yumArchitecture = null; | |
String group = null; | |
String dockerLayerId = null; | |
String repository = "central"; | |
String pypiKeywords = null; | |
String version = null; | |
String mavenExtension = "jar"; | |
String mavenClassifier = null; | |
String pypiDescription = null; | |
String npmScope = null; | |
String name = null; | |
String sha1 = null; | |
String dockerImageTag = null; | |
String pypiSummary = null; | |
String rubygemsSummary = null; | |
String nugetId = null; | |
String mavenGroupId = "com.fasterxml.jackson.core"; | |
String mavenArtifactId = "jackson-core"; | |
String rubygemsDescription = null; | |
String format = "maven2"; | |
String md5 = null; | |
String sha512 = null; | |
String dockerImageName = null; | |
String pypiClassifiers = null; | |
String nugetTags = null; | |
String rubygemsPlatform = null; | |
String mavenBaseVersion = null; | |
String q = null; | |
PageAssetXO resultAssets = searchApi.searchAssets(continuationToken, q, repository, format, group, name, version, md5, sha1, sha256, sha512, dockerImageName, dockerImageTag, dockerLayerId, dockerContentDigest, mavenGroupId, mavenArtifactId, mavenBaseVersion, mavenExtension, mavenClassifier, npmScope, nugetId, nugetTags, pypiClassifiers, pypiDescription, pypiKeywords, pypiSummary, rubygemsDescription, rubygemsPlatform, rubygemsSummary, yumArchitecture); | |
System.out.println(resultAssets); | |
System.out.println("\n\n"); | |
PageComponentXO resultComponents = searchApi.search(continuationToken, q, repository, format, group, name, version, md5, sha1, sha256, sha512, dockerImageName, dockerImageTag, dockerLayerId, dockerContentDigest, mavenGroupId, mavenArtifactId, mavenBaseVersion, mavenExtension, mavenClassifier, npmScope, nugetId, nugetTags, pypiClassifiers, pypiDescription, pypiKeywords, pypiSummary, rubygemsDescription, rubygemsPlatform, rubygemsSummary, yumArchitecture); | |
System.out.println("\n\n"); | |
System.out.println(resultComponents); | |
System.out.println("\n\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment