From f9c938dfdd0276e2ea514b78269d4d59865e620c Mon Sep 17 00:00:00 2001 From: Ghada Mohamed Kamal Mohamed Date: Tue, 11 Feb 2025 11:50:46 +0100 Subject: [PATCH] testing the client for discovery integration --- .../basyx.aasdiscoveryservice-client/pom.xml | 65 + .../client/ConnectedAasDiscoveryService.java | 48 + .../internal/AssDiscoveryServiceApi.java | 508 +++++++ .../DummyAasDiscoveryServiceComponent.java | 43 + .../TestConnectedAasDiscoveryService.java | 86 ++ .../DummyDiscoveryServiceConfig.java | 54 + basyx.aasdiscoveryservice/pom.xml | 9 +- .../RegistryAndDiscoveryInterfaceApi.java | 1257 +++++++++++++++++ pom.xml | 13 + 9 files changed, 2079 insertions(+), 4 deletions(-) create mode 100644 basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/pom.xml create mode 100644 basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/ConnectedAasDiscoveryService.java create mode 100644 basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/internal/AssDiscoveryServiceApi.java create mode 100644 basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/DummyAasDiscoveryServiceComponent.java create mode 100644 basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/TestConnectedAasDiscoveryService.java create mode 100644 basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/testconfig/DummyDiscoveryServiceConfig.java create mode 100644 basyx.aasregistry/basyx.aasregistry-client-native/src/main/java/RegistryAndDiscoveryInterfaceApi.java diff --git a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/pom.xml b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/pom.xml new file mode 100644 index 000000000..feb8281e5 --- /dev/null +++ b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/pom.xml @@ -0,0 +1,65 @@ + + 4.0.0 + + org.eclipse.digitaltwin.basyx + basyx.aasdiscoveryservice + ${revision} + + basyx.aasdiscoveryservice-client + BaSyx AAS Discovery Service Client + AAS Discovery Service Client enabling interaction with an AAS + Discovery Service + + + org.eclipse.digitaltwin.basyx + basyx.client + + + org.eclipse.digitaltwin.basyx + basyx.aasdiscoveryservice-core + + + org.eclipse.digitaltwin.basyx + basyx.aasdiscoveryservice-core + tests + test + + + org.eclipse.digitaltwin.basyx + basyx.aasdiscoveryservice-http + test + + + org.eclipse.digitaltwin.basyx + basyx.aasdiscoveryservice-backend-inmemory + test + + + org.eclipse.digitaltwin.aas4j + aas4j-model + + + org.apache.httpcomponents.client5 + httpclient5 + test + + + org.eclipse.digitaltwin.basyx + basyx.http + test + tests + + + org.mockito + mockito-core + test + + + org.eclipse.digitaltwin.basyx + basyx.client + + + + \ No newline at end of file diff --git a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/ConnectedAasDiscoveryService.java b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/ConnectedAasDiscoveryService.java new file mode 100644 index 000000000..0e3dfbb10 --- /dev/null +++ b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/ConnectedAasDiscoveryService.java @@ -0,0 +1,48 @@ +package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.client; + +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.client.internal.AasDiscoveryServiceApi; +import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService; +import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.model.AssetLink; +import org.eclipse.digitaltwin.basyx.core.pagination.CursorResult; +import org.eclipse.digitaltwin.basyx.core.pagination.PaginationInfo; + +import java.util.List; + +public class ConnectedAasDiscoveryService implements AasDiscoveryService { + + private final AasDiscoveryServiceApi aasDiscoveryServiceApi; + + public ConnectedAasDiscoveryService(AasDiscoveryServiceApi aasDiscoveryServiceApi) { + this.aasDiscoveryServiceApi = aasDiscoveryServiceApi; + } + + @Override + public CursorResult> getAllAssetAdministrationShellIdsByAssetLink(PaginationInfo pInfo, List assetIds) { + List assetsId = convertToString(assetIds); + Integer limit = pInfo.getLimit(); + String cursor = pInfo.getCursor(); + return aasDiscoveryServiceApi.getAllAssetAdministrationShellIdsByAssetLink(assetsId, limit, cursor); + } + + private static List convertToString(List assetIds) { + return assetIds.stream().map(AssetLink::toString).toList(); + } + + + @Override + public List getAllAssetLinksById(String shellIdentifier) { + return aasDiscoveryServiceApi.getAllAssetLinksById(shellIdentifier); + } + + @Override + public List createAllAssetLinksById(String shellIdentifier, List assetIds) { + return aasDiscoveryServiceApi.postAllAssetLinksById(shellIdentifier,assetIds); + } + + @Override + public void deleteAllAssetLinksById(String shellIdentifier) { + aasDiscoveryServiceApi.deleteAllAssetLinksById(shellIdentifier); + + } +} \ No newline at end of file diff --git a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/internal/AssDiscoveryServiceApi.java b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/internal/AssDiscoveryServiceApi.java new file mode 100644 index 000000000..7692d93b1 --- /dev/null +++ b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/main/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/internal/AssDiscoveryServiceApi.java @@ -0,0 +1,508 @@ +/* + * DotAAS Part 2 | HTTP/REST | Discovery Service Specification + * The entire Full Profile of the Discovery Service Specification as part of the [Specification of the Asset Administration Shell: Part 2](http://industrialdigitaltwin.org/en/content-hub). Publisher: Industrial Digital Twin Association (IDTA) April 2023 + * + * The version of the OpenAPI document: V3.0.3_SSP-001 + * Contact: info@idtwin.org + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + +package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.client.internal; + +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.DeserializationFeature; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.SerializationFeature; +import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.JsonMapperFactory; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.SimpleAbstractTypeResolverFactory; +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.aas4j.v3.model.SpecificAssetId; +import org.eclipse.digitaltwin.basyx.client.internal.ApiClient; +import org.eclipse.digitaltwin.basyx.client.internal.ApiException; +import org.eclipse.digitaltwin.basyx.client.internal.ApiResponse; +import org.eclipse.digitaltwin.basyx.client.internal.Pair; +import org.eclipse.digitaltwin.basyx.client.internal.authorization.TokenManager; +import org.eclipse.digitaltwin.basyx.core.pagination.CursorResult; +import org.eclipse.digitaltwin.basyx.http.pagination.Base64UrlEncodedCursorResult; +import org.openapitools.jackson.nullable.JsonNullableModule; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URI; +import java.net.URLEncoder; +import java.net.http.HttpClient; +import java.net.http.HttpConnectTimeoutException; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; +import java.time.OffsetDateTime; +import java.time.format.DateTimeFormatter; +import java.util.*; +import java.util.function.Consumer; +import java.util.stream.Collectors; + +import static java.nio.charset.StandardCharsets.UTF_8; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.deserialization.EnumDeserializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.serialization.EnumSerializer; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.core.internal.util.ReflectionHelper; +import org.eclipse.digitaltwin.aas4j.v3.dataformat.json.internal.ReflectionAnnotationIntrospector; + +/** + * Configuration and utility class for API clients. + * + *

This class can be constructed and modified, then used to instantiate the + * various API classes. The API classes use the settings in this class to + * configure themselves, but otherwise do not store a link to this class.

+ * + *

This class is mutable and not synchronized, so it is not thread-safe. + * The API classes generated from this are immutable and thread-safe.

+ * + *

The setter methods of this class return the current object to facilitate + * a fluent style of configuration.

+ */ +public class AasDiscoveryServiceApi { + + private HttpClient memberVarHttpClient; + private ObjectMapper memberVarObjectMapper; + private String scheme; + private String host; + private int port; + private String memberVarBaseUri; + private Consumer memberVarInterceptor; + private Consumer> memberVarResponseInterceptor; + private Consumer> memberVarAsyncResponseInterceptor; + private Duration memberVarReadTimeout; + private Duration connectTimeout; + private TokenManager tokenManager; + + public static String valueToString(Object value) { + if (value == null) { + return ""; + } + if (value instanceof OffsetDateTime) { + return ((OffsetDateTime) value).format(DateTimeFormatter.ISO_OFFSET_DATE_TIME); + } + return value.toString(); + } + + + public AasDiscoveryServiceApi() { + this(new ApiClient()); + } + + public AasDiscoveryServiceApi(TokenManager tokenManager) { + this(new ApiClient()); + this.tokenManager = tokenManager; + } + + public AasDiscoveryServiceApi(ObjectMapper mapper, String baseUri) { + this(new ApiClient(HttpClient.newBuilder(), mapper, baseUri)); + } + + public AasDiscoveryServiceApi(ObjectMapper mapper, String baseUri, TokenManager tokenManager) { + this(new ApiClient(HttpClient.newBuilder(), mapper, baseUri)); + this.tokenManager = tokenManager; + } + + public AasDiscoveryServiceApi(String baseUri) { + this(new ApiClient(HttpClient.newBuilder(), new JsonMapperFactory().create(new SimpleAbstractTypeResolverFactory().create()), baseUri)); + } + + public AasDiscoveryServiceApi(String baseUri, TokenManager tokenManager) { + this(new ApiClient(HttpClient.newBuilder(), new JsonMapperFactory().create(new SimpleAbstractTypeResolverFactory().create()), baseUri)); + this.tokenManager = tokenManager; + } + + + public AasDiscoveryServiceApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + public static ObjectMapper createDefaultObjectMapper() { + ObjectMapper mapper = new ObjectMapper(); + mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL); + mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); + mapper.configure(DeserializationFeature.FAIL_ON_INVALID_SUBTYPE, false); + mapper.disable(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS); + mapper.enable(SerializationFeature.WRITE_ENUMS_USING_TO_STRING); + mapper.enable(DeserializationFeature.READ_ENUMS_USING_TO_STRING); + mapper.disable(DeserializationFeature.ADJUST_DATES_TO_CONTEXT_TIME_ZONE); + mapper.registerModule(new JavaTimeModule()); + mapper.registerModule(new JsonNullableModule()); + return mapper; + } + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Deletes all specific Asset identifiers linked to an Asset Administration Shell to edit discoverable content + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @throws ApiException if fails to make API call + */ + public void deleteAllAssetLinksById(String aasIdentifier) throws ApiException { + deleteAllAssetLinksByIdWithHttpInfo(aasIdentifier); + } + + /** + * Deletes all specific Asset identifiers linked to an Asset Administration Shell to edit discoverable content + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteAllAssetLinksByIdWithHttpInfo(String aasIdentifier) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteAllAssetLinksByIdRequestBuilder(aasIdentifier); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteAllAssetLinksById", localVarResponse); + } + return new ApiResponse<>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteAllAssetLinksByIdRequestBuilder(String aasIdentifier) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling deleteAllAssetLinksById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/lookup/shells/{aasIdentifier}" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifier.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Returns a list of Asset Administration Shell ids linked to specific Asset identifiers + * + * @param assetIds A list of specific Asset identifiers. Every single value asset identifier is a base64-url-encoded [SpecificAssetId](https://api.swaggerhub.com/domains/Plattform_i40/Part1-MetaModel-Schemas/V3.0.3#/components/schemas/SpecificAssetId). (optional) + * @param limit The maximum number of elements in the response array (optional) + * @param cursor A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue (optional) + * @return GetAllAssetAdministrationShellIdsByAssetLink200Response + * @throws ApiException if fails to make API call + */ + public CursorResult> getAllAssetAdministrationShellIdsByAssetLink(List assetIds, Integer limit, String cursor) throws ApiException { + ApiResponse>> localVarResponse = getAllAssetAdministrationShellIdsByAssetLinkWithHttpInfo(assetIds, limit, cursor); + return localVarResponse.getData(); + } + + /** + * Returns a list of Asset Administration Shell ids linked to specific Asset identifiers + * + * @param assetIds A list of specific Asset identifiers. Every single value asset identifier is a base64-url-encoded [SpecificAssetId](https://api.swaggerhub.com/domains/Plattform_i40/Part1-MetaModel-Schemas/V3.0.3#/components/schemas/SpecificAssetId). (optional) + * @param limit The maximum number of elements in the response array (optional) + * @param cursor A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue (optional) + * @return ApiResponse<GetAllAssetAdministrationShellIdsByAssetLink200Response> + * @throws ApiException if fails to make API call + */ + public ApiResponse>> getAllAssetAdministrationShellIdsByAssetLinkWithHttpInfo(List assetIds, Integer limit, String cursor) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getAllAssetAdministrationShellIdsByAssetLinkRequestBuilder(assetIds, limit, cursor); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getAllAssetAdministrationShellIdsByAssetLink", localVarResponse); + } + + return new ApiResponse<>(localVarResponse.statusCode(), localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference>>() { + }) // closes the InputStream + ); + + + + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getAllAssetAdministrationShellIdsByAssetLinkRequestBuilder(List assetIds, Integer limit, String cursor) throws ApiException { + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/lookup/shells"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "assetIds"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("multi", "assetIds", assetIds)); + localVarQueryParameterBaseName = "limit"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("limit", limit)); + localVarQueryParameterBaseName = "cursor"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("cursor", cursor)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Returns a list of specific Asset identifiers based on an Asset Administration Shell id to edit discoverable content + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @return List<SpecificAssetId> + * @throws ApiException if fails to make API call + */ + public List getAllAssetLinksById(String aasIdentifier) throws ApiException { + ApiResponse> localVarResponse = getAllAssetLinksByIdWithHttpInfo(aasIdentifier); + return localVarResponse.getData(); + } + + /** + * Returns a list of specific Asset identifiers based on an Asset Administration Shell id to edit discoverable content + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @return ApiResponse<List<SpecificAssetId>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> getAllAssetLinksByIdWithHttpInfo(String aasIdentifier) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getAllAssetLinksByIdRequestBuilder(aasIdentifier); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getAllAssetLinksById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getAllAssetLinksByIdRequestBuilder(String aasIdentifier) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling getAllAssetLinksById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/lookup/shells/{aasIdentifier}" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifier.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + /** + * Creates specific Asset identifiers linked to an Asset Administration Shell to edit discoverable content + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param specificAssetId A list of specific Asset identifiers (required) + * @return List<SpecificAssetId> + * @throws ApiException if fails to make API call + */ + public List postAllAssetLinksById(String aasIdentifier, List specificAssetId) throws ApiException { + ApiResponse> localVarResponse = postAllAssetLinksByIdWithHttpInfo(aasIdentifier, specificAssetId); + return localVarResponse.getData(); + } + + /** + * Creates specific Asset identifiers linked to an Asset Administration Shell to edit discoverable content + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param specificAssetId A list of specific Asset identifiers (required) + * @return ApiResponse<List<SpecificAssetId>> + * @throws ApiException if fails to make API call + */ + public ApiResponse> postAllAssetLinksByIdWithHttpInfo(String aasIdentifier, List specificAssetId) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = postAllAssetLinksByIdRequestBuilder(aasIdentifier, specificAssetId); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("postAllAssetLinksById", localVarResponse); + } + if (localVarResponse.body() == null) { + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } + + String responseBody = new String(localVarResponse.body().readAllBytes()); + localVarResponse.body().close(); + + return new ApiResponse>( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + responseBody.isBlank()? null: memberVarObjectMapper.readValue(responseBody, new TypeReference>() {}) + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder postAllAssetLinksByIdRequestBuilder(String aasIdentifier, List specificAssetId) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling postAllAssetLinksById"); + } + // verify the required parameter 'specificAssetId' is set + if (specificAssetId == null) { + throw new ApiException(400, "Missing the required parameter 'specificAssetId' when calling postAllAssetLinksById"); + } + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/lookup/shells/{aasIdentifier}" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifier.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(specificAssetId); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } +} \ No newline at end of file diff --git a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/DummyAasDiscoveryServiceComponent.java b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/DummyAasDiscoveryServiceComponent.java new file mode 100644 index 000000000..9923fba5b --- /dev/null +++ b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/DummyAasDiscoveryServiceComponent.java @@ -0,0 +1,43 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + +package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.client; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + * Spring application configured for tests. + * + * @author danish + * + */ +@SpringBootApplication(scanBasePackages = "org.eclipse.digitaltwin.basyx") +public class DummyAasDiscoveryServiceComponent { + + public static void main(String[] args) { + SpringApplication.run(DummyAasDiscoveryServiceComponent.class, args); + } +} \ No newline at end of file diff --git a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/TestConnectedAasDiscoveryService.java b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/TestConnectedAasDiscoveryService.java new file mode 100644 index 000000000..1ffce0038 --- /dev/null +++ b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/TestConnectedAasDiscoveryService.java @@ -0,0 +1,86 @@ +/******************************************************************************* + * Copyright (C) 2024 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + + +package org.eclipse.digitaltwin.basyx.aasrepository.client; + +import java.io.IOException; + +import org.eclipse.digitaltwin.aas4j.v3.model.AssetAdministrationShell; +import org.eclipse.digitaltwin.basyx.aasrepository.AasRepository; +import org.eclipse.digitaltwin.basyx.aasrepository.AasRepositorySuite; +import org.eclipse.digitaltwin.basyx.aasrepository.http.DummyAasRepositoryComponent; +import org.eclipse.digitaltwin.basyx.aasservice.AasService; +import org.eclipse.digitaltwin.basyx.aasservice.DummyAssetAdministrationShellFactory; +import org.eclipse.digitaltwin.basyx.core.pagination.PaginationInfo; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.springframework.boot.builder.SpringApplicationBuilder; +import org.springframework.context.ConfigurableApplicationContext; + +/** + * Features of the client not implemented but existing in the test suite are + * overwritten to pass. This is required to enable reuse of the test suite. + * Whenever a feature is implemented, the respective test here has to be + * removed. + * + * @author schnicke, mateusmolina + */ +public class TestConnectedAasRepository extends AasRepositorySuite { + + private static ConfigurableApplicationContext appContext; + + @BeforeClass + public static void startAASRepo() throws Exception { + appContext = new SpringApplicationBuilder(DummyAasRepositoryComponent.class).profiles("httptests").run(new String[] {}); + } + + @After + public void removeAasFromRepo() { + AasRepository repo = appContext.getBean(AasRepository.class); + repo.getAllAas(PaginationInfo.NO_LIMIT).getResult().stream().map(s -> s.getId()).forEach(repo::deleteAas); + } + + @AfterClass + public static void shutdownAASRepo() { + appContext.close(); + } + + @Override + protected AasRepository getAasRepository() { + return new ConnectedAasRepository("http://localhost:8080"); + } + + @Override + protected AasService getAasServiceWithThumbnail() throws IOException { + AssetAdministrationShell expected = DummyAssetAdministrationShellFactory.createForThumbnail(); + AasService aasServiceWithThumbnail = getAasService(expected); + + aasServiceWithThumbnail.setThumbnail("dummyImgA.jpeg", "", createDummyImageIS_A()); + + return aasServiceWithThumbnail; + } +} diff --git a/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/testconfig/DummyDiscoveryServiceConfig.java b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/testconfig/DummyDiscoveryServiceConfig.java new file mode 100644 index 000000000..8303891b8 --- /dev/null +++ b/basyx.aasdiscoveryservice/basyx.aasdiscoveryservice-client/src/test/java/org/eclipse/digitaltwin/basyx/aasdiscoveryservice/client/testconfig/DummyDiscoveryServiceConfig.java @@ -0,0 +1,54 @@ +/******************************************************************************* + * Copyright (C) 2023 the Eclipse BaSyx Authors + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ + +package org.eclipse.digitaltwin.basyx.aasdiscoveryservice.client.testconfig; + + +import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.SimpleAasDiscoveryFactory; +import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.backend.inmemory.AasDiscoveryInMemoryBackendProvider; +import org.eclipse.digitaltwin.basyx.aasdiscoveryservice.core.AasDiscoveryService; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; + +/** + * Configuration for tests + * + * @author danish + * + */ +@Configuration +@Profile("clienttest") +public class DummyDiscoveryServiceConfig { + + @Bean + @ConditionalOnMissingBean + public AasDiscoveryService createAasDiscoveryService() { + return new SimpleAasDiscoveryFactory(new AasDiscoveryInMemoryBackendProvider()).create(); + } + + +} \ No newline at end of file diff --git a/basyx.aasdiscoveryservice/pom.xml b/basyx.aasdiscoveryservice/pom.xml index 84ae37a4f..ab1f63344 100644 --- a/basyx.aasdiscoveryservice/pom.xml +++ b/basyx.aasdiscoveryservice/pom.xml @@ -1,5 +1,5 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 @@ -20,6 +20,7 @@ basyx.aasdiscoveryservice-tck basyx.aasdiscoveryservice.component basyx.aasdiscoveryservice-feature-authorization - basyx.aasdiscoveryservice-backend - - + basyx.aasdiscoveryservice-backend + basyx.aasdiscoveryservice-client + + \ No newline at end of file diff --git a/basyx.aasregistry/basyx.aasregistry-client-native/src/main/java/RegistryAndDiscoveryInterfaceApi.java b/basyx.aasregistry/basyx.aasregistry-client-native/src/main/java/RegistryAndDiscoveryInterfaceApi.java new file mode 100644 index 000000000..9eb210263 --- /dev/null +++ b/basyx.aasregistry/basyx.aasregistry-client-native/src/main/java/RegistryAndDiscoveryInterfaceApi.java @@ -0,0 +1,1257 @@ +/******************************************************************************* + * Copyright (C) 2023 DFKI GmbH (https://www.dfki.de/en/web) + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * SPDX-License-Identifier: MIT + ******************************************************************************/ +package org.eclipse.digitaltwin.basyx.aasregistry.client.api; + +import org.eclipse.digitaltwin.basyx.aasregistry.client.ApiClient; +import org.eclipse.digitaltwin.basyx.aasregistry.client.ApiException; +import org.eclipse.digitaltwin.basyx.aasregistry.client.ApiResponse; +import org.eclipse.digitaltwin.basyx.aasregistry.client.Pair; + +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetAdministrationShellDescriptor; +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.AssetKind; +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.GetAssetAdministrationShellDescriptorsResult; +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.GetSubmodelDescriptorsResult; +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.Result; +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.ServiceDescription; +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.ShellDescriptorSearchRequest; +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.ShellDescriptorSearchResponse; +import org.eclipse.digitaltwin.basyx.aasregistry.client.model.SubmodelDescriptor; + +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; + +import java.io.InputStream; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.OutputStream; +import java.net.http.HttpRequest; +import java.nio.channels.Channels; +import java.nio.channels.Pipe; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpRequest; +import java.net.http.HttpResponse; +import java.time.Duration; + +import java.util.ArrayList; +import java.util.StringJoiner; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.function.Consumer; +import org.eclipse.digitaltwin.basyx.client.internal.authorization.TokenManager; +import org.eclipse.digitaltwin.basyx.core.exceptions.AccessTokenRetrievalException; + +@jakarta.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-02-10T17:05:52.413466700+01:00[Europe/Berlin]") +public class RegistryAndDiscoveryInterfaceApi { + private final HttpClient memberVarHttpClient; + private final ObjectMapper memberVarObjectMapper; + private final String memberVarBaseUri; + private final Consumer memberVarInterceptor; + private final Duration memberVarReadTimeout; + private final Consumer> memberVarResponseInterceptor; + private final Consumer> memberVarAsyncResponseInterceptor; + private TokenManager tokenManager; + + public RegistryAndDiscoveryInterfaceApi() { + this(new ApiClient()); + } + + public RegistryAndDiscoveryInterfaceApi(TokenManager tokenManager) { + this(new ApiClient()); + this.tokenManager = tokenManager; + } + + public RegistryAndDiscoveryInterfaceApi(String protocol, String host, int port) { + this(protocol + "://" + host + ":" + port); + } + + public RegistryAndDiscoveryInterfaceApi(String protocol, String host, int port, TokenManager tokenManager) { + this(protocol + "://" + host + ":" + port); + this.tokenManager = tokenManager; + } + + public RegistryAndDiscoveryInterfaceApi(String basePath) { + this(withBaseUri(new ApiClient(), basePath)); + } + + public RegistryAndDiscoveryInterfaceApi(String basePath, TokenManager tokenManager) { + this(withBaseUri(new ApiClient(), basePath)); + this.tokenManager = tokenManager; + } + + private static ApiClient withBaseUri(ApiClient client, String uri) { + client.updateBaseUri(uri); + return client; + } + + public RegistryAndDiscoveryInterfaceApi(ApiClient apiClient) { + memberVarHttpClient = apiClient.getHttpClient(); + memberVarObjectMapper = apiClient.getObjectMapper(); + memberVarBaseUri = apiClient.getBaseUri(); + memberVarInterceptor = apiClient.getRequestInterceptor(); + memberVarReadTimeout = apiClient.getReadTimeout(); + memberVarResponseInterceptor = apiClient.getResponseInterceptor(); + memberVarAsyncResponseInterceptor = apiClient.getAsyncResponseInterceptor(); + } + + protected ApiException getApiException(String operationId, HttpResponse response) throws IOException { + String body = response.body() == null ? null : new String(response.body().readAllBytes()); + String message = formatExceptionMessage(operationId, response.statusCode(), body); + return new ApiException(response.statusCode(), message, response.headers(), body); + } + + private String formatExceptionMessage(String operationId, int statusCode, String body) { + if (body == null || body.isEmpty()) { + body = "[no body]"; + } + return operationId + " call failed with: " + statusCode + " - " + body; + } + + /** + * Deletes all Asset Administration Shell Descriptors + * + * @throws ApiException if fails to make API call + */ + public void deleteAllShellDescriptors() throws ApiException { + deleteAllShellDescriptorsWithHttpInfo(); + } + + /** + * Deletes all Asset Administration Shell Descriptors + * + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteAllShellDescriptorsWithHttpInfo() throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteAllShellDescriptorsRequestBuilder(); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteAllShellDescriptors", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteAllShellDescriptorsRequestBuilder() throws ApiException { + + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Deletes an Asset Administration Shell Descriptor, i.e. de-registers an AAS + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @throws ApiException if fails to make API call + */ + public void deleteAssetAdministrationShellDescriptorById(String aasIdentifier) throws ApiException { + deleteAssetAdministrationShellDescriptorByIdWithHttpInfo(aasIdentifier); + } + + /** + * Deletes an Asset Administration Shell Descriptor, i.e. de-registers an AAS + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteAssetAdministrationShellDescriptorByIdWithHttpInfo(String aasIdentifier) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteAssetAdministrationShellDescriptorByIdRequestBuilder(aasIdentifier); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteAssetAdministrationShellDescriptorById", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteAssetAdministrationShellDescriptorByIdRequestBuilder(String aasIdentifier) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling deleteAssetAdministrationShellDescriptorById"); + } + + String aasIdentifierAsBase64EncodedParam = aasIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(aasIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors/{aasIdentifier}" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifierAsBase64EncodedParam.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Deletes a Submodel Descriptor, i.e. de-registers a submodel + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelIdentifier The Submodel’s unique id (UTF8-BASE64-URL-encoded) (required) + * @throws ApiException if fails to make API call + */ + public void deleteSubmodelDescriptorByIdThroughSuperpath(String aasIdentifier, String submodelIdentifier) throws ApiException { + deleteSubmodelDescriptorByIdThroughSuperpathWithHttpInfo(aasIdentifier, submodelIdentifier); + } + + /** + * Deletes a Submodel Descriptor, i.e. de-registers a submodel + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelIdentifier The Submodel’s unique id (UTF8-BASE64-URL-encoded) (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse deleteSubmodelDescriptorByIdThroughSuperpathWithHttpInfo(String aasIdentifier, String submodelIdentifier) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = deleteSubmodelDescriptorByIdThroughSuperpathRequestBuilder(aasIdentifier, submodelIdentifier); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("deleteSubmodelDescriptorByIdThroughSuperpath", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder deleteSubmodelDescriptorByIdThroughSuperpathRequestBuilder(String aasIdentifier, String submodelIdentifier) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling deleteSubmodelDescriptorByIdThroughSuperpath"); + } + // verify the required parameter 'submodelIdentifier' is set + if (submodelIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'submodelIdentifier' when calling deleteSubmodelDescriptorByIdThroughSuperpath"); + } + + String aasIdentifierAsBase64EncodedParam = aasIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(aasIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + String submodelIdentifierAsBase64EncodedParam = submodelIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(submodelIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors/{aasIdentifier}/submodel-descriptors/{submodelIdentifier}" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifierAsBase64EncodedParam.toString())) + .replace("{submodelIdentifier}", ApiClient.urlEncode(submodelIdentifierAsBase64EncodedParam.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + localVarRequestBuilder.method("DELETE", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Returns all Asset Administration Shell Descriptors + * + * @param limit The maximum number of elements in the response array (optional) + * @param cursor A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue (optional) + * @param assetKind The Asset's kind (Instance or Type) (optional) + * @param assetType The Asset's type (UTF8-BASE64-URL-encoded) (optional) + * @return GetAssetAdministrationShellDescriptorsResult + * @throws ApiException if fails to make API call + */ + public GetAssetAdministrationShellDescriptorsResult getAllAssetAdministrationShellDescriptors(Integer limit, String cursor, AssetKind assetKind, String assetType) throws ApiException { + ApiResponse localVarResponse = getAllAssetAdministrationShellDescriptorsWithHttpInfo(limit, cursor, assetKind, assetType); + return localVarResponse.getData(); + } + + /** + * Returns all Asset Administration Shell Descriptors + * + * @param limit The maximum number of elements in the response array (optional) + * @param cursor A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue (optional) + * @param assetKind The Asset's kind (Instance or Type) (optional) + * @param assetType The Asset's type (UTF8-BASE64-URL-encoded) (optional) + * @return ApiResponse<GetAssetAdministrationShellDescriptorsResult> + * @throws ApiException if fails to make API call + */ + public ApiResponse getAllAssetAdministrationShellDescriptorsWithHttpInfo(Integer limit, String cursor, AssetKind assetKind, String assetType) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getAllAssetAdministrationShellDescriptorsRequestBuilder(limit, cursor, assetKind, assetType); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getAllAssetAdministrationShellDescriptors", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getAllAssetAdministrationShellDescriptorsRequestBuilder(Integer limit, String cursor, AssetKind assetKind, String assetType) throws ApiException { + + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors"; + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "limit"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("limit", limit)); + localVarQueryParameterBaseName = "cursor"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("cursor", cursor)); + localVarQueryParameterBaseName = "assetKind"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("assetKind", assetKind)); + localVarQueryParameterBaseName = "assetType"; + String assetTypeAsBase64EncodedQueryParam = assetType == null ? null : new String(java.util.Base64.getUrlEncoder().encode(assetType.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + localVarQueryParams.addAll(ApiClient.parameterToPairs("assetType", assetTypeAsBase64EncodedQueryParam)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Returns all Submodel Descriptors + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param limit The maximum number of elements in the response array (optional) + * @param cursor A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue (optional) + * @return GetSubmodelDescriptorsResult + * @throws ApiException if fails to make API call + */ + public GetSubmodelDescriptorsResult getAllSubmodelDescriptorsThroughSuperpath(String aasIdentifier, Integer limit, String cursor) throws ApiException { + ApiResponse localVarResponse = getAllSubmodelDescriptorsThroughSuperpathWithHttpInfo(aasIdentifier, limit, cursor); + return localVarResponse.getData(); + } + + /** + * Returns all Submodel Descriptors + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param limit The maximum number of elements in the response array (optional) + * @param cursor A server-generated identifier retrieved from pagingMetadata that specifies from which position the result listing should continue (optional) + * @return ApiResponse<GetSubmodelDescriptorsResult> + * @throws ApiException if fails to make API call + */ + public ApiResponse getAllSubmodelDescriptorsThroughSuperpathWithHttpInfo(String aasIdentifier, Integer limit, String cursor) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getAllSubmodelDescriptorsThroughSuperpathRequestBuilder(aasIdentifier, limit, cursor); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getAllSubmodelDescriptorsThroughSuperpath", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getAllSubmodelDescriptorsThroughSuperpathRequestBuilder(String aasIdentifier, Integer limit, String cursor) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling getAllSubmodelDescriptorsThroughSuperpath"); + } + + String aasIdentifierAsBase64EncodedParam = aasIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(aasIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors/{aasIdentifier}/submodel-descriptors" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifierAsBase64EncodedParam.toString())); + + List localVarQueryParams = new ArrayList<>(); + StringJoiner localVarQueryStringJoiner = new StringJoiner("&"); + String localVarQueryParameterBaseName; + localVarQueryParameterBaseName = "limit"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("limit", limit)); + localVarQueryParameterBaseName = "cursor"; + localVarQueryParams.addAll(ApiClient.parameterToPairs("cursor", cursor)); + + if (!localVarQueryParams.isEmpty() || localVarQueryStringJoiner.length() != 0) { + StringJoiner queryJoiner = new StringJoiner("&"); + localVarQueryParams.forEach(p -> queryJoiner.add(p.getName() + '=' + p.getValue())); + if (localVarQueryStringJoiner.length() != 0) { + queryJoiner.add(localVarQueryStringJoiner.toString()); + } + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath + '?' + queryJoiner.toString())); + } else { + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + } + + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Returns a specific Asset Administration Shell Descriptor + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @return AssetAdministrationShellDescriptor + * @throws ApiException if fails to make API call + */ + public AssetAdministrationShellDescriptor getAssetAdministrationShellDescriptorById(String aasIdentifier) throws ApiException { + ApiResponse localVarResponse = getAssetAdministrationShellDescriptorByIdWithHttpInfo(aasIdentifier); + return localVarResponse.getData(); + } + + /** + * Returns a specific Asset Administration Shell Descriptor + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @return ApiResponse<AssetAdministrationShellDescriptor> + * @throws ApiException if fails to make API call + */ + public ApiResponse getAssetAdministrationShellDescriptorByIdWithHttpInfo(String aasIdentifier) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getAssetAdministrationShellDescriptorByIdRequestBuilder(aasIdentifier); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getAssetAdministrationShellDescriptorById", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getAssetAdministrationShellDescriptorByIdRequestBuilder(String aasIdentifier) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling getAssetAdministrationShellDescriptorById"); + } + + String aasIdentifierAsBase64EncodedParam = aasIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(aasIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors/{aasIdentifier}" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifierAsBase64EncodedParam.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Returns the self-describing information of a network resource (ServiceDescription) + * + * @return ServiceDescription + * @throws ApiException if fails to make API call + */ + public ServiceDescription getDescription() throws ApiException { + ApiResponse localVarResponse = getDescriptionWithHttpInfo(); + return localVarResponse.getData(); + } + + /** + * Returns the self-describing information of a network resource (ServiceDescription) + * + * @return ApiResponse<ServiceDescription> + * @throws ApiException if fails to make API call + */ + public ApiResponse getDescriptionWithHttpInfo() throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getDescriptionRequestBuilder(); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getDescription", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getDescriptionRequestBuilder() throws ApiException { + + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/description"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Returns a specific Submodel Descriptor + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelIdentifier The Submodel’s unique id (UTF8-BASE64-URL-encoded) (required) + * @return SubmodelDescriptor + * @throws ApiException if fails to make API call + */ + public SubmodelDescriptor getSubmodelDescriptorByIdThroughSuperpath(String aasIdentifier, String submodelIdentifier) throws ApiException { + ApiResponse localVarResponse = getSubmodelDescriptorByIdThroughSuperpathWithHttpInfo(aasIdentifier, submodelIdentifier); + return localVarResponse.getData(); + } + + /** + * Returns a specific Submodel Descriptor + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelIdentifier The Submodel’s unique id (UTF8-BASE64-URL-encoded) (required) + * @return ApiResponse<SubmodelDescriptor> + * @throws ApiException if fails to make API call + */ + public ApiResponse getSubmodelDescriptorByIdThroughSuperpathWithHttpInfo(String aasIdentifier, String submodelIdentifier) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = getSubmodelDescriptorByIdThroughSuperpathRequestBuilder(aasIdentifier, submodelIdentifier); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("getSubmodelDescriptorByIdThroughSuperpath", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder getSubmodelDescriptorByIdThroughSuperpathRequestBuilder(String aasIdentifier, String submodelIdentifier) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling getSubmodelDescriptorByIdThroughSuperpath"); + } + // verify the required parameter 'submodelIdentifier' is set + if (submodelIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'submodelIdentifier' when calling getSubmodelDescriptorByIdThroughSuperpath"); + } + + String aasIdentifierAsBase64EncodedParam = aasIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(aasIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + String submodelIdentifierAsBase64EncodedParam = submodelIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(submodelIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors/{aasIdentifier}/submodel-descriptors/{submodelIdentifier}" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifierAsBase64EncodedParam.toString())) + .replace("{submodelIdentifier}", ApiClient.urlEncode(submodelIdentifierAsBase64EncodedParam.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + localVarRequestBuilder.method("GET", HttpRequest.BodyPublishers.noBody()); + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Creates a new Asset Administration Shell Descriptor, i.e. registers an AAS + * + * @param assetAdministrationShellDescriptor Asset Administration Shell Descriptor object (required) + * @return AssetAdministrationShellDescriptor + * @throws ApiException if fails to make API call + */ + public AssetAdministrationShellDescriptor postAssetAdministrationShellDescriptor(AssetAdministrationShellDescriptor assetAdministrationShellDescriptor) throws ApiException { + ApiResponse localVarResponse = postAssetAdministrationShellDescriptorWithHttpInfo(assetAdministrationShellDescriptor); + return localVarResponse.getData(); + } + + /** + * Creates a new Asset Administration Shell Descriptor, i.e. registers an AAS + * + * @param assetAdministrationShellDescriptor Asset Administration Shell Descriptor object (required) + * @return ApiResponse<AssetAdministrationShellDescriptor> + * @throws ApiException if fails to make API call + */ + public ApiResponse postAssetAdministrationShellDescriptorWithHttpInfo(AssetAdministrationShellDescriptor assetAdministrationShellDescriptor) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = postAssetAdministrationShellDescriptorRequestBuilder(assetAdministrationShellDescriptor); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("postAssetAdministrationShellDescriptor", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder postAssetAdministrationShellDescriptorRequestBuilder(AssetAdministrationShellDescriptor assetAdministrationShellDescriptor) throws ApiException { + // verify the required parameter 'assetAdministrationShellDescriptor' is set + if (assetAdministrationShellDescriptor == null) { + throw new ApiException(400, "Missing the required parameter 'assetAdministrationShellDescriptor' when calling postAssetAdministrationShellDescriptor"); + } + + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(assetAdministrationShellDescriptor); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Creates a new Submodel Descriptor, i.e. registers a submodel + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelDescriptor Submodel Descriptor object (required) + * @return SubmodelDescriptor + * @throws ApiException if fails to make API call + */ + public SubmodelDescriptor postSubmodelDescriptorThroughSuperpath(String aasIdentifier, SubmodelDescriptor submodelDescriptor) throws ApiException { + ApiResponse localVarResponse = postSubmodelDescriptorThroughSuperpathWithHttpInfo(aasIdentifier, submodelDescriptor); + return localVarResponse.getData(); + } + + /** + * Creates a new Submodel Descriptor, i.e. registers a submodel + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelDescriptor Submodel Descriptor object (required) + * @return ApiResponse<SubmodelDescriptor> + * @throws ApiException if fails to make API call + */ + public ApiResponse postSubmodelDescriptorThroughSuperpathWithHttpInfo(String aasIdentifier, SubmodelDescriptor submodelDescriptor) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = postSubmodelDescriptorThroughSuperpathRequestBuilder(aasIdentifier, submodelDescriptor); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("postSubmodelDescriptorThroughSuperpath", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder postSubmodelDescriptorThroughSuperpathRequestBuilder(String aasIdentifier, SubmodelDescriptor submodelDescriptor) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling postSubmodelDescriptorThroughSuperpath"); + } + // verify the required parameter 'submodelDescriptor' is set + if (submodelDescriptor == null) { + throw new ApiException(400, "Missing the required parameter 'submodelDescriptor' when calling postSubmodelDescriptorThroughSuperpath"); + } + + String aasIdentifierAsBase64EncodedParam = aasIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(aasIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors/{aasIdentifier}/submodel-descriptors" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifierAsBase64EncodedParam.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(submodelDescriptor); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Updates an existing Asset Administration Shell Descriptor + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param assetAdministrationShellDescriptor Asset Administration Shell Descriptor object (required) + * @throws ApiException if fails to make API call + */ + public void putAssetAdministrationShellDescriptorById(String aasIdentifier, AssetAdministrationShellDescriptor assetAdministrationShellDescriptor) throws ApiException { + putAssetAdministrationShellDescriptorByIdWithHttpInfo(aasIdentifier, assetAdministrationShellDescriptor); + } + + /** + * Updates an existing Asset Administration Shell Descriptor + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param assetAdministrationShellDescriptor Asset Administration Shell Descriptor object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse putAssetAdministrationShellDescriptorByIdWithHttpInfo(String aasIdentifier, AssetAdministrationShellDescriptor assetAdministrationShellDescriptor) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = putAssetAdministrationShellDescriptorByIdRequestBuilder(aasIdentifier, assetAdministrationShellDescriptor); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("putAssetAdministrationShellDescriptorById", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder putAssetAdministrationShellDescriptorByIdRequestBuilder(String aasIdentifier, AssetAdministrationShellDescriptor assetAdministrationShellDescriptor) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling putAssetAdministrationShellDescriptorById"); + } + // verify the required parameter 'assetAdministrationShellDescriptor' is set + if (assetAdministrationShellDescriptor == null) { + throw new ApiException(400, "Missing the required parameter 'assetAdministrationShellDescriptor' when calling putAssetAdministrationShellDescriptorById"); + } + + String aasIdentifierAsBase64EncodedParam = aasIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(aasIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors/{aasIdentifier}" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifierAsBase64EncodedParam.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(assetAdministrationShellDescriptor); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * Updates an existing Submodel Descriptor + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelIdentifier The Submodel’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelDescriptor Submodel Descriptor object (required) + * @throws ApiException if fails to make API call + */ + public void putSubmodelDescriptorByIdThroughSuperpath(String aasIdentifier, String submodelIdentifier, SubmodelDescriptor submodelDescriptor) throws ApiException { + putSubmodelDescriptorByIdThroughSuperpathWithHttpInfo(aasIdentifier, submodelIdentifier, submodelDescriptor); + } + + /** + * Updates an existing Submodel Descriptor + * + * @param aasIdentifier The Asset Administration Shell’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelIdentifier The Submodel’s unique id (UTF8-BASE64-URL-encoded) (required) + * @param submodelDescriptor Submodel Descriptor object (required) + * @return ApiResponse<Void> + * @throws ApiException if fails to make API call + */ + public ApiResponse putSubmodelDescriptorByIdThroughSuperpathWithHttpInfo(String aasIdentifier, String submodelIdentifier, SubmodelDescriptor submodelDescriptor) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = putSubmodelDescriptorByIdThroughSuperpathRequestBuilder(aasIdentifier, submodelIdentifier, submodelDescriptor); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("putSubmodelDescriptorByIdThroughSuperpath", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + null + ); + } finally { + // Drain the InputStream + while (localVarResponse.body().read() != -1) { + // Ignore + } + localVarResponse.body().close(); + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder putSubmodelDescriptorByIdThroughSuperpathRequestBuilder(String aasIdentifier, String submodelIdentifier, SubmodelDescriptor submodelDescriptor) throws ApiException { + // verify the required parameter 'aasIdentifier' is set + if (aasIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'aasIdentifier' when calling putSubmodelDescriptorByIdThroughSuperpath"); + } + // verify the required parameter 'submodelIdentifier' is set + if (submodelIdentifier == null) { + throw new ApiException(400, "Missing the required parameter 'submodelIdentifier' when calling putSubmodelDescriptorByIdThroughSuperpath"); + } + // verify the required parameter 'submodelDescriptor' is set + if (submodelDescriptor == null) { + throw new ApiException(400, "Missing the required parameter 'submodelDescriptor' when calling putSubmodelDescriptorByIdThroughSuperpath"); + } + + String aasIdentifierAsBase64EncodedParam = aasIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(aasIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + String submodelIdentifierAsBase64EncodedParam = submodelIdentifier == null ? null : new String(java.util.Base64.getUrlEncoder().encode(submodelIdentifier.getBytes(java.nio.charset.StandardCharsets.UTF_8)), java.nio.charset.StandardCharsets.UTF_8); + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/shell-descriptors/{aasIdentifier}/submodel-descriptors/{submodelIdentifier}" + .replace("{aasIdentifier}", ApiClient.urlEncode(aasIdentifierAsBase64EncodedParam.toString())) + .replace("{submodelIdentifier}", ApiClient.urlEncode(submodelIdentifierAsBase64EncodedParam.toString())); + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(submodelDescriptor); + localVarRequestBuilder.method("PUT", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + /** + * + * + * @param shellDescriptorSearchRequest (required) + * @return ShellDescriptorSearchResponse + * @throws ApiException if fails to make API call + */ + public ShellDescriptorSearchResponse searchShellDescriptors(ShellDescriptorSearchRequest shellDescriptorSearchRequest) throws ApiException { + ApiResponse localVarResponse = searchShellDescriptorsWithHttpInfo(shellDescriptorSearchRequest); + return localVarResponse.getData(); + } + + /** + * + * + * @param shellDescriptorSearchRequest (required) + * @return ApiResponse<ShellDescriptorSearchResponse> + * @throws ApiException if fails to make API call + */ + public ApiResponse searchShellDescriptorsWithHttpInfo(ShellDescriptorSearchRequest shellDescriptorSearchRequest) throws ApiException { + HttpRequest.Builder localVarRequestBuilder = searchShellDescriptorsRequestBuilder(shellDescriptorSearchRequest); + try { + HttpResponse localVarResponse = memberVarHttpClient.send( + localVarRequestBuilder.build(), + HttpResponse.BodyHandlers.ofInputStream()); + if (memberVarResponseInterceptor != null) { + memberVarResponseInterceptor.accept(localVarResponse); + } + try { + if (localVarResponse.statusCode()/ 100 != 2) { + throw getApiException("searchShellDescriptors", localVarResponse); + } + return new ApiResponse( + localVarResponse.statusCode(), + localVarResponse.headers().map(), + localVarResponse.body() == null ? null : memberVarObjectMapper.readValue(localVarResponse.body(), new TypeReference() {}) // closes the InputStream + ); + } finally { + } + } catch (IOException e) { + throw new ApiException(e); + } + catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new ApiException(e); + } + } + + private HttpRequest.Builder searchShellDescriptorsRequestBuilder(ShellDescriptorSearchRequest shellDescriptorSearchRequest) throws ApiException { + // verify the required parameter 'shellDescriptorSearchRequest' is set + if (shellDescriptorSearchRequest == null) { + throw new ApiException(400, "Missing the required parameter 'shellDescriptorSearchRequest' when calling searchShellDescriptors"); + } + + + + HttpRequest.Builder localVarRequestBuilder = HttpRequest.newBuilder(); + + String localVarPath = "/search"; + + localVarRequestBuilder.uri(URI.create(memberVarBaseUri + localVarPath)); + + localVarRequestBuilder.header("Content-Type", "application/json"); + localVarRequestBuilder.header("Accept", "application/json"); + + addAuthorizationHeaderIfAuthIsEnabled(localVarRequestBuilder); + + try { + byte[] localVarPostBody = memberVarObjectMapper.writeValueAsBytes(shellDescriptorSearchRequest); + localVarRequestBuilder.method("POST", HttpRequest.BodyPublishers.ofByteArray(localVarPostBody)); + } catch (IOException e) { + throw new ApiException(e); + } + if (memberVarReadTimeout != null) { + localVarRequestBuilder.timeout(memberVarReadTimeout); + } + if (memberVarInterceptor != null) { + memberVarInterceptor.accept(localVarRequestBuilder); + } + return localVarRequestBuilder; + } + + private void addAuthorizationHeaderIfAuthIsEnabled(HttpRequest.Builder localVarRequestBuilder) { + if (tokenManager != null) { + try { + localVarRequestBuilder.header("Authorization", "Bearer " + tokenManager.getAccessToken()); + } catch (IOException e) { + e.printStackTrace(); + throw new AccessTokenRetrievalException("Unable to request access token"); + } + } + } +} diff --git a/pom.xml b/pom.xml index 90ca37e10..157c22112 100644 --- a/pom.xml +++ b/pom.xml @@ -57,6 +57,19 @@ false + + + + sonatype.snapshots + Sonatype Snapshot Repository + https://oss.sonatype.org/content/repositories/snapshots + + false + + + true + +