diff --git a/CHANGELOG.md b/CHANGELOG.md index 06ad2ada35d..0fa733c8821 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/). ### Added - N/A +## 1.2.47 - 2018-09-27 +### Added +- Support for `paravirtualized` launch mode when importing images in the Compute service +- Support for Key Management service +- Support for encrypting the contents of an Object Storage bucket using a Key Management service key +- Support for specifying a Key Management service key when launching a compute instance in the Compute service +- Support for specifying a Key Management service key when backing up or restoring a block storage volume in the Block Volume service + ## 1.2.46 - 2018-09-06 ### Added - Support for updating metadata fields on an instance in the Compute service diff --git a/bmc-addons/bmc-apache-connector-provider/pom.xml b/bmc-addons/bmc-apache-connector-provider/pom.xml index c88b7e0a4be..01248c0b05b 100644 --- a/bmc-addons/bmc-apache-connector-provider/pom.xml +++ b/bmc-addons/bmc-apache-connector-provider/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk-addons - 1.2.46 + 1.2.47 ../pom.xml @@ -37,7 +37,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-addons/pom.xml b/bmc-addons/pom.xml index 4c27b8aa87c..8765422dde2 100644 --- a/bmc-addons/pom.xml +++ b/bmc-addons/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml diff --git a/bmc-audit/pom.xml b/bmc-audit/pom.xml index e2da25520d4..adec112bb28 100644 --- a/bmc-audit/pom.xml +++ b/bmc-audit/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-audit/src/main/java/com/oracle/bmc/audit/AuditAsyncClient.java b/bmc-audit/src/main/java/com/oracle/bmc/audit/AuditAsyncClient.java index c14c21c79f8..67e917c35ac 100644 --- a/bmc-audit/src/main/java/com/oracle/bmc/audit/AuditAsyncClient.java +++ b/bmc-audit/src/main/java/com/oracle/bmc/audit/AuditAsyncClient.java @@ -15,7 +15,10 @@ public class AuditAsyncClient implements AuditAsync { * Service instance for Audit. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("AUDIT", "audit"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("AUDIT") + .serviceEndpointPrefix("audit") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-audit/src/main/java/com/oracle/bmc/audit/AuditClient.java b/bmc-audit/src/main/java/com/oracle/bmc/audit/AuditClient.java index 1e8765d319f..2b0a4f0674a 100644 --- a/bmc-audit/src/main/java/com/oracle/bmc/audit/AuditClient.java +++ b/bmc-audit/src/main/java/com/oracle/bmc/audit/AuditClient.java @@ -15,7 +15,10 @@ public class AuditClient implements Audit { * Service instance for Audit. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("AUDIT", "audit"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("AUDIT") + .serviceEndpointPrefix("audit") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-bom/pom.xml b/bmc-bom/pom.xml index 857290ac9a0..7630c0e2640 100644 --- a/bmc-bom/pom.xml +++ b/bmc-bom/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml oci-java-sdk-bom @@ -19,83 +19,88 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-audit - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-containerengine - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-core - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-database - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-dns - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-email - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-filestorage - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-identity - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-loadbalancer - 1.2.46 + 1.2.47 false com.oracle.oci.sdk oci-java-sdk-objectstorage - 1.2.46 + 1.2.47 false - pom com.oracle.oci.sdk oci-java-sdk-resourcesearch false - 1.2.46 + 1.2.47 com.oracle.oci.sdk false oci-java-sdk-addons-apache - 1.2.46 + 1.2.47 + + + com.oracle.oci.sdk + oci-java-sdk-keymanagement + 1.2.47 + false - + \ No newline at end of file diff --git a/bmc-common/pom.xml b/bmc-common/pom.xml index 5216a589514..e5f7c7a1d3c 100644 --- a/bmc-common/pom.xml +++ b/bmc-common/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml diff --git a/bmc-common/src/main/java/com/oracle/bmc/Region.java b/bmc-common/src/main/java/com/oracle/bmc/Region.java index 668b36d0a3c..b7522a2d480 100644 --- a/bmc-common/src/main/java/com/oracle/bmc/Region.java +++ b/bmc-common/src/main/java/com/oracle/bmc/Region.java @@ -13,6 +13,7 @@ import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; /** * Enumeration of all of the known Regions that can be contacted. @@ -98,6 +99,9 @@ public synchronized Optional getEndpoint(Service service) { * @return The endpoint. */ public static String formatDefaultRegionEndpoint(Service service, String regionId) { + if (StringUtils.isNotBlank(service.getServiceEndpointTemplate())) { + return service.getServiceEndpointTemplate().replace("{region}", regionId); + } return String.format(DEFAULT_ENDPOINT_FORMAT, service.getServiceEndpointPrefix(), regionId); } diff --git a/bmc-common/src/main/java/com/oracle/bmc/Service.java b/bmc-common/src/main/java/com/oracle/bmc/Service.java index 39b9df33322..4e8be01dabd 100644 --- a/bmc-common/src/main/java/com/oracle/bmc/Service.java +++ b/bmc-common/src/main/java/com/oracle/bmc/Service.java @@ -21,4 +21,10 @@ public interface Service { * "https://iaas.us-phoenix-1.oraclecloud.com". */ String getServiceEndpointPrefix(); + + /** + * The service endpoint template that will be used, ex + * "{region}.service.oci.oraclecloud.com" + */ + String getServiceEndpointTemplate(); } diff --git a/bmc-common/src/main/java/com/oracle/bmc/Services.java b/bmc-common/src/main/java/com/oracle/bmc/Services.java index ffb9ade358b..1efebd91c81 100644 --- a/bmc-common/src/main/java/com/oracle/bmc/Services.java +++ b/bmc-common/src/main/java/com/oracle/bmc/Services.java @@ -6,9 +6,9 @@ import java.util.HashMap; import java.util.Map; -import lombok.Getter; -import lombok.RequiredArgsConstructor; -import lombok.ToString; +import lombok.Builder; +import lombok.Value; +import org.apache.commons.lang3.Validate; /** * Factory class to create new {@link Service} instances. @@ -28,31 +28,44 @@ public class Services { * @param serviceName The unique service name. * @param serviceEndpointPrefix The endpoint prefix. * @return A Service instance. + * @deprecated Use {@link #serviceBuilder()} instead */ - public static synchronized Service create( - final String serviceName, final String serviceEndpointPrefix) { + @Deprecated + public static Service create(final String serviceName, final String serviceEndpointPrefix) { + return serviceBuilder() + .serviceName(serviceName) + .serviceEndpointPrefix(serviceEndpointPrefix) + .build(); + } + + @Builder(builderClassName = "ServiceBuilder", builderMethodName = "serviceBuilder") + private static synchronized Service create( + final String serviceName, + final String serviceEndpointPrefix, + final String serviceEndpointTemplate) { + Validate.notBlank(serviceName); + final Service newInstance = + new BasicService(serviceName, serviceEndpointPrefix, serviceEndpointTemplate); if (SERVICE_CACHE.containsKey(serviceName)) { Service existing = SERVICE_CACHE.get(serviceName); - if (existing.getServiceEndpointPrefix().equals(serviceEndpointPrefix)) { + if (existing.equals(newInstance)) { return existing; } throw new IllegalArgumentException( String.format( - "Cannot redefine service '%s' with with new endpoint prefix '%s', already set to '%s'", + "Cannot redefine service '%s'. Existing: '%s', New: '%s'", serviceName, - serviceEndpointPrefix, - existing.getServiceEndpointPrefix())); + existing, + newInstance)); } - Service newInstance = new BasicService(serviceName, serviceEndpointPrefix); SERVICE_CACHE.put(serviceName, newInstance); return newInstance; } - @RequiredArgsConstructor - @Getter - @ToString + @Value private static final class BasicService implements Service { private final String serviceName; private final String serviceEndpointPrefix; + private final String serviceEndpointTemplate; } } diff --git a/bmc-common/src/main/java/com/oracle/bmc/auth/InstancePrincipalsAuthenticationDetailsProvider.java b/bmc-common/src/main/java/com/oracle/bmc/auth/InstancePrincipalsAuthenticationDetailsProvider.java index 19b360dfcfe..dde9e995803 100644 --- a/bmc-common/src/main/java/com/oracle/bmc/auth/InstancePrincipalsAuthenticationDetailsProvider.java +++ b/bmc-common/src/main/java/com/oracle/bmc/auth/InstancePrincipalsAuthenticationDetailsProvider.java @@ -78,7 +78,10 @@ public static class InstancePrincipalsAuthenticationDetailsProviderBuilder * Service instance for auth. */ private static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("AUTH", "auth"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("AUTH") + .serviceEndpointPrefix("auth") + .build(); /** * Base url of metadata service. diff --git a/bmc-common/src/main/java/com/oracle/bmc/http/signing/internal/RequestSignerImpl.java b/bmc-common/src/main/java/com/oracle/bmc/http/signing/internal/RequestSignerImpl.java index 221efb34df8..98bd786de10 100644 --- a/bmc-common/src/main/java/com/oracle/bmc/http/signing/internal/RequestSignerImpl.java +++ b/bmc-common/src/main/java/com/oracle/bmc/http/signing/internal/RequestSignerImpl.java @@ -3,6 +3,27 @@ */ package com.oracle.bmc.http.signing.internal; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.base.Supplier; +import com.google.common.collect.ImmutableList; +import com.google.common.hash.Hashing; +import com.google.common.io.ByteStreams; +import com.oracle.bmc.http.internal.RestClientFactory; +import com.oracle.bmc.http.signing.RequestSigner; +import com.oracle.bmc.http.signing.RequestSignerException; +import com.oracle.bmc.http.signing.SigningStrategy; +import com.oracle.bmc.io.DuplicatableInputStream; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import javax.annotation.concurrent.Immutable; import java.io.IOException; import java.io.InputStream; import java.net.URI; @@ -18,29 +39,6 @@ import java.util.Map.Entry; import java.util.TimeZone; -import javax.annotation.Nonnull; -import javax.annotation.Nullable; -import javax.annotation.concurrent.Immutable; - -import com.google.common.annotations.VisibleForTesting; -import com.google.common.io.ByteStreams; -import com.oracle.bmc.http.signing.RequestSignerException; -import com.oracle.bmc.io.DuplicatableInputStream; -import org.apache.commons.codec.binary.Base64; -import org.apache.commons.lang3.StringUtils; - -import com.fasterxml.jackson.core.JsonProcessingException; -import com.google.common.base.Optional; -import com.google.common.base.Preconditions; -import com.google.common.base.Supplier; -import com.google.common.hash.Hashing; -import com.oracle.bmc.http.internal.RestClientFactory; -import com.oracle.bmc.http.signing.RequestSigner; -import com.oracle.bmc.http.signing.SigningStrategy; - -import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; - /** * Implementation of the {@linkplain RequestSigner} interface *

@@ -141,7 +139,7 @@ private Map signRequest( final List requiredHeaders = getRequiredSigningHeaders(lowerHttpMethod); // 2) copy of original headers as case-insensitive, do not modify input map - final Map existingHeaders = ignoreCaseHeaders(headers); + final Map> existingHeaders = ignoreCaseHeaders(headers); // 3) calculate any required headers that are missing final Map missingHeaders = @@ -154,13 +152,16 @@ private Map signRequest( signingConfiguration); // 4) create a map containing both existing + missing headers - final Map allHeaders = new HashMap<>(); + final Map> allHeaders = new HashMap<>(); allHeaders.putAll(existingHeaders); - allHeaders.putAll(missingHeaders); + for (Map.Entry e : missingHeaders.entrySet()) { + allHeaders.put(e.getKey(), ImmutableList.of(e.getValue())); + } // 5) calculate the signature final String stringToSign = - calculateStringToSign(lowerHttpMethod, path, allHeaders, requiredHeaders); + calculateStringToSign( + lowerHttpMethod, path, allHeaders, requiredHeaders, headers); final String signature = sign(key, algorithm, stringToSign); // 6) calculate the auth header and add to all the missing headers that should be added @@ -217,22 +218,11 @@ private RSAPrivateKey getPrivateKey(String keyId) { } @VisibleForTesting - static Map ignoreCaseHeaders(Map> originalHeaders) { - Map transformedMap = new HashMap<>(); + static Map> ignoreCaseHeaders( + final Map> originalHeaders) { + Map> transformedMap = new HashMap<>(); for (Entry> entry : originalHeaders.entrySet()) { - if (entry.getValue().size() != 1) { - final String headerKey = entry.getKey(); - final RequestSignerException exception = - new RequestSignerException( - "Expecting exactly one value for header " + headerKey); - LOG.error( - "More than one value for header [{}] found. All headers: {}", - headerKey, - transformHeadersToJsonString(originalHeaders), - exception); - throw exception; - } - transformedMap.put(entry.getKey().toLowerCase(Locale.ROOT), entry.getValue().get(0)); + transformedMap.put(entry.getKey().toLowerCase(), entry.getValue()); } return transformedMap; } @@ -258,7 +248,7 @@ private static String extractPath(URI uri) { static Map calculateMissingHeaders( final String httpMethod, final URI uri, - final Map existingHeaders, + final Map> existingHeaders, final Object body, final List requiredHeaders, final SigningConfiguration signingConfiguration) @@ -305,6 +295,16 @@ static Map calculateMissingHeaders( if (!existingHeaders.containsKey(Constants.CONTENT_TYPE)) { LOG.warn("Missing 'content-type' header, defaulting to 'application/json'"); missingHeaders.put(Constants.CONTENT_TYPE, Constants.JSON_CONTENT_TYPE); + } else { + List contentTypes = existingHeaders.get(Constants.CONTENT_TYPE); + if (contentTypes.size() != 1) { + throw new IllegalArgumentException( + "Expected exactly one '" + + Constants.CONTENT_TYPE + + " header (received " + + contentTypes.size() + + ")"); + } } } @@ -320,7 +320,7 @@ static Map calculateMissingHeaders( } private static boolean isRequiredHeaderMissing( - String headerName, List requiredHeaders, Map existingHeaders) { + String headerName, List requiredHeaders, Map existingHeaders) { return requiredHeaders.contains(headerName) && !existingHeaders.containsKey(headerName); } @@ -329,11 +329,13 @@ private static String calculateBodySHA256(final byte[] body) { return base64Encode(hash); } - private String calculateStringToSign( + @VisibleForTesting + static String calculateStringToSign( String httpMethod, String path, - Map allHeaders, - List requiredHeaders) { + Map> allHeaders, + List requiredHeaders, + Map> originalHeaders) { // Header name and value are separated with ": " and each (name, value) // pair is separated with "\n" @@ -342,13 +344,38 @@ private String calculateStringToSign( // Use the order from requiredHeaders, which must match the order // when creating the authorization header for (String headerName : requiredHeaders) { - String headerValue = allHeaders.get(headerName); + List headerValues = allHeaders.get(headerName); + if (headerValues != null && headerValues.size() != 1) { + final RequestSignerException exception = + new RequestSignerException( + "Expecting exactly one value for header " + headerName); + LOG.error( + "More than one value for header [{}] to be signed found. All headers: {}", + headerName, + transformHeadersToJsonString(originalHeaders), + exception); + throw exception; + } + String headerValue = (headerValues != null) ? headerValues.get(0) : null; if (headerName.equals(Constants.REQUEST_TARGET)) { // Manually compute pseudo-header (request-target), since it // won't be in headers headerValue = httpMethod + " " + path; } + + if (headerValue == null) { + final RequestSignerException exception = + new RequestSignerException( + "Expecting exactly one value for header " + headerName); + LOG.error( + "No header value for header [{}] to be signed found. All headers: {}", + headerName, + transformHeadersToJsonString(originalHeaders), + exception); + throw exception; + } + signatureParts.add(String.format("%s: %s", headerName, headerValue)); } diff --git a/bmc-common/src/test/java/com/oracle/bmc/ServicesTest.java b/bmc-common/src/test/java/com/oracle/bmc/ServicesTest.java new file mode 100644 index 00000000000..94a4c5acc10 --- /dev/null +++ b/bmc-common/src/test/java/com/oracle/bmc/ServicesTest.java @@ -0,0 +1,54 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc; + +import org.junit.BeforeClass; +import org.junit.Test; + +public class ServicesTest { + + @BeforeClass + public static void setup() { + final Service fooService = + Services.serviceBuilder().serviceName("FOO").serviceEndpointPrefix("foo").build(); + } + + @Test + public void addNewService() { + final Service newService = + Services.serviceBuilder().serviceName("NEW").serviceEndpointPrefix("new").build(); + } + + @Test + public void addExistingService() { + final Service fooService = + Services.serviceBuilder().serviceName("FOO").serviceEndpointPrefix("foo").build(); + } + + @Test(expected = IllegalArgumentException.class) + public void addExistingService_ConflictingEndpointPrefix() { + final Service fooService = + Services.serviceBuilder().serviceName("FOO").serviceEndpointPrefix("bar").build(); + } + + @Test(expected = IllegalArgumentException.class) + public void addExistingService_ConflictingEndpointTemplate() { + final Service fooService = + Services.serviceBuilder() + .serviceName("FOO") + .serviceEndpointPrefix("foo") + .serviceEndpointTemplate("{region}.foo.oci.oraclecloud.com") + .build(); + } + + @Test(expected = NullPointerException.class) + public void addService_NoName() { + final Service noNameService = Services.serviceBuilder().build(); + } + + @Test(expected = IllegalArgumentException.class) + public void addService_BlankName() { + final Service blankNameService = Services.serviceBuilder().serviceName("").build(); + } +} diff --git a/bmc-common/src/test/java/com/oracle/bmc/http/signing/internal/RequestSignerImplTest.java b/bmc-common/src/test/java/com/oracle/bmc/http/signing/internal/RequestSignerImplTest.java index 53fc57154e1..bbfdc2c431c 100644 --- a/bmc-common/src/test/java/com/oracle/bmc/http/signing/internal/RequestSignerImplTest.java +++ b/bmc-common/src/test/java/com/oracle/bmc/http/signing/internal/RequestSignerImplTest.java @@ -4,6 +4,7 @@ package com.oracle.bmc.http.signing.internal; import com.fasterxml.jackson.databind.ObjectMapper; +import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Lists; import com.google.common.io.ByteStreams; @@ -14,7 +15,6 @@ import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.ArgumentCaptor; import org.mockito.Mock; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; @@ -40,8 +40,6 @@ import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; -import static org.mockito.Mockito.verify; import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.when; @@ -77,18 +75,18 @@ public void ignoreCaseHeaders_shouldReturnMapWithLowerCaseKeys_whenHeadersContai headers.put("Content-Type", Collections.singletonList(MediaType.APPLICATION_JSON)); headers.put("OPC-REQUEST-ID", Collections.singletonList("RequestID")); - final Map actual = RequestSignerImpl.ignoreCaseHeaders(headers); + final Map> actual = RequestSignerImpl.ignoreCaseHeaders(headers); assertNotNull("Map should not be null", actual); assertEquals("Map should contain 3 entries", 3, actual.size()); for (Map.Entry> expectedEntry : headers.entrySet()) { final String expectedKey = expectedEntry.getKey(); - final String expectedValue = expectedEntry.getValue().get(0); + final List expectedValue = expectedEntry.getValue(); assertTrue( "Actual map should contain matching key for lower case value", actual.containsKey(expectedKey.toLowerCase())); - final String actualValue = actual.get(expectedKey.toLowerCase()); + final List actualValue = actual.get(expectedKey.toLowerCase()); assertEquals( "Values should be equal for key: " + expectedKey, expectedValue, actualValue); } @@ -97,34 +95,42 @@ public void ignoreCaseHeaders_shouldReturnMapWithLowerCaseKeys_whenHeadersContai // Reload the classes so PowerMockito can inject the static mocks. @PrepareForTest({LoggerFactory.class, RestClientFactory.class, RequestSignerImpl.class}) @Test - public void ignoreCaseHeaders_shouldThrowRequestSignerException_whenDuplicateHeaderKeysExists() - throws Exception { + public void ignoreCaseHeaders_whenDuplicateHeaderKeysExists() throws Exception { final Map> headers = new HashMap<>(); headers.put("content-length", Collections.singletonList("238")); headers.put("opc-request-id", Lists.newArrayList("ID1", "ID2")); - try { - RequestSignerImpl.ignoreCaseHeaders(headers); - fail("RequestSignerException should have been thrown"); - } catch (RequestSignerException ex) { - assertTrue( - "Exception message should contain key with duplicate entries", - ex.getMessage() - .contains("Expecting exactly one value for header opc-request-id")); - verify(mockObjectMapper).writeValueAsString(eq(headers)); - - final ArgumentCaptor logMessageCaptor = ArgumentCaptor.forClass(String.class); - verify(mockLogger) - .error( - logMessageCaptor.capture(), - eq("opc-request-id"), - eq(SERIALIZED_MAP_JSON_STRING), - eq(ex)); - - final String actaulLogMessageValue = logMessageCaptor.getValue(); + final Map> actual = RequestSignerImpl.ignoreCaseHeaders(headers); + + assertNotNull("Map should not be null", actual); + assertEquals("Map should contain 2 entries", 2, actual.size()); + for (Map.Entry> expectedEntry : headers.entrySet()) { + final String expectedKey = expectedEntry.getKey(); + final List expectedValue = expectedEntry.getValue(); + assertTrue( - "Logging messages should contain the base message", - actaulLogMessageValue.contains("More than one value for header [{}] found.")); + "Actual map should contain matching key for lower case value", + actual.containsKey(expectedKey.toLowerCase())); + final List actualValue = actual.get(expectedKey.toLowerCase()); + assertEquals( + "Values should be equal for key: " + expectedKey, expectedValue, actualValue); + } + } + + // Reload the classes so PowerMockito can inject the static mocks. + @PrepareForTest({LoggerFactory.class, RestClientFactory.class, RequestSignerImpl.class}) + @Test + public void calculateStringToSign_whenDuplicateHeaderKeysExists() { + final Map> headers = new HashMap<>(); + headers.put("content-length", Collections.singletonList("238")); + headers.put("opc-request-id", Lists.newArrayList("ID1", "ID2")); + + try { + RequestSignerImpl.calculateStringToSign( + "get", "/path", headers, ImmutableList.of("opc-request-id"), headers); + fail("Should have thrown"); + } catch (RequestSignerException e) { + assertEquals("Expecting exactly one value for header opc-request-id", e.getMessage()); } } @@ -180,14 +186,14 @@ private void calculateAndVerifyMissingHeaders( final String contentType, final Object body, final int contentLength) throws IOException { final URI uri = URI.create("https://identity.us-phoenix-1.oraclecloud.com/20160918/users"); - final Map existingHeaders = - ImmutableMap.of( + final Map> existingHeaders = + ImmutableMap.>of( HttpHeaders.CONTENT_TYPE.toLowerCase(), - contentType, + ImmutableList.of(contentType), "opc-request-id", - "2F9BA4A30BB3452397A5BC1BFE447C5D", + ImmutableList.of("2F9BA4A30BB3452397A5BC1BFE447C5D"), HttpHeaders.ACCEPT.toLowerCase(), - MediaType.APPLICATION_JSON); + ImmutableList.of(MediaType.APPLICATION_JSON)); final RequestSignerImpl.SigningConfiguration signingConfiguration = new RequestSignerImpl.SigningConfiguration( SigningStrategy.STANDARD.getHeadersToSign(), diff --git a/bmc-containerengine/pom.xml b/bmc-containerengine/pom.xml index ecef3863e91..97ae78d6fe4 100644 --- a/bmc-containerengine/pom.xml +++ b/bmc-containerengine/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-containerengine/src/main/java/com/oracle/bmc/containerengine/ContainerEngineAsyncClient.java b/bmc-containerengine/src/main/java/com/oracle/bmc/containerengine/ContainerEngineAsyncClient.java index 84deb5ace46..d263fbcdabd 100644 --- a/bmc-containerengine/src/main/java/com/oracle/bmc/containerengine/ContainerEngineAsyncClient.java +++ b/bmc-containerengine/src/main/java/com/oracle/bmc/containerengine/ContainerEngineAsyncClient.java @@ -15,7 +15,10 @@ public class ContainerEngineAsyncClient implements ContainerEngineAsync { * Service instance for ContainerEngine. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("CONTAINERENGINE", "containerengine"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("CONTAINERENGINE") + .serviceEndpointPrefix("containerengine") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-containerengine/src/main/java/com/oracle/bmc/containerengine/ContainerEngineClient.java b/bmc-containerengine/src/main/java/com/oracle/bmc/containerengine/ContainerEngineClient.java index 833bdd88969..ff8ae01c6d9 100644 --- a/bmc-containerengine/src/main/java/com/oracle/bmc/containerengine/ContainerEngineClient.java +++ b/bmc-containerengine/src/main/java/com/oracle/bmc/containerengine/ContainerEngineClient.java @@ -15,7 +15,10 @@ public class ContainerEngineClient implements ContainerEngine { * Service instance for ContainerEngine. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("CONTAINERENGINE", "containerengine"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("CONTAINERENGINE") + .serviceEndpointPrefix("containerengine") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-core/pom.xml b/bmc-core/pom.xml index 2c1dab68280..6ae99ad6abb 100644 --- a/bmc-core/pom.xml +++ b/bmc-core/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/Blockstorage.java b/bmc-core/src/main/java/com/oracle/bmc/core/Blockstorage.java index 70465a97cf6..5301d6ea2b7 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/Blockstorage.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/Blockstorage.java @@ -155,6 +155,15 @@ CreateVolumeBackupPolicyAssignmentResponse createVolumeBackupPolicyAssignment( */ DeleteBootVolumeBackupResponse deleteBootVolumeBackup(DeleteBootVolumeBackupRequest request); + /** + * Remove kms for the specific boot volume. If the volume doesn't use KMS, then do nothing. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + DeleteBootVolumeKmsKeyResponse deleteBootVolumeKmsKey(DeleteBootVolumeKmsKeyRequest request); + /** * Deletes the specified volume. The volume cannot have an active connection to an instance. * To disconnect the volume from a connected instance, see @@ -202,6 +211,15 @@ DeleteVolumeBackupPolicyAssignmentResponse deleteVolumeBackupPolicyAssignment( */ DeleteVolumeGroupBackupResponse deleteVolumeGroupBackup(DeleteVolumeGroupBackupRequest request); + /** + * Remove kms for the specific volume. If the volume doesn't use KMS, then do nothing. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + DeleteVolumeKmsKeyResponse deleteVolumeKmsKey(DeleteVolumeKmsKeyRequest request); + /** * Gets information for the specified boot volume. * @param request The request object containing the details to send @@ -218,6 +236,15 @@ DeleteVolumeBackupPolicyAssignmentResponse deleteVolumeBackupPolicyAssignment( */ GetBootVolumeBackupResponse getBootVolumeBackup(GetBootVolumeBackupRequest request); + /** + * Gets kms key id for the specified boot volume. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + GetBootVolumeKmsKeyResponse getBootVolumeKmsKey(GetBootVolumeKmsKeyRequest request); + /** * Gets information for the specified volume. * @param request The request object containing the details to send @@ -279,6 +306,15 @@ GetVolumeBackupPolicyAssignmentResponse getVolumeBackupPolicyAssignment( */ GetVolumeGroupBackupResponse getVolumeGroupBackup(GetVolumeGroupBackupRequest request); + /** + * Gets kms key id for the specified volume. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + GetVolumeKmsKeyResponse getVolumeKmsKey(GetVolumeKmsKeyRequest request); + /** * Lists the boot volume backups in the specified compartment. You can filter the results by boot volume. * @@ -362,6 +398,15 @@ ListVolumeBackupPoliciesResponse listVolumeBackupPolicies( */ UpdateBootVolumeBackupResponse updateBootVolumeBackup(UpdateBootVolumeBackupRequest request); + /** + * Update kms key id for the specific volume. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + UpdateBootVolumeKmsKeyResponse updateBootVolumeKmsKey(UpdateBootVolumeKmsKeyRequest request); + /** * Updates the specified volume's display name. * Avoid entering confidential information. @@ -404,6 +449,15 @@ ListVolumeBackupPoliciesResponse listVolumeBackupPolicies( */ UpdateVolumeGroupBackupResponse updateVolumeGroupBackup(UpdateVolumeGroupBackupRequest request); + /** + * Update kms key id for the specific volume. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + UpdateVolumeKmsKeyResponse updateVolumeKmsKey(UpdateVolumeKmsKeyRequest request); + /** * Gets the pre-configured waiters available for resources for this service. * diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageAsync.java b/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageAsync.java index 33cce1e0007..d59a7c2e572 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageAsync.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageAsync.java @@ -225,6 +225,23 @@ java.util.concurrent.Future deleteBootVolumeBack DeleteBootVolumeBackupRequest, DeleteBootVolumeBackupResponse> handler); + /** + * Remove kms for the specific boot volume. If the volume doesn't use KMS, then do nothing. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future deleteBootVolumeKmsKey( + DeleteBootVolumeKmsKeyRequest request, + com.oracle.bmc.responses.AsyncHandler< + DeleteBootVolumeKmsKeyRequest, DeleteBootVolumeKmsKeyResponse> + handler); + /** * Deletes the specified volume. The volume cannot have an active connection to an instance. * To disconnect the volume from a connected instance, see @@ -312,6 +329,23 @@ java.util.concurrent.Future deleteVolumeGroupBa DeleteVolumeGroupBackupRequest, DeleteVolumeGroupBackupResponse> handler); + /** + * Remove kms for the specific volume. If the volume doesn't use KMS, then do nothing. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future deleteVolumeKmsKey( + DeleteVolumeKmsKeyRequest request, + com.oracle.bmc.responses.AsyncHandler< + DeleteVolumeKmsKeyRequest, DeleteVolumeKmsKeyResponse> + handler); + /** * Gets information for the specified boot volume. * @@ -343,6 +377,23 @@ java.util.concurrent.Future getBootVolumeBackup( GetBootVolumeBackupRequest, GetBootVolumeBackupResponse> handler); + /** + * Gets kms key id for the specified boot volume. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future getBootVolumeKmsKey( + GetBootVolumeKmsKeyRequest request, + com.oracle.bmc.responses.AsyncHandler< + GetBootVolumeKmsKeyRequest, GetBootVolumeKmsKeyResponse> + handler); + /** * Gets information for the specified volume. * @@ -458,6 +509,22 @@ java.util.concurrent.Future getVolumeGroupBackup( GetVolumeGroupBackupRequest, GetVolumeGroupBackupResponse> handler); + /** + * Gets kms key id for the specified volume. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future getVolumeKmsKey( + GetVolumeKmsKeyRequest request, + com.oracle.bmc.responses.AsyncHandler + handler); + /** * Lists the boot volume backups in the specified compartment. You can filter the results by boot volume. * @@ -607,6 +674,23 @@ java.util.concurrent.Future updateBootVolumeBack UpdateBootVolumeBackupRequest, UpdateBootVolumeBackupResponse> handler); + /** + * Update kms key id for the specific volume. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future updateBootVolumeKmsKey( + UpdateBootVolumeKmsKeyRequest request, + com.oracle.bmc.responses.AsyncHandler< + UpdateBootVolumeKmsKeyRequest, UpdateBootVolumeKmsKeyResponse> + handler); + /** * Updates the specified volume's display name. * Avoid entering confidential information. @@ -679,4 +763,21 @@ java.util.concurrent.Future updateVolumeGroupBa com.oracle.bmc.responses.AsyncHandler< UpdateVolumeGroupBackupRequest, UpdateVolumeGroupBackupResponse> handler); + + /** + * Update kms key id for the specific volume. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future updateVolumeKmsKey( + UpdateVolumeKmsKeyRequest request, + com.oracle.bmc.responses.AsyncHandler< + UpdateVolumeKmsKeyRequest, UpdateVolumeKmsKeyResponse> + handler); } diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageAsyncClient.java b/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageAsyncClient.java index d330bf3d0e3..7ec5b89bb1a 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageAsyncClient.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageAsyncClient.java @@ -15,7 +15,10 @@ public class BlockstorageAsyncClient implements BlockstorageAsync { * Service instance for Blockstorage. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("BLOCKSTORAGE", "iaas"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("BLOCKSTORAGE") + .serviceEndpointPrefix("iaas") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; @@ -1024,6 +1027,77 @@ public java.util.concurrent.Future get() { } } + @Override + public java.util.concurrent.Future deleteBootVolumeKmsKey( + final DeleteBootVolumeKmsKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler< + DeleteBootVolumeKmsKeyRequest, DeleteBootVolumeKmsKeyResponse> + handler) { + LOG.trace("Called async deleteBootVolumeKmsKey"); + final DeleteBootVolumeKmsKeyRequest interceptedRequest = + DeleteBootVolumeKmsKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + DeleteBootVolumeKmsKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function< + javax.ws.rs.core.Response, DeleteBootVolumeKmsKeyResponse> + transformer = DeleteBootVolumeKmsKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler< + DeleteBootVolumeKmsKeyRequest, DeleteBootVolumeKmsKeyResponse> + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + DeleteBootVolumeKmsKeyRequest, DeleteBootVolumeKmsKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.delete(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.delete(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, DeleteBootVolumeKmsKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.delete(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + @Override public java.util.concurrent.Future deleteVolume( final DeleteVolumeRequest request, @@ -1376,6 +1450,75 @@ public java.util.concurrent.Future get() { } } + @Override + public java.util.concurrent.Future deleteVolumeKmsKey( + final DeleteVolumeKmsKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler< + DeleteVolumeKmsKeyRequest, DeleteVolumeKmsKeyResponse> + handler) { + LOG.trace("Called async deleteVolumeKmsKey"); + final DeleteVolumeKmsKeyRequest interceptedRequest = + DeleteVolumeKmsKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + DeleteVolumeKmsKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = DeleteVolumeKmsKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + DeleteVolumeKmsKeyRequest, DeleteVolumeKmsKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.delete(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.delete(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, DeleteVolumeKmsKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.delete(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + @Override public java.util.concurrent.Future getBootVolume( final GetBootVolumeRequest request, @@ -1515,6 +1658,77 @@ public java.util.concurrent.Future get() { } } + @Override + public java.util.concurrent.Future getBootVolumeKmsKey( + final GetBootVolumeKmsKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler< + GetBootVolumeKmsKeyRequest, GetBootVolumeKmsKeyResponse> + handler) { + LOG.trace("Called async getBootVolumeKmsKey"); + final GetBootVolumeKmsKeyRequest interceptedRequest = + GetBootVolumeKmsKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetBootVolumeKmsKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function< + javax.ws.rs.core.Response, GetBootVolumeKmsKeyResponse> + transformer = GetBootVolumeKmsKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler< + GetBootVolumeKmsKeyRequest, GetBootVolumeKmsKeyResponse> + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + GetBootVolumeKmsKeyRequest, GetBootVolumeKmsKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.get(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.get(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, GetBootVolumeKmsKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.get(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + @Override public java.util.concurrent.Future getVolume( final GetVolumeRequest request, @@ -2013,6 +2227,75 @@ public java.util.concurrent.Future get() { } } + @Override + public java.util.concurrent.Future getVolumeKmsKey( + final GetVolumeKmsKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler< + GetVolumeKmsKeyRequest, GetVolumeKmsKeyResponse> + handler) { + LOG.trace("Called async getVolumeKmsKey"); + final GetVolumeKmsKeyRequest interceptedRequest = + GetVolumeKmsKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetVolumeKmsKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = GetVolumeKmsKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + GetVolumeKmsKeyRequest, GetVolumeKmsKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.get(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.get(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, GetVolumeKmsKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.get(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + @Override public java.util.concurrent.Future listBootVolumeBackups( final ListBootVolumeBackupsRequest request, @@ -2671,6 +2954,92 @@ public java.util.concurrent.Future get() { } } + @Override + public java.util.concurrent.Future updateBootVolumeKmsKey( + final UpdateBootVolumeKmsKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler< + UpdateBootVolumeKmsKeyRequest, UpdateBootVolumeKmsKeyResponse> + handler) { + LOG.trace("Called async updateBootVolumeKmsKey"); + final UpdateBootVolumeKmsKeyRequest interceptedRequest = + UpdateBootVolumeKmsKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + UpdateBootVolumeKmsKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function< + javax.ws.rs.core.Response, UpdateBootVolumeKmsKeyResponse> + transformer = UpdateBootVolumeKmsKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler< + UpdateBootVolumeKmsKeyRequest, UpdateBootVolumeKmsKeyResponse> + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + UpdateBootVolumeKmsKeyRequest, UpdateBootVolumeKmsKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.put( + ib, + interceptedRequest.getUpdateBootVolumeKmsKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.put( + ib, + interceptedRequest.getUpdateBootVolumeKmsKeyDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, UpdateBootVolumeKmsKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.put( + ib, + interceptedRequest.getUpdateBootVolumeKmsKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + @Override public java.util.concurrent.Future updateVolume( final UpdateVolumeRequest request, @@ -3007,4 +3376,88 @@ public java.util.concurrent.Future get() { responseFuture, transformer); } } + + @Override + public java.util.concurrent.Future updateVolumeKmsKey( + final UpdateVolumeKmsKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler< + UpdateVolumeKmsKeyRequest, UpdateVolumeKmsKeyResponse> + handler) { + LOG.trace("Called async updateVolumeKmsKey"); + final UpdateVolumeKmsKeyRequest interceptedRequest = + UpdateVolumeKmsKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + UpdateVolumeKmsKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = UpdateVolumeKmsKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + UpdateVolumeKmsKeyRequest, UpdateVolumeKmsKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.put( + ib, + interceptedRequest.getUpdateVolumeKmsKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.put( + ib, + interceptedRequest.getUpdateVolumeKmsKeyDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, UpdateVolumeKmsKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.put( + ib, + interceptedRequest.getUpdateVolumeKmsKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } } diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageClient.java b/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageClient.java index 5529e47fba6..18759169728 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageClient.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/BlockstorageClient.java @@ -15,7 +15,10 @@ public class BlockstorageClient implements Blockstorage { * Service instance for Blockstorage. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("BLOCKSTORAGE", "iaas"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("BLOCKSTORAGE") + .serviceEndpointPrefix("iaas") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; @@ -548,6 +551,32 @@ && canRetryRequestIfRefreshableAuthTokenUsed(e)) { } } + @Override + public DeleteBootVolumeKmsKeyResponse deleteBootVolumeKmsKey( + DeleteBootVolumeKmsKeyRequest request) { + LOG.trace("Called deleteBootVolumeKmsKey"); + request = DeleteBootVolumeKmsKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + DeleteBootVolumeKmsKeyConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = DeleteBootVolumeKmsKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.delete(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + @Override public DeleteVolumeResponse deleteVolume(DeleteVolumeRequest request) { LOG.trace("Called deleteVolume"); @@ -676,6 +705,31 @@ && canRetryRequestIfRefreshableAuthTokenUsed(e)) { } } + @Override + public DeleteVolumeKmsKeyResponse deleteVolumeKmsKey(DeleteVolumeKmsKeyRequest request) { + LOG.trace("Called deleteVolumeKmsKey"); + request = DeleteVolumeKmsKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + DeleteVolumeKmsKeyConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = DeleteVolumeKmsKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.delete(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + @Override public GetBootVolumeResponse getBootVolume(GetBootVolumeRequest request) { LOG.trace("Called getBootVolume"); @@ -726,6 +780,31 @@ && canRetryRequestIfRefreshableAuthTokenUsed(e)) { } } + @Override + public GetBootVolumeKmsKeyResponse getBootVolumeKmsKey(GetBootVolumeKmsKeyRequest request) { + LOG.trace("Called getBootVolumeKmsKey"); + request = GetBootVolumeKmsKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetBootVolumeKmsKeyConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = GetBootVolumeKmsKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.get(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + @Override public GetVolumeResponse getVolume(GetVolumeRequest request) { LOG.trace("Called getVolume"); @@ -906,6 +985,31 @@ && canRetryRequestIfRefreshableAuthTokenUsed(e)) { } } + @Override + public GetVolumeKmsKeyResponse getVolumeKmsKey(GetVolumeKmsKeyRequest request) { + LOG.trace("Called getVolumeKmsKey"); + request = GetVolumeKmsKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetVolumeKmsKeyConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = GetVolumeKmsKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.get(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + @Override public ListBootVolumeBackupsResponse listBootVolumeBackups( ListBootVolumeBackupsRequest request) { @@ -1137,6 +1241,33 @@ && canRetryRequestIfRefreshableAuthTokenUsed(e)) { } } + @Override + public UpdateBootVolumeKmsKeyResponse updateBootVolumeKmsKey( + UpdateBootVolumeKmsKeyRequest request) { + LOG.trace("Called updateBootVolumeKmsKey"); + request = UpdateBootVolumeKmsKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + UpdateBootVolumeKmsKeyConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = UpdateBootVolumeKmsKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.put(ib, request.getUpdateBootVolumeKmsKeyDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + @Override public UpdateVolumeResponse updateVolume(UpdateVolumeRequest request) { LOG.trace("Called updateVolume"); @@ -1242,6 +1373,32 @@ && canRetryRequestIfRefreshableAuthTokenUsed(e)) { } } + @Override + public UpdateVolumeKmsKeyResponse updateVolumeKmsKey(UpdateVolumeKmsKeyRequest request) { + LOG.trace("Called updateVolumeKmsKey"); + request = UpdateVolumeKmsKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + UpdateVolumeKmsKeyConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = UpdateVolumeKmsKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.put(ib, request.getUpdateVolumeKmsKeyDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + private boolean canRetryRequestIfRefreshableAuthTokenUsed(com.oracle.bmc.model.BmcException e) { if (e.getStatusCode() == 401 && this.authenticationDetailsProvider diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/ComputeAsyncClient.java b/bmc-core/src/main/java/com/oracle/bmc/core/ComputeAsyncClient.java index 2a65122ccd9..89d6174da05 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/ComputeAsyncClient.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/ComputeAsyncClient.java @@ -15,7 +15,10 @@ public class ComputeAsyncClient implements ComputeAsync { * Service instance for Compute. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("COMPUTE", "iaas"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("COMPUTE") + .serviceEndpointPrefix("iaas") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/ComputeClient.java b/bmc-core/src/main/java/com/oracle/bmc/core/ComputeClient.java index 40cc6b09f96..2909063debd 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/ComputeClient.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/ComputeClient.java @@ -15,7 +15,10 @@ public class ComputeClient implements Compute { * Service instance for Compute. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("COMPUTE", "iaas"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("COMPUTE") + .serviceEndpointPrefix("iaas") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/VirtualNetworkAsyncClient.java b/bmc-core/src/main/java/com/oracle/bmc/core/VirtualNetworkAsyncClient.java index 8d528f2eb45..79acb8dfca6 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/VirtualNetworkAsyncClient.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/VirtualNetworkAsyncClient.java @@ -15,7 +15,10 @@ public class VirtualNetworkAsyncClient implements VirtualNetworkAsync { * Service instance for VirtualNetwork. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("VIRTUALNETWORK", "iaas"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("VIRTUALNETWORK") + .serviceEndpointPrefix("iaas") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/VirtualNetworkClient.java b/bmc-core/src/main/java/com/oracle/bmc/core/VirtualNetworkClient.java index eb184728974..6d1f4941417 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/VirtualNetworkClient.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/VirtualNetworkClient.java @@ -15,7 +15,10 @@ public class VirtualNetworkClient implements VirtualNetwork { * Service instance for VirtualNetwork. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("VIRTUALNETWORK", "iaas"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("VIRTUALNETWORK") + .serviceEndpointPrefix("iaas") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/DeleteBootVolumeKmsKeyConverter.java b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/DeleteBootVolumeKmsKeyConverter.java new file mode 100644 index 00000000000..8562f6685ba --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/DeleteBootVolumeKmsKeyConverter.java @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.internal.http; + +import com.oracle.bmc.core.model.*; +import com.oracle.bmc.core.requests.*; +import com.oracle.bmc.core.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.extern.slf4j.Slf4j +public class DeleteBootVolumeKmsKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static DeleteBootVolumeKmsKeyRequest interceptRequest( + DeleteBootVolumeKmsKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, DeleteBootVolumeKmsKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getBootVolumeId(), "bootVolumeId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20160918") + .path("bootVolumes") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getBootVolumeId())) + .path("kmsKey"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, DeleteBootVolumeKmsKeyResponse> + fromResponse() { + final com.google.common.base.Function< + javax.ws.rs.core.Response, DeleteBootVolumeKmsKeyResponse> + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, DeleteBootVolumeKmsKeyResponse>() { + @Override + public DeleteBootVolumeKmsKeyResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace( + "Transform function invoked for DeleteBootVolumeKmsKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = RESPONSE_CONVERSION_FACTORY.create(); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + DeleteBootVolumeKmsKeyResponse.Builder builder = + DeleteBootVolumeKmsKeyResponse.builder(); + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + DeleteBootVolumeKmsKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/DeleteVolumeKmsKeyConverter.java b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/DeleteVolumeKmsKeyConverter.java new file mode 100644 index 00000000000..2eed6c04a10 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/DeleteVolumeKmsKeyConverter.java @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.internal.http; + +import com.oracle.bmc.core.model.*; +import com.oracle.bmc.core.requests.*; +import com.oracle.bmc.core.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.extern.slf4j.Slf4j +public class DeleteVolumeKmsKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static DeleteVolumeKmsKeyRequest interceptRequest(DeleteVolumeKmsKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, DeleteVolumeKmsKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getVolumeId(), "volumeId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20160918") + .path("volumes") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getVolumeId())) + .path("kmsKey"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, DeleteVolumeKmsKeyResponse> + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, DeleteVolumeKmsKeyResponse>() { + @Override + public DeleteVolumeKmsKeyResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace( + "Transform function invoked for DeleteVolumeKmsKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = RESPONSE_CONVERSION_FACTORY.create(); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + DeleteVolumeKmsKeyResponse.Builder builder = + DeleteVolumeKmsKeyResponse.builder(); + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + DeleteVolumeKmsKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/GetBootVolumeKmsKeyConverter.java b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/GetBootVolumeKmsKeyConverter.java new file mode 100644 index 00000000000..cd08acc2747 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/GetBootVolumeKmsKeyConverter.java @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.internal.http; + +import com.oracle.bmc.core.model.*; +import com.oracle.bmc.core.requests.*; +import com.oracle.bmc.core.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.extern.slf4j.Slf4j +public class GetBootVolumeKmsKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static GetBootVolumeKmsKeyRequest interceptRequest(GetBootVolumeKmsKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, GetBootVolumeKmsKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getBootVolumeId(), "bootVolumeId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20160918") + .path("bootVolumes") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getBootVolumeId())) + .path("kmsKey"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, GetBootVolumeKmsKeyResponse> + fromResponse() { + final com.google.common.base.Function< + javax.ws.rs.core.Response, GetBootVolumeKmsKeyResponse> + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, GetBootVolumeKmsKeyResponse>() { + @Override + public GetBootVolumeKmsKeyResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace( + "Transform function invoked for GetBootVolumeKmsKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + BootVolumeKmsKey>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + BootVolumeKmsKey.class); + + com.oracle.bmc.http.internal.WithHeaders + response = responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + GetBootVolumeKmsKeyResponse.Builder builder = + GetBootVolumeKmsKeyResponse.builder(); + + builder.bootVolumeKmsKey(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + GetBootVolumeKmsKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/GetVolumeKmsKeyConverter.java b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/GetVolumeKmsKeyConverter.java new file mode 100644 index 00000000000..444a41f7bae --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/GetVolumeKmsKeyConverter.java @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.internal.http; + +import com.oracle.bmc.core.model.*; +import com.oracle.bmc.core.requests.*; +import com.oracle.bmc.core.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.extern.slf4j.Slf4j +public class GetVolumeKmsKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static GetVolumeKmsKeyRequest interceptRequest(GetVolumeKmsKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, GetVolumeKmsKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getVolumeId(), "volumeId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20160918") + .path("volumes") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getVolumeId())) + .path("kmsKey"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, GetVolumeKmsKeyResponse> + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, GetVolumeKmsKeyResponse>() { + @Override + public GetVolumeKmsKeyResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for GetVolumeKmsKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + VolumeKmsKey>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + VolumeKmsKey.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + GetVolumeKmsKeyResponse.Builder builder = + GetVolumeKmsKeyResponse.builder(); + + builder.volumeKmsKey(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + GetVolumeKmsKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/UpdateBootVolumeKmsKeyConverter.java b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/UpdateBootVolumeKmsKeyConverter.java new file mode 100644 index 00000000000..c3f08e15995 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/UpdateBootVolumeKmsKeyConverter.java @@ -0,0 +1,111 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.internal.http; + +import com.oracle.bmc.core.model.*; +import com.oracle.bmc.core.requests.*; +import com.oracle.bmc.core.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.extern.slf4j.Slf4j +public class UpdateBootVolumeKmsKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static UpdateBootVolumeKmsKeyRequest interceptRequest( + UpdateBootVolumeKmsKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, UpdateBootVolumeKmsKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getBootVolumeId(), "bootVolumeId must not be blank"); + Validate.notNull( + request.getUpdateBootVolumeKmsKeyDetails(), + "updateBootVolumeKmsKeyDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20160918") + .path("bootVolumes") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getBootVolumeId())) + .path("kmsKey"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, UpdateBootVolumeKmsKeyResponse> + fromResponse() { + final com.google.common.base.Function< + javax.ws.rs.core.Response, UpdateBootVolumeKmsKeyResponse> + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, UpdateBootVolumeKmsKeyResponse>() { + @Override + public UpdateBootVolumeKmsKeyResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace( + "Transform function invoked for UpdateBootVolumeKmsKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + BootVolumeKmsKey>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + BootVolumeKmsKey.class); + + com.oracle.bmc.http.internal.WithHeaders + response = responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + UpdateBootVolumeKmsKeyResponse.Builder builder = + UpdateBootVolumeKmsKeyResponse.builder(); + + builder.bootVolumeKmsKey(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + UpdateBootVolumeKmsKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/UpdateVolumeKmsKeyConverter.java b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/UpdateVolumeKmsKeyConverter.java new file mode 100644 index 00000000000..e9f04f5ce00 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/internal/http/UpdateVolumeKmsKeyConverter.java @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.internal.http; + +import com.oracle.bmc.core.model.*; +import com.oracle.bmc.core.requests.*; +import com.oracle.bmc.core.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.extern.slf4j.Slf4j +public class UpdateVolumeKmsKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static UpdateVolumeKmsKeyRequest interceptRequest(UpdateVolumeKmsKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, UpdateVolumeKmsKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getVolumeId(), "volumeId must not be blank"); + Validate.notNull( + request.getUpdateVolumeKmsKeyDetails(), "updateVolumeKmsKeyDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20160918") + .path("volumes") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getVolumeId())) + .path("kmsKey"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, UpdateVolumeKmsKeyResponse> + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, UpdateVolumeKmsKeyResponse>() { + @Override + public UpdateVolumeKmsKeyResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace( + "Transform function invoked for UpdateVolumeKmsKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + VolumeKmsKey>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + VolumeKmsKey.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + UpdateVolumeKmsKeyResponse.Builder builder = + UpdateVolumeKmsKeyResponse.builder(); + + builder.volumeKmsKey(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + UpdateVolumeKmsKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/BootVolume.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/BootVolume.java index c20b46f0751..67e8cdcfc19 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/model/BootVolume.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/BootVolume.java @@ -158,6 +158,15 @@ public Builder volumeGroupId(String volumeGroupId) { return this; } + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); @@ -177,7 +186,8 @@ public BootVolume build() { sizeInMBs, sourceDetails, timeCreated, - volumeGroupId); + volumeGroupId, + kmsKeyId); __instance__.__explicitlySet__.addAll(__explicitlySet__); return __instance__; } @@ -198,7 +208,8 @@ public Builder copy(BootVolume o) { .sizeInMBs(o.getSizeInMBs()) .sourceDetails(o.getSourceDetails()) .timeCreated(o.getTimeCreated()) - .volumeGroupId(o.getVolumeGroupId()); + .volumeGroupId(o.getVolumeGroupId()) + .kmsKeyId(o.getKmsKeyId()); copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); return copiedBuilder; @@ -363,6 +374,12 @@ public static LifecycleState create(String key) { @com.fasterxml.jackson.annotation.JsonProperty("volumeGroupId") String volumeGroupId; + /** + * The OCID of the KMS key which is the master encryption key for the boot volume. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); } diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/BootVolumeKmsKey.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/BootVolumeKmsKey.java new file mode 100644 index 00000000000..49003ac6f1b --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/BootVolumeKmsKey.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.model; + +/** + * Kms key id associated with this volume. + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = BootVolumeKmsKey.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class BootVolumeKmsKey { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public BootVolumeKmsKey build() { + BootVolumeKmsKey __instance__ = new BootVolumeKmsKey(kmsKeyId); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(BootVolumeKmsKey o) { + Builder copiedBuilder = kmsKeyId(o.getKmsKeyId()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Kms key id associated with this volume. If volume is not using KMS, then kmsKeyId will be null string. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateBootVolumeDetails.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateBootVolumeDetails.java index b665752aba3..9dc84e9d97b 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateBootVolumeDetails.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateBootVolumeDetails.java @@ -79,6 +79,15 @@ public Builder freeformTags(java.util.Map freeformTags) { return this; } + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + @com.fasterxml.jackson.annotation.JsonProperty("sizeInGBs") private Long sizeInGBs; @@ -109,6 +118,7 @@ public CreateBootVolumeDetails build() { definedTags, displayName, freeformTags, + kmsKeyId, sizeInGBs, sourceDetails); __instance__.__explicitlySet__.addAll(__explicitlySet__); @@ -124,6 +134,7 @@ public Builder copy(CreateBootVolumeDetails o) { .definedTags(o.getDefinedTags()) .displayName(o.getDisplayName()) .freeformTags(o.getFreeformTags()) + .kmsKeyId(o.getKmsKeyId()) .sizeInGBs(o.getSizeInGBs()) .sourceDetails(o.getSourceDetails()); @@ -191,6 +202,12 @@ public static Builder builder() { @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") java.util.Map freeformTags; + /** + * The OCID of the KMS key to be used as the master encryption key for the boot volume. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + /** * The size of the volume in GBs. **/ diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateImageDetails.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateImageDetails.java index 76c9cf4b5fe..3b1ff90d93b 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateImageDetails.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateImageDetails.java @@ -182,12 +182,14 @@ public static Builder builder() { * Specifies the configuration mode for launching virtual machine (VM) instances. The configuration modes are: * * `NATIVE` - VM instances launch with iSCSI boot and VFIO devices. The default value for Oracle-provided images. * * `EMULATED` - VM instances launch with emulated devices, such as the E1000 network driver and emulated SCSI disk controller. + * * `PARAVIRTUALIZED` - VM instances launch with paravirtualized devices using virtio drivers. * * `CUSTOM` - VM instances launch with custom configuration settings specified in the `LaunchOptions` parameter. * **/ public enum LaunchMode { Native("NATIVE"), Emulated("EMULATED"), + Paravirtualized("PARAVIRTUALIZED"), Custom("CUSTOM"), ; @@ -222,6 +224,7 @@ public static LaunchMode create(String key) { * Specifies the configuration mode for launching virtual machine (VM) instances. The configuration modes are: * * `NATIVE` - VM instances launch with iSCSI boot and VFIO devices. The default value for Oracle-provided images. * * `EMULATED` - VM instances launch with emulated devices, such as the E1000 network driver and emulated SCSI disk controller. + * * `PARAVIRTUALIZED` - VM instances launch with paravirtualized devices using virtio drivers. * * `CUSTOM` - VM instances launch with custom configuration settings specified in the `LaunchOptions` parameter. * **/ diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateVolumeDetails.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateVolumeDetails.java index 7c6908f11c3..131c5fa644e 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateVolumeDetails.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/CreateVolumeDetails.java @@ -79,6 +79,15 @@ public Builder freeformTags(java.util.Map freeformTags) { return this; } + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + @com.fasterxml.jackson.annotation.JsonProperty("sizeInGBs") private Long sizeInGBs; @@ -127,6 +136,7 @@ public CreateVolumeDetails build() { definedTags, displayName, freeformTags, + kmsKeyId, sizeInGBs, sizeInMBs, sourceDetails, @@ -144,6 +154,7 @@ public Builder copy(CreateVolumeDetails o) { .definedTags(o.getDefinedTags()) .displayName(o.getDisplayName()) .freeformTags(o.getFreeformTags()) + .kmsKeyId(o.getKmsKeyId()) .sizeInGBs(o.getSizeInGBs()) .sizeInMBs(o.getSizeInMBs()) .sourceDetails(o.getSourceDetails()) @@ -213,6 +224,12 @@ public static Builder builder() { @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") java.util.Map freeformTags; + /** + * The OCID of the KMS key to be used as the master encryption key for the volume. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + /** * The size of the volume in GBs. **/ diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/Image.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/Image.java index 15e9d6bc27a..827c5e8f029 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/model/Image.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/Image.java @@ -275,6 +275,7 @@ public static Builder builder() { * Specifies the configuration mode for launching virtual machine (VM) instances. The configuration modes are: * * `NATIVE` - VM instances launch with iSCSI boot and VFIO devices. The default value for Oracle-provided images. * * `EMULATED` - VM instances launch with emulated devices, such as the E1000 network driver and emulated SCSI disk controller. + * * `PARAVIRTUALIZED` - VM instances launch with paravirtualized devices using virtio drivers. * * `CUSTOM` - VM instances launch with custom configuration settings specified in the `LaunchOptions` parameter. * **/ @@ -282,6 +283,7 @@ public static Builder builder() { public enum LaunchMode { Native("NATIVE"), Emulated("EMULATED"), + Paravirtualized("PARAVIRTUALIZED"), Custom("CUSTOM"), /** @@ -326,6 +328,7 @@ public static LaunchMode create(String key) { * Specifies the configuration mode for launching virtual machine (VM) instances. The configuration modes are: * * `NATIVE` - VM instances launch with iSCSI boot and VFIO devices. The default value for Oracle-provided images. * * `EMULATED` - VM instances launch with emulated devices, such as the E1000 network driver and emulated SCSI disk controller. + * * `PARAVIRTUALIZED` - VM instances launch with paravirtualized devices using virtio drivers. * * `CUSTOM` - VM instances launch with custom configuration settings specified in the `LaunchOptions` parameter. * **/ diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/Instance.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/Instance.java index 69c921aed66..db7874c5973 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/model/Instance.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/Instance.java @@ -375,6 +375,7 @@ public static Builder builder() { * Specifies the configuration mode for launching virtual machine (VM) instances. The configuration modes are: * * `NATIVE` - VM instances launch with iSCSI boot and VFIO devices. The default value for Oracle-provided images. * * `EMULATED` - VM instances launch with emulated devices, such as the E1000 network driver and emulated SCSI disk controller. + * * `PARAVIRTUALIZED` - VM instances launch with paravirtualized devices using virtio drivers. * * `CUSTOM` - VM instances launch with custom configuration settings specified in the `LaunchOptions` parameter. * **/ @@ -382,6 +383,7 @@ public static Builder builder() { public enum LaunchMode { Native("NATIVE"), Emulated("EMULATED"), + Paravirtualized("PARAVIRTUALIZED"), Custom("CUSTOM"), /** @@ -426,6 +428,7 @@ public static LaunchMode create(String key) { * Specifies the configuration mode for launching virtual machine (VM) instances. The configuration modes are: * * `NATIVE` - VM instances launch with iSCSI boot and VFIO devices. The default value for Oracle-provided images. * * `EMULATED` - VM instances launch with emulated devices, such as the E1000 network driver and emulated SCSI disk controller. + * * `PARAVIRTUALIZED` - VM instances launch with paravirtualized devices using virtio drivers. * * `CUSTOM` - VM instances launch with custom configuration settings specified in the `LaunchOptions` parameter. * **/ diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/InstanceSourceViaImageDetails.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/InstanceSourceViaImageDetails.java index 62bff5b8535..9edd686761d 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/model/InstanceSourceViaImageDetails.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/InstanceSourceViaImageDetails.java @@ -48,12 +48,21 @@ public Builder imageId(String imageId) { return this; } + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); public InstanceSourceViaImageDetails build() { InstanceSourceViaImageDetails __instance__ = - new InstanceSourceViaImageDetails(bootVolumeSizeInGBs, imageId); + new InstanceSourceViaImageDetails(bootVolumeSizeInGBs, imageId, kmsKeyId); __instance__.__explicitlySet__.addAll(__explicitlySet__); return __instance__; } @@ -61,7 +70,9 @@ public InstanceSourceViaImageDetails build() { @com.fasterxml.jackson.annotation.JsonIgnore public Builder copy(InstanceSourceViaImageDetails o) { Builder copiedBuilder = - bootVolumeSizeInGBs(o.getBootVolumeSizeInGBs()).imageId(o.getImageId()); + bootVolumeSizeInGBs(o.getBootVolumeSizeInGBs()) + .imageId(o.getImageId()) + .kmsKeyId(o.getKmsKeyId()); copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); return copiedBuilder; @@ -76,10 +87,12 @@ public static Builder builder() { } @Deprecated - public InstanceSourceViaImageDetails(Long bootVolumeSizeInGBs, String imageId) { + public InstanceSourceViaImageDetails( + Long bootVolumeSizeInGBs, String imageId, String kmsKeyId) { super(); this.bootVolumeSizeInGBs = bootVolumeSizeInGBs; this.imageId = imageId; + this.kmsKeyId = kmsKeyId; } /** @@ -94,6 +107,12 @@ public InstanceSourceViaImageDetails(Long bootVolumeSizeInGBs, String imageId) { @com.fasterxml.jackson.annotation.JsonProperty("imageId") String imageId; + /** + * The OCID of the KMS key to be used as the master encryption key for the boot volume. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); } diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/LaunchOptions.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/LaunchOptions.java index 836fb48b436..e6b1d14a217 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/model/LaunchOptions.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/LaunchOptions.java @@ -224,12 +224,14 @@ public static Firmware create(String key) { * Emulation type for NIC. * * `E1000` - Emulated Gigabit ethernet controller. Compatible with Linux e1000 network driver. * * `VFIO` - Direct attached Virtual Function network controller. Default for Oracle provided images. + * * `PARAVIRTUALIZED` - VM instances launch with paravirtualized devices using virtio drivers. * **/ @lombok.extern.slf4j.Slf4j public enum NetworkType { E1000("E1000"), Vfio("VFIO"), + Paravirtualized("PARAVIRTUALIZED"), /** * This value is used if a service returns a value for this enum that is not recognized by this @@ -273,6 +275,7 @@ public static NetworkType create(String key) { * Emulation type for NIC. * * `E1000` - Emulated Gigabit ethernet controller. Compatible with Linux e1000 network driver. * * `VFIO` - Direct attached Virtual Function network controller. Default for Oracle provided images. + * * `PARAVIRTUALIZED` - VM instances launch with paravirtualized devices using virtio drivers. * **/ @com.fasterxml.jackson.annotation.JsonProperty("networkType") diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/UpdateBootVolumeKmsKeyDetails.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/UpdateBootVolumeKmsKeyDetails.java new file mode 100644 index 00000000000..939e678d1ac --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/UpdateBootVolumeKmsKeyDetails.java @@ -0,0 +1,74 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize( + builder = UpdateBootVolumeKmsKeyDetails.Builder.class +) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class UpdateBootVolumeKmsKeyDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public UpdateBootVolumeKmsKeyDetails build() { + UpdateBootVolumeKmsKeyDetails __instance__ = + new UpdateBootVolumeKmsKeyDetails(kmsKeyId); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(UpdateBootVolumeKmsKeyDetails o) { + Builder copiedBuilder = kmsKeyId(o.getKmsKeyId()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The new kms key which will be used to protect the specific volume. + * This key has to be a valid kms key ocid, and user must have key delegation policy to allow them to access this key. + * Even if this new kms key is the same as the previous kms key id, block storage service will use it to regenerate a new volume encryption key. + * Example: `{\"kmsKeyId\": \"ocid1.key.region1.sea.afnl2n7daag4s.abzwkljs6uevhlgcznhmh7oiatyrxngrywc3tje3uk3g77hzmewqiieuk75f\"}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/UpdateVolumeKmsKeyDetails.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/UpdateVolumeKmsKeyDetails.java new file mode 100644 index 00000000000..d8028fb7fbe --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/UpdateVolumeKmsKeyDetails.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize( + builder = UpdateVolumeKmsKeyDetails.Builder.class +) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class UpdateVolumeKmsKeyDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public UpdateVolumeKmsKeyDetails build() { + UpdateVolumeKmsKeyDetails __instance__ = new UpdateVolumeKmsKeyDetails(kmsKeyId); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(UpdateVolumeKmsKeyDetails o) { + Builder copiedBuilder = kmsKeyId(o.getKmsKeyId()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The new kms key which will be used to protect the specific volume. + * This key has to be a valid kms key ocid, and user must have key delegation policy to allow them to access this key. + * Even if this new kms key is the same as the previous kms key id, block storage service will use it to regenerate a new volume encryption key. + * Example: `{\"kmsKeyId\": \"ocid1.key.region1.sea.afnl2n7daag4s.abzwkljs6uevhlgcznhmh7oiatyrxngrywc3tje3uk3g77hzmewqiieuk75f\"}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/Volume.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/Volume.java index bfeb8a1aa25..0ab32247dc3 100644 --- a/bmc-core/src/main/java/com/oracle/bmc/core/model/Volume.java +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/Volume.java @@ -96,6 +96,15 @@ public Builder isHydrated(Boolean isHydrated) { return this; } + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + @com.fasterxml.jackson.annotation.JsonProperty("lifecycleState") private LifecycleState lifecycleState; @@ -163,6 +172,7 @@ public Volume build() { freeformTags, id, isHydrated, + kmsKeyId, lifecycleState, sizeInGBs, sizeInMBs, @@ -183,6 +193,7 @@ public Builder copy(Volume o) { .freeformTags(o.getFreeformTags()) .id(o.getId()) .isHydrated(o.getIsHydrated()) + .kmsKeyId(o.getKmsKeyId()) .lifecycleState(o.getLifecycleState()) .sizeInGBs(o.getSizeInGBs()) .sizeInMBs(o.getSizeInMBs()) @@ -257,6 +268,12 @@ public static Builder builder() { **/ @com.fasterxml.jackson.annotation.JsonProperty("isHydrated") Boolean isHydrated; + + /** + * The OCID of the KMS key which is the master encryption key for the volume. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; /** * The current state of a volume. **/ diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/model/VolumeKmsKey.java b/bmc-core/src/main/java/com/oracle/bmc/core/model/VolumeKmsKey.java new file mode 100644 index 00000000000..a8c3fabef32 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/model/VolumeKmsKey.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.model; + +/** + * Kms key id associated with this volume. + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = VolumeKmsKey.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class VolumeKmsKey { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public VolumeKmsKey build() { + VolumeKmsKey __instance__ = new VolumeKmsKey(kmsKeyId); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(VolumeKmsKey o) { + Builder copiedBuilder = kmsKeyId(o.getKmsKeyId()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Kms key id associated with this volume. If volume is not using KMS, then kmsKeyId will be null string. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/requests/DeleteBootVolumeKmsKeyRequest.java b/bmc-core/src/main/java/com/oracle/bmc/core/requests/DeleteBootVolumeKmsKeyRequest.java new file mode 100644 index 00000000000..a5d1b90bd43 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/requests/DeleteBootVolumeKmsKeyRequest.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.requests; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class DeleteBootVolumeKmsKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the boot volume. + */ + private String bootVolumeId; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` + * parameter to the value of the etag from a previous GET or POST response for that resource. The resource + * will be updated or deleted only if the etag you provide matches the resource's current etag value. + * + */ + private String ifMatch; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(DeleteBootVolumeKmsKeyRequest o) { + bootVolumeId(o.getBootVolumeId()); + ifMatch(o.getIfMatch()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of DeleteBootVolumeKmsKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of DeleteBootVolumeKmsKeyRequest + */ + public DeleteBootVolumeKmsKeyRequest build() { + DeleteBootVolumeKmsKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/requests/DeleteVolumeKmsKeyRequest.java b/bmc-core/src/main/java/com/oracle/bmc/core/requests/DeleteVolumeKmsKeyRequest.java new file mode 100644 index 00000000000..4234332eeb0 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/requests/DeleteVolumeKmsKeyRequest.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.requests; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class DeleteVolumeKmsKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the volume. + */ + private String volumeId; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` + * parameter to the value of the etag from a previous GET or POST response for that resource. The resource + * will be updated or deleted only if the etag you provide matches the resource's current etag value. + * + */ + private String ifMatch; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(DeleteVolumeKmsKeyRequest o) { + volumeId(o.getVolumeId()); + ifMatch(o.getIfMatch()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of DeleteVolumeKmsKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of DeleteVolumeKmsKeyRequest + */ + public DeleteVolumeKmsKeyRequest build() { + DeleteVolumeKmsKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/requests/GetBootVolumeKmsKeyRequest.java b/bmc-core/src/main/java/com/oracle/bmc/core/requests/GetBootVolumeKmsKeyRequest.java new file mode 100644 index 00000000000..87a7a9b1ac7 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/requests/GetBootVolumeKmsKeyRequest.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.requests; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class GetBootVolumeKmsKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the boot volume. + */ + private String bootVolumeId; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` + * parameter to the value of the etag from a previous GET or POST response for that resource. The resource + * will be updated or deleted only if the etag you provide matches the resource's current etag value. + * + */ + private String ifMatch; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetBootVolumeKmsKeyRequest o) { + bootVolumeId(o.getBootVolumeId()); + ifMatch(o.getIfMatch()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of GetBootVolumeKmsKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of GetBootVolumeKmsKeyRequest + */ + public GetBootVolumeKmsKeyRequest build() { + GetBootVolumeKmsKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/requests/GetVolumeKmsKeyRequest.java b/bmc-core/src/main/java/com/oracle/bmc/core/requests/GetVolumeKmsKeyRequest.java new file mode 100644 index 00000000000..21f46d213c8 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/requests/GetVolumeKmsKeyRequest.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.requests; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class GetVolumeKmsKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the volume. + */ + private String volumeId; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` + * parameter to the value of the etag from a previous GET or POST response for that resource. The resource + * will be updated or deleted only if the etag you provide matches the resource's current etag value. + * + */ + private String ifMatch; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetVolumeKmsKeyRequest o) { + volumeId(o.getVolumeId()); + ifMatch(o.getIfMatch()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of GetVolumeKmsKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of GetVolumeKmsKeyRequest + */ + public GetVolumeKmsKeyRequest build() { + GetVolumeKmsKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/requests/UpdateBootVolumeKmsKeyRequest.java b/bmc-core/src/main/java/com/oracle/bmc/core/requests/UpdateBootVolumeKmsKeyRequest.java new file mode 100644 index 00000000000..21a6253f988 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/requests/UpdateBootVolumeKmsKeyRequest.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.requests; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class UpdateBootVolumeKmsKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the boot volume. + */ + private String bootVolumeId; + + /** + * Update kms key id for the specific boot volume. + */ + private UpdateBootVolumeKmsKeyDetails updateBootVolumeKmsKeyDetails; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` + * parameter to the value of the etag from a previous GET or POST response for that resource. The resource + * will be updated or deleted only if the etag you provide matches the resource's current etag value. + * + */ + private String ifMatch; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(UpdateBootVolumeKmsKeyRequest o) { + bootVolumeId(o.getBootVolumeId()); + updateBootVolumeKmsKeyDetails(o.getUpdateBootVolumeKmsKeyDetails()); + ifMatch(o.getIfMatch()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of UpdateBootVolumeKmsKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of UpdateBootVolumeKmsKeyRequest + */ + public UpdateBootVolumeKmsKeyRequest build() { + UpdateBootVolumeKmsKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/requests/UpdateVolumeKmsKeyRequest.java b/bmc-core/src/main/java/com/oracle/bmc/core/requests/UpdateVolumeKmsKeyRequest.java new file mode 100644 index 00000000000..df803baeb13 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/requests/UpdateVolumeKmsKeyRequest.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.requests; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class UpdateVolumeKmsKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the volume. + */ + private String volumeId; + + /** + * Update kms key id for the specific volume. + */ + private UpdateVolumeKmsKeyDetails updateVolumeKmsKeyDetails; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a resource, set the `if-match` + * parameter to the value of the etag from a previous GET or POST response for that resource. The resource + * will be updated or deleted only if the etag you provide matches the resource's current etag value. + * + */ + private String ifMatch; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(UpdateVolumeKmsKeyRequest o) { + volumeId(o.getVolumeId()); + updateVolumeKmsKeyDetails(o.getUpdateVolumeKmsKeyDetails()); + ifMatch(o.getIfMatch()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of UpdateVolumeKmsKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of UpdateVolumeKmsKeyRequest + */ + public UpdateVolumeKmsKeyRequest build() { + UpdateVolumeKmsKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/responses/DeleteBootVolumeKmsKeyResponse.java b/bmc-core/src/main/java/com/oracle/bmc/core/responses/DeleteBootVolumeKmsKeyResponse.java new file mode 100644 index 00000000000..f698f0f6b15 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/responses/DeleteBootVolumeKmsKeyResponse.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.responses; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class DeleteBootVolumeKmsKeyResponse { + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(DeleteBootVolumeKmsKeyResponse o) { + opcRequestId(o.getOpcRequestId()); + + return this; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/responses/DeleteVolumeKmsKeyResponse.java b/bmc-core/src/main/java/com/oracle/bmc/core/responses/DeleteVolumeKmsKeyResponse.java new file mode 100644 index 00000000000..947f0b8b301 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/responses/DeleteVolumeKmsKeyResponse.java @@ -0,0 +1,31 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.responses; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class DeleteVolumeKmsKeyResponse { + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(DeleteVolumeKmsKeyResponse o) { + opcRequestId(o.getOpcRequestId()); + + return this; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/responses/GetBootVolumeKmsKeyResponse.java b/bmc-core/src/main/java/com/oracle/bmc/core/responses/GetBootVolumeKmsKeyResponse.java new file mode 100644 index 00000000000..954879c3e08 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/responses/GetBootVolumeKmsKeyResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.responses; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class GetBootVolumeKmsKeyResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned BootVolumeKmsKey instance. + */ + private BootVolumeKmsKey bootVolumeKmsKey; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetBootVolumeKmsKeyResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + bootVolumeKmsKey(o.getBootVolumeKmsKey()); + + return this; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/responses/GetVolumeKmsKeyResponse.java b/bmc-core/src/main/java/com/oracle/bmc/core/responses/GetVolumeKmsKeyResponse.java new file mode 100644 index 00000000000..a8bc1aef0e2 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/responses/GetVolumeKmsKeyResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.responses; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class GetVolumeKmsKeyResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned VolumeKmsKey instance. + */ + private VolumeKmsKey volumeKmsKey; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetVolumeKmsKeyResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + volumeKmsKey(o.getVolumeKmsKey()); + + return this; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/responses/UpdateBootVolumeKmsKeyResponse.java b/bmc-core/src/main/java/com/oracle/bmc/core/responses/UpdateBootVolumeKmsKeyResponse.java new file mode 100644 index 00000000000..e6a5ec1097c --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/responses/UpdateBootVolumeKmsKeyResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.responses; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class UpdateBootVolumeKmsKeyResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned BootVolumeKmsKey instance. + */ + private BootVolumeKmsKey bootVolumeKmsKey; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(UpdateBootVolumeKmsKeyResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + bootVolumeKmsKey(o.getBootVolumeKmsKey()); + + return this; + } + } +} diff --git a/bmc-core/src/main/java/com/oracle/bmc/core/responses/UpdateVolumeKmsKeyResponse.java b/bmc-core/src/main/java/com/oracle/bmc/core/responses/UpdateVolumeKmsKeyResponse.java new file mode 100644 index 00000000000..db3cbeac614 --- /dev/null +++ b/bmc-core/src/main/java/com/oracle/bmc/core/responses/UpdateVolumeKmsKeyResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.core.responses; + +import com.oracle.bmc.core.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20160918") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class UpdateVolumeKmsKeyResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned VolumeKmsKey instance. + */ + private VolumeKmsKey volumeKmsKey; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(UpdateVolumeKmsKeyResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + volumeKmsKey(o.getVolumeKmsKey()); + + return this; + } + } +} diff --git a/bmc-database/pom.xml b/bmc-database/pom.xml index d94ad535169..22f09eb0010 100644 --- a/bmc-database/pom.xml +++ b/bmc-database/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-database/src/main/java/com/oracle/bmc/database/DatabaseAsyncClient.java b/bmc-database/src/main/java/com/oracle/bmc/database/DatabaseAsyncClient.java index 77555727378..f9b0d3e4a34 100644 --- a/bmc-database/src/main/java/com/oracle/bmc/database/DatabaseAsyncClient.java +++ b/bmc-database/src/main/java/com/oracle/bmc/database/DatabaseAsyncClient.java @@ -15,7 +15,10 @@ public class DatabaseAsyncClient implements DatabaseAsync { * Service instance for Database. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("DATABASE", "database"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("DATABASE") + .serviceEndpointPrefix("database") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-database/src/main/java/com/oracle/bmc/database/DatabaseClient.java b/bmc-database/src/main/java/com/oracle/bmc/database/DatabaseClient.java index 8af676f1f99..00a3b3e4b49 100644 --- a/bmc-database/src/main/java/com/oracle/bmc/database/DatabaseClient.java +++ b/bmc-database/src/main/java/com/oracle/bmc/database/DatabaseClient.java @@ -15,7 +15,10 @@ public class DatabaseClient implements Database { * Service instance for Database. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("DATABASE", "database"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("DATABASE") + .serviceEndpointPrefix("database") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-dns/pom.xml b/bmc-dns/pom.xml index 3a6ed521f35..edeaba5829e 100644 --- a/bmc-dns/pom.xml +++ b/bmc-dns/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-dns/src/main/java/com/oracle/bmc/dns/DnsAsyncClient.java b/bmc-dns/src/main/java/com/oracle/bmc/dns/DnsAsyncClient.java index 47eea611220..7c9704e84b0 100644 --- a/bmc-dns/src/main/java/com/oracle/bmc/dns/DnsAsyncClient.java +++ b/bmc-dns/src/main/java/com/oracle/bmc/dns/DnsAsyncClient.java @@ -15,7 +15,10 @@ public class DnsAsyncClient implements DnsAsync { * Service instance for Dns. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("DNS", "dns"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("DNS") + .serviceEndpointPrefix("dns") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-dns/src/main/java/com/oracle/bmc/dns/DnsClient.java b/bmc-dns/src/main/java/com/oracle/bmc/dns/DnsClient.java index bf4ca09694f..b1f6ff81ea1 100644 --- a/bmc-dns/src/main/java/com/oracle/bmc/dns/DnsClient.java +++ b/bmc-dns/src/main/java/com/oracle/bmc/dns/DnsClient.java @@ -15,7 +15,10 @@ public class DnsClient implements Dns { * Service instance for Dns. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("DNS", "dns"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("DNS") + .serviceEndpointPrefix("dns") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-email/pom.xml b/bmc-email/pom.xml index c5b98093973..cc09a48313d 100644 --- a/bmc-email/pom.xml +++ b/bmc-email/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-email/src/main/java/com/oracle/bmc/email/EmailAsyncClient.java b/bmc-email/src/main/java/com/oracle/bmc/email/EmailAsyncClient.java index bb757582776..05cfa7ddfad 100644 --- a/bmc-email/src/main/java/com/oracle/bmc/email/EmailAsyncClient.java +++ b/bmc-email/src/main/java/com/oracle/bmc/email/EmailAsyncClient.java @@ -15,7 +15,10 @@ public class EmailAsyncClient implements EmailAsync { * Service instance for Email. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("EMAIL", "email"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("EMAIL") + .serviceEndpointPrefix("email") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-email/src/main/java/com/oracle/bmc/email/EmailClient.java b/bmc-email/src/main/java/com/oracle/bmc/email/EmailClient.java index f032d345d35..f01f91e8f52 100644 --- a/bmc-email/src/main/java/com/oracle/bmc/email/EmailClient.java +++ b/bmc-email/src/main/java/com/oracle/bmc/email/EmailClient.java @@ -15,7 +15,10 @@ public class EmailClient implements Email { * Service instance for Email. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("EMAIL", "email"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("EMAIL") + .serviceEndpointPrefix("email") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-examples/pom.xml b/bmc-examples/pom.xml index 24e9c648905..555be6f62c8 100644 --- a/bmc-examples/pom.xml +++ b/bmc-examples/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -19,7 +19,7 @@ com.oracle.oci.sdk oci-java-sdk-bom - 1.2.46 + 1.2.47 pom import @@ -58,7 +58,6 @@ com.oracle.oci.sdk oci-java-sdk-objectstorage - pom com.oracle.oci.sdk @@ -72,6 +71,10 @@ com.oracle.oci.sdk oci-java-sdk-addons-apache + + com.oracle.oci.sdk + oci-java-sdk-keymanagement + diff --git a/bmc-examples/src/main/java/CreateInstanceExample.java b/bmc-examples/src/main/java/CreateInstanceExample.java index acd442df057..0a3e23c0ba4 100644 --- a/bmc-examples/src/main/java/CreateInstanceExample.java +++ b/bmc-examples/src/main/java/CreateInstanceExample.java @@ -6,18 +6,26 @@ import java.util.List; import java.util.Map; +import com.google.common.base.Strings; import com.oracle.bmc.Region; import com.oracle.bmc.auth.AuthenticationDetailsProvider; import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider; +import com.oracle.bmc.core.BlockstorageClient; +import com.oracle.bmc.core.BlockstorageWaiters; import com.oracle.bmc.core.ComputeClient; import com.oracle.bmc.core.ComputeWaiters; import com.oracle.bmc.core.VirtualNetworkClient; +import com.oracle.bmc.core.model.BootVolume; +import com.oracle.bmc.core.model.BootVolumeSourceDetails; +import com.oracle.bmc.core.model.BootVolumeSourceFromBootVolumeDetails; +import com.oracle.bmc.core.model.CreateBootVolumeDetails; import com.oracle.bmc.core.model.CreateInternetGatewayDetails; import com.oracle.bmc.core.model.CreateSubnetDetails; import com.oracle.bmc.core.model.CreateVcnDetails; import com.oracle.bmc.core.model.CreateVnicDetails; import com.oracle.bmc.core.model.Image; import com.oracle.bmc.core.model.Instance; +import com.oracle.bmc.core.model.InstanceSourceViaBootVolumeDetails; import com.oracle.bmc.core.model.InstanceSourceViaImageDetails; import com.oracle.bmc.core.model.InternetGateway; import com.oracle.bmc.core.model.LaunchInstanceDetails; @@ -26,18 +34,22 @@ import com.oracle.bmc.core.model.Subnet; import com.oracle.bmc.core.model.UpdateRouteTableDetails; import com.oracle.bmc.core.model.Vcn; +import com.oracle.bmc.core.requests.CreateBootVolumeRequest; import com.oracle.bmc.core.requests.CreateInternetGatewayRequest; import com.oracle.bmc.core.requests.CreateSubnetRequest; import com.oracle.bmc.core.requests.CreateVcnRequest; +import com.oracle.bmc.core.requests.GetBootVolumeRequest; import com.oracle.bmc.core.requests.GetInstanceRequest; import com.oracle.bmc.core.requests.GetSubnetRequest; import com.oracle.bmc.core.requests.LaunchInstanceRequest; +import com.oracle.bmc.core.requests.ListBootVolumesRequest; import com.oracle.bmc.core.requests.ListImagesRequest; import com.oracle.bmc.core.requests.ListShapesRequest; import com.oracle.bmc.core.requests.UpdateRouteTableRequest; import com.oracle.bmc.core.responses.CreateInternetGatewayResponse; import com.oracle.bmc.core.responses.CreateSubnetResponse; import com.oracle.bmc.core.responses.CreateVcnResponse; +import com.oracle.bmc.core.responses.GetBootVolumeResponse; import com.oracle.bmc.core.responses.GetInstanceResponse; import com.oracle.bmc.core.responses.LaunchInstanceResponse; import com.oracle.bmc.core.responses.ListImagesResponse; @@ -49,7 +61,16 @@ import com.oracle.bmc.identity.responses.ListAvailabilityDomainsResponse; public class CreateInstanceExample { - + /** + * Please refer to https://docs.cloud.oracle.com/iaas/Content/Compute/Tasks/launchinginstance.htm to get information about what is necessary for using API to launch a VM instance. + * This sample will do following things: + * 1) Prepare VCN, GateWay for VMs. + * 2) create an instance in VCN from image id and kms key Id. + * 3) Create a new boot volume based on existing boot volume. + * 4) Launch another instance based on the newly created boot volume. + * @param args + * @throws Exception + */ public static void main(String[] args) throws Exception { // TODO: Fill in these values @@ -63,15 +84,23 @@ public static void main(String[] args) throws Exception { String subnetDisplayName = instanceDisplayName + "-subnet"; String vcnDisplayName = instanceDisplayName + "-vcn"; String internetGatewayDisplayName = instanceDisplayName + "-internet-gateway"; + String bootVolumeDisplayName = instanceDisplayName + "-bootVolume"; String configurationFilePath = "~/.oci/config"; String profile = "DEFAULT"; + // When an instance is created, a boot volume is created at the same time. User could choose to use their own kms key to encrypt the data. + // fill out necessary kms key information to use your own key to protect kms. More information of volume security please refer to https://cloud.oracle.com/storage/block-volume/faq + // If you dont't need kmsKeyId, then simply set it to null. Refer to the commented out line below. + String kmsKeyId = "SOME VALID KMS Key OCID"; + // String kmsKeyId = null; + AuthenticationDetailsProvider provider = new ConfigFileAuthenticationDetailsProvider(configurationFilePath, profile); ComputeClient computeClient = new ComputeClient(provider); VirtualNetworkClient vcnClient = new VirtualNetworkClient(provider); + BlockstorageClient blockstorageClient = new BlockstorageClient(provider); vcnClient.setRegion(Region.US_PHOENIX_1); computeClient.setRegion(Region.US_PHOENIX_1); @@ -145,17 +174,50 @@ public static void main(String[] args) throws Exception { image, shape, subnet, - sshPublicKey); + sshPublicKey, + kmsKeyId); - System.out.println("Instance is provisioning..."); + System.out.println("Instance is being created via image id and kms key id..."); instance = waitForInstanceProvisioningToComplete(computeClient, instance.getId()); + System.out.println("Instance is provisioned."); + + InstanceSourceViaImageDetails sourceDetails = + (InstanceSourceViaImageDetails) instance.getSourceDetails(); + + BootVolume bootVolume = + createBootVolume( + blockstorageClient, + adToUse, + sourceDetails, + instance.getImageId(), + bootVolumeDisplayName, + compartmentId, + kmsKeyId); + + System.out.println("New bootVolume is provisioning..."); + + bootVolume = waitForBootVolumeToBeReady(blockstorageClient, bootVolume.getId()); + + System.out.println("New bootVolume is provisioned..."); + + System.out.println("Provisioning a new instance via boot volume"); + Instance instance2 = + createInstanceFromBootVolume( + computeClient, + compartmentId, + adToUse, + instanceDisplayName + "2", + bootVolume.getId(), + shapes.get(0), + subnet, + sshPublicKey); + + System.out.println("Instance 2 is provisioned."); + blockstorageClient.close(); computeClient.close(); vcnClient.close(); - - System.out.println("Instance is provisioned:"); - System.out.println(instance); } public static Vcn createVcn( @@ -255,11 +317,20 @@ public static Instance createInstance( Image image, Shape shape, Subnet subnet, - String sshPublicKey) { + String sshPublicKey, + String kmsKeyId) { Map metadata = new HashMap<>(); metadata.put("ssh_authorized_keys", sshPublicKey); + InstanceSourceViaImageDetails details = + (Strings.isNullOrEmpty(kmsKeyId)) + ? InstanceSourceViaImageDetails.builder().imageId(image.getId()).build() + : InstanceSourceViaImageDetails.builder() + .imageId(image.getId()) + .kmsKeyId(kmsKeyId) + .build(); + LaunchInstanceResponse response = computeClient.launchInstance( LaunchInstanceRequest.builder() @@ -271,10 +342,7 @@ public static Instance createInstance( .faultDomain("FAULT-DOMAIN-1") // optional parameter .metadata(metadata) .shape(shape.getShape()) - .sourceDetails( - InstanceSourceViaImageDetails.builder() - .imageId(image.getId()) - .build()) + .sourceDetails(details) .createVnicDetails( CreateVnicDetails.builder() .subnetId(subnet.getId()) @@ -340,4 +408,94 @@ public static Instance waitForInstanceProvisioningToComplete( return response.getInstance(); } + + private static BootVolume createBootVolume( + BlockstorageClient blockstorageClient, + AvailabilityDomain adToUse, + InstanceSourceViaImageDetails sourceDetails, + String imageId, + String displayName, + String compartmentId, + String kmsKeyId) { + List bootVolumes = + blockstorageClient + .listBootVolumes( + ListBootVolumesRequest.builder() + .availabilityDomain(adToUse.getName()) + .compartmentId(compartmentId) + .build()) + .getItems(); + String bootVolumeId = null; + for (BootVolume bootVolume : bootVolumes) { + if (bootVolume.getLifecycleState().equals(BootVolume.LifecycleState.Available) + && bootVolume.getImageId() != null + && bootVolume.getImageId().equals(imageId)) { + bootVolumeId = bootVolume.getId(); + break; + } + } + + BootVolumeSourceDetails bootVolumeSourceDetails = + BootVolumeSourceFromBootVolumeDetails.builder().id(bootVolumeId).build(); + CreateBootVolumeDetails details = + CreateBootVolumeDetails.builder() + .availabilityDomain(adToUse.getName()) + .compartmentId(compartmentId) + .displayName(displayName) + .sourceDetails(bootVolumeSourceDetails) + .kmsKeyId(kmsKeyId) + .build(); + + return blockstorageClient + .createBootVolume( + CreateBootVolumeRequest.builder().createBootVolumeDetails(details).build()) + .getBootVolume(); + } + + private static BootVolume waitForBootVolumeToBeReady( + BlockstorageClient blockStorage, String bootVolumeId) throws Exception { + + BlockstorageWaiters waiter = blockStorage.getWaiters(); + GetBootVolumeResponse response = + waiter.forBootVolume( + GetBootVolumeRequest.builder().bootVolumeId(bootVolumeId).build(), + BootVolume.LifecycleState.Available) + .execute(); + + return response.getBootVolume(); + } + + private static Instance createInstanceFromBootVolume( + ComputeClient computeClient, + String compartmentId, + AvailabilityDomain adToUse, + String instanceName, + String bootVolumeId, + Shape shape, + Subnet subnet, + String sshPublicKey) { + Map metadata = new HashMap<>(); + metadata.put("ssh_authorized_keys", sshPublicKey); + + InstanceSourceViaBootVolumeDetails details = + InstanceSourceViaBootVolumeDetails.builder().bootVolumeId(bootVolumeId).build(); + + LaunchInstanceResponse response = + computeClient.launchInstance( + LaunchInstanceRequest.builder() + .launchInstanceDetails( + LaunchInstanceDetails.builder() + .availabilityDomain(adToUse.getName()) + .compartmentId(compartmentId) + .displayName(instanceName) + .faultDomain("FAULT-DOMAIN-1") // optional parameter + .sourceDetails(details) + .metadata(metadata) + .shape(shape.getShape()) + .subnetId(subnet.getId()) + .build()) + .build()); + + return response.getInstance(); + } } diff --git a/bmc-examples/src/main/java/KmsExample.java b/bmc-examples/src/main/java/KmsExample.java new file mode 100644 index 00000000000..8dec8a2e649 --- /dev/null +++ b/bmc-examples/src/main/java/KmsExample.java @@ -0,0 +1,388 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +import com.oracle.bmc.Region; +import com.oracle.bmc.auth.AuthenticationDetailsProvider; +import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider; +import com.oracle.bmc.keymanagement.KmsCryptoClient; +import com.oracle.bmc.keymanagement.KmsManagementClient; +import com.oracle.bmc.keymanagement.KmsVaultClient; +import com.oracle.bmc.keymanagement.model.CreateKeyDetails; +import com.oracle.bmc.keymanagement.model.CreateVaultDetails; +import com.oracle.bmc.keymanagement.model.DecryptDataDetails; +import com.oracle.bmc.keymanagement.model.EncryptDataDetails; +import com.oracle.bmc.keymanagement.model.GenerateKeyDetails; +import com.oracle.bmc.keymanagement.model.KeyShape; +import com.oracle.bmc.keymanagement.model.KeySummary; +import com.oracle.bmc.keymanagement.model.KeyVersionSummary; +import com.oracle.bmc.keymanagement.model.ScheduleVaultDeletionDetails; +import com.oracle.bmc.keymanagement.model.UpdateKeyDetails; +import com.oracle.bmc.keymanagement.model.UpdateVaultDetails; +import com.oracle.bmc.keymanagement.model.Vault; +import com.oracle.bmc.keymanagement.model.VaultSummary; +import com.oracle.bmc.keymanagement.requests.CancelVaultDeletionRequest; +import com.oracle.bmc.keymanagement.requests.CreateKeyRequest; +import com.oracle.bmc.keymanagement.requests.CreateKeyVersionRequest; +import com.oracle.bmc.keymanagement.requests.CreateVaultRequest; +import com.oracle.bmc.keymanagement.requests.DecryptRequest; +import com.oracle.bmc.keymanagement.requests.DisableKeyRequest; +import com.oracle.bmc.keymanagement.requests.EnableKeyRequest; +import com.oracle.bmc.keymanagement.requests.EncryptRequest; +import com.oracle.bmc.keymanagement.requests.GenerateDataEncryptionKeyRequest; +import com.oracle.bmc.keymanagement.requests.GetKeyRequest; +import com.oracle.bmc.keymanagement.requests.GetVaultRequest; +import com.oracle.bmc.keymanagement.requests.ListKeyVersionsRequest; +import com.oracle.bmc.keymanagement.requests.ListKeysRequest; +import com.oracle.bmc.keymanagement.requests.ListVaultsRequest; +import com.oracle.bmc.keymanagement.requests.ScheduleVaultDeletionRequest; +import com.oracle.bmc.keymanagement.requests.UpdateKeyRequest; +import com.oracle.bmc.keymanagement.requests.UpdateVaultRequest; +import com.oracle.bmc.keymanagement.responses.CancelVaultDeletionResponse; +import com.oracle.bmc.keymanagement.responses.CreateKeyResponse; +import com.oracle.bmc.keymanagement.responses.CreateKeyVersionResponse; +import com.oracle.bmc.keymanagement.responses.CreateVaultResponse; +import com.oracle.bmc.keymanagement.responses.DecryptResponse; +import com.oracle.bmc.keymanagement.responses.DisableKeyResponse; +import com.oracle.bmc.keymanagement.responses.EnableKeyResponse; +import com.oracle.bmc.keymanagement.responses.EncryptResponse; +import com.oracle.bmc.keymanagement.responses.GenerateDataEncryptionKeyResponse; +import com.oracle.bmc.keymanagement.responses.GetKeyResponse; +import com.oracle.bmc.keymanagement.responses.GetVaultResponse; +import com.oracle.bmc.keymanagement.responses.ListKeyVersionsResponse; +import com.oracle.bmc.keymanagement.responses.ListKeysResponse; +import com.oracle.bmc.keymanagement.responses.ListVaultsResponse; +import com.oracle.bmc.keymanagement.responses.ScheduleVaultDeletionResponse; +import com.oracle.bmc.keymanagement.responses.UpdateKeyResponse; +import com.oracle.bmc.keymanagement.responses.UpdateVaultResponse; +import org.apache.commons.codec.binary.Base64; +import org.apache.commons.lang3.StringUtils; + +/** + * This class contains examples which cover basic KMS usage. + * + * These examples assume you already have a Vault in ACTIVE state. If you need to create a new Vault, please + * refer to the createVaultTest method in this class. Please keep in mind that KMS does not support immediate + * deletion of Vaults because of the high risk; instead, you need to schedule the deletion of a Vault and a + * retention period of 7-30 days will be enforced before the Vault is deleted. During the retention period, you + * can cancel the deletion and the Vault will be ACTIVE again. Be careful before creating a Vault to avoid + * unnecessary expenses. + */ +public class KmsExample { + + private static final int DEFAULT_KEY_LENGTH = 32; + private static final long TRANSIENT_STATE_WAIT_TIME_MS = 1000L * 30L; + + // The KeyShape used for testing + private static final KeyShape TEST_KEY_SHAPE = + KeyShape.builder().algorithm(KeyShape.Algorithm.Aes).length(DEFAULT_KEY_LENGTH).build(); + + // Please pass in the compartmentId and the vaultId as the first and second argument + public static void main(final String[] args) throws Exception { + + // Read in compartmentId and vaultId and perform basic validations. + final String compartmentId = args[0]; + final String vaultId = args[1]; + if (StringUtils.isBlank(compartmentId) || StringUtils.isBlank(vaultId)) { + System.out.println("compartmentId and vaultId cannot be empty or null"); + return; + } + + // Configuring the AuthenticationDetailsProvider. It's assuming there is a default OCI config file + // "", and a profile in that config with the name "DEFAULT". Make changes to the following + // line if needed. + final String configurationFilePath = "~/.oci/config"; + final String profile = "DEFAULT"; + + final AuthenticationDetailsProvider provider = + new ConfigFileAuthenticationDetailsProvider(configurationFilePath, profile); + + // Initialize the KMS Clients. KMS has three clients as following: + // * KmsVaultClient: The client for Vault management + // * KmsManagementClient: The client for Key management (ControlPlane) + // * KmsCryptoClient: The client for data encryption and decryption (DataPlane) + KmsVaultClient kmsVaultClient = new KmsVaultClient(provider); + + // Using the us-ashburn-1 in this example, choose a different region if needed + kmsVaultClient.setRegion(Region.US_ASHBURN_1); + + KmsManagementClient kmsManagementClient = new KmsManagementClient(provider); + KmsCryptoClient kmsCryptoClient = new KmsCryptoClient(provider); + + // Get the details of the given Vault + Vault vault = getVaultTest(kmsVaultClient, vaultId); + + // The ManagementClient and CryptoClient use Vault specific endpoints; Set them now. + kmsManagementClient.setEndpoint(vault.getManagementEndpoint()); + kmsCryptoClient.setEndpoint(vault.getCryptoEndpoint()); + + // Vault Operations + updateVaultTest(kmsVaultClient, vault.getId()); + listVaultsTest(kmsVaultClient, compartmentId); + scheduleVaultDeletionTest(kmsVaultClient, vault.getId()); + // After scheduling deletion, the Vault will stay in SCHEDULING_DELETION state shortly and then + // transit to PENDING_DELETION state. Wait a bit for the transition to happen. + System.out.println("Wait a bit for the deletion scheduling to finish"); + Thread.sleep(TRANSIENT_STATE_WAIT_TIME_MS); + + cancelVaultDeletionTest(kmsVaultClient, vault.getId()); + // After cancelling deletion, the Vault will stay in CANCELLING_DELETION state shortly and then + // transit to ACTIVE state. Wait a bit for the transition to happen. + System.out.println("Wait a bit for the deletion cancelling to finish"); + Thread.sleep(TRANSIENT_STATE_WAIT_TIME_MS); + + // Management / Key Operations + String keyId = createKeyTest(kmsManagementClient, compartmentId); + // After creating a Key, the Key will stay in CREATING state shortly and then + // transit to ENABLED state. Wait a bit for the transition to happen. + System.out.println("Wait a bit for Key creation to finish"); + Thread.sleep(TRANSIENT_STATE_WAIT_TIME_MS); + + getKeyTest(kmsManagementClient, keyId); + updateKeyTest(kmsManagementClient, keyId); + listKeysTest(kmsManagementClient, compartmentId); + disableKeyTest(kmsManagementClient, keyId); + // After disabling a Key, the Key will stay in DISABLING state shortly and then + // transit to DISABLED state. Wait a bit for the transition to happen. + System.out.println("Wait a bit for Key disabling to finish"); + Thread.sleep(TRANSIENT_STATE_WAIT_TIME_MS); + + enableKeyTest(kmsManagementClient, keyId); + // After enabling a Key, the Key will stay in ENABLING state shortly and then + // transit to ENABLED state. Wait a bit for the transition to happen. + System.out.println("Wait a bit for Key enabling to finish"); + Thread.sleep(TRANSIENT_STATE_WAIT_TIME_MS); + + createKeyVersionTest(kmsManagementClient, keyId); + listKeyVersionsTest(kmsManagementClient, keyId); + + // Crypto Operations + String ciphertext = encryptTest(kmsCryptoClient, keyId); + decryptTest(kmsCryptoClient, keyId, ciphertext); + generateDataEncryptionKeyTest(kmsCryptoClient, keyId); + } + + public static Vault createVaultTest(KmsVaultClient kmsVaultClient, String compartmentId) { + System.out.println("CreateVault Test: "); + CreateVaultDetails createVaultDetails = + CreateVaultDetails.builder() + .compartmentId(compartmentId) + .displayName("Test-Vault-V1") + .vaultType(CreateVaultDetails.VaultType.VirtualPrivate) + .build(); + + CreateVaultRequest request = + CreateVaultRequest.builder().createVaultDetails(createVaultDetails).build(); + + CreateVaultResponse response = kmsVaultClient.createVault(request); + System.out.println("Newly Created Vault: "); + System.out.println(response.getVault()); + return response.getVault(); + } + + public static Vault getVaultTest(KmsVaultClient kmsVaultClient, String vaultId) { + System.out.println("GetVault Test: "); + GetVaultRequest getVaultRequest = GetVaultRequest.builder().vaultId(vaultId).build(); + GetVaultResponse response = kmsVaultClient.getVault(getVaultRequest); + System.out.println("Vault Retrieved: "); + System.out.println(response.getVault()); + return response.getVault(); + } + + public static void listVaultsTest(KmsVaultClient kmsVaultClient, String compartmentId) { + System.out.println("ListVaults Test: "); + ListVaultsRequest listVaultsRequest = + ListVaultsRequest.builder().compartmentId(compartmentId).build(); + ListVaultsResponse response = kmsVaultClient.listVaults(listVaultsRequest); + + System.out.println("ListVaults Response: "); + for (VaultSummary vault : response.getItems()) { + System.out.println(vault); + } + System.out.println(); + } + + public static void updateVaultTest(KmsVaultClient kmsVaultClient, String vaultId) { + System.out.println("UpdateVault Test: "); + UpdateVaultDetails updateVaultDetails = + UpdateVaultDetails.builder().displayName("Test-Vault-V2").build(); + UpdateVaultRequest updateVaultRequest = + UpdateVaultRequest.builder() + .updateVaultDetails(updateVaultDetails) + .vaultId(vaultId) + .build(); + UpdateVaultResponse response = kmsVaultClient.updateVault(updateVaultRequest); + System.out.println("Updated Vault: "); + System.out.println(response.getVault()); + System.out.println(); + } + + public static void scheduleVaultDeletionTest(KmsVaultClient kmsVaultClient, String vaultId) { + System.out.println("ScheduleVaultDeletion Test: "); + ScheduleVaultDeletionDetails scheduleVaultDeletionDetails = + ScheduleVaultDeletionDetails.builder().timeOfDeletion(null).build(); + ScheduleVaultDeletionRequest scheduleVaultDeletionRequest = + ScheduleVaultDeletionRequest.builder() + .scheduleVaultDeletionDetails(scheduleVaultDeletionDetails) + .vaultId(vaultId) + .build(); + ScheduleVaultDeletionResponse response = + kmsVaultClient.scheduleVaultDeletion(scheduleVaultDeletionRequest); + System.out.println("Deletion Scheduled Successfully, Updated Vault: "); + System.out.println(response.getVault()); + System.out.println(); + } + + public static void cancelVaultDeletionTest(KmsVaultClient kmsVaultClient, String vaultId) { + System.out.println("CancelVaultDeletion Test: "); + CancelVaultDeletionRequest cancelVaultDeletionRequest = + CancelVaultDeletionRequest.builder().vaultId(vaultId).build(); + CancelVaultDeletionResponse response = + kmsVaultClient.cancelVaultDeletion(cancelVaultDeletionRequest); + System.out.println("Deletion Cancelled Successfully, Updated Vault: "); + System.out.println(response.getVault()); + System.out.println(); + } + + public static String createKeyTest( + KmsManagementClient kmsManagementClient, String compartmentId) { + System.out.println("CreateKey Test: "); + CreateKeyDetails createKeyDetails = + CreateKeyDetails.builder() + .keyShape(TEST_KEY_SHAPE) + .compartmentId(compartmentId) + .displayName("Test_Key_V1") + .build(); + CreateKeyRequest createKeyRequest = + CreateKeyRequest.builder().createKeyDetails(createKeyDetails).build(); + CreateKeyResponse response = kmsManagementClient.createKey(createKeyRequest); + System.out.println("Newly Created Key: "); + System.out.println(response.getKey()); + System.out.println(); + return response.getKey().getId(); + } + + public static void getKeyTest(KmsManagementClient kmsManagementClient, String keyId) { + System.out.println("GetKey Test: "); + GetKeyRequest getKeyRequest = GetKeyRequest.builder().keyId(keyId).build(); + GetKeyResponse response = kmsManagementClient.getKey(getKeyRequest); + System.out.println("Key Retrieved: "); + System.out.println(response.getKey()); + } + + public static void listKeysTest(KmsManagementClient kmsManagementClient, String compartmentId) { + System.out.println("ListKeys Test: "); + ListKeysRequest listKeysRequest = + ListKeysRequest.builder().compartmentId(compartmentId).build(); + ListKeysResponse response = kmsManagementClient.listKeys(listKeysRequest); + + System.out.println("ListKeys Response: "); + for (KeySummary key : response.getItems()) { + System.out.println(key); + } + System.out.println(); + } + + public static void updateKeyTest(KmsManagementClient kmsManagementClient, String keyId) { + System.out.println("UpdateKey Test: "); + UpdateKeyDetails updateKeyDetails = + UpdateKeyDetails.builder().displayName("Test_Key_V2").build(); + UpdateKeyRequest updateKeyRequest = + UpdateKeyRequest.builder().updateKeyDetails(updateKeyDetails).keyId(keyId).build(); + UpdateKeyResponse response = kmsManagementClient.updateKey(updateKeyRequest); + System.out.println("Updated Key: "); + System.out.println(response.getKey()); + System.out.println(); + } + + public static void disableKeyTest(KmsManagementClient kmsManagementClient, String keyId) { + System.out.println("DisableKey Test: "); + DisableKeyRequest disableKeyRequest = DisableKeyRequest.builder().keyId(keyId).build(); + DisableKeyResponse response = kmsManagementClient.disableKey(disableKeyRequest); + System.out.println("Key Disabled Successfully, Updated Key: "); + System.out.println(response.getKey()); + System.out.println(); + } + + public static void enableKeyTest(KmsManagementClient kmsManagementClient, String keyId) { + System.out.println("EnableKey Test: "); + EnableKeyRequest enableKeyRequest = EnableKeyRequest.builder().keyId(keyId).build(); + EnableKeyResponse response = kmsManagementClient.enableKey(enableKeyRequest); + System.out.println("Key Enabled Successfully, Updated Key: "); + System.out.println(response.getKey()); + System.out.println(); + } + + public static void createKeyVersionTest(KmsManagementClient kmsManagementClient, String keyId) { + System.out.println("CreateKeyVersion Test: "); + CreateKeyVersionRequest createKeyVersionRequest = + CreateKeyVersionRequest.builder().keyId(keyId).build(); + CreateKeyVersionResponse response = + kmsManagementClient.createKeyVersion(createKeyVersionRequest); + System.out.println("Newly Created KeyVersion: "); + System.out.println(response.getKeyVersion()); + System.out.println(); + } + + public static void listKeyVersionsTest(KmsManagementClient kmsManagementClient, String keyId) { + System.out.println("ListKeyVersions Test: "); + ListKeyVersionsRequest listKeyVersionsRequest = + ListKeyVersionsRequest.builder().keyId(keyId).build(); + ListKeyVersionsResponse response = + kmsManagementClient.listKeyVersions(listKeyVersionsRequest); + System.out.println("ListKeyVersions Response: "); + for (KeyVersionSummary keyVersion : response.getItems()) { + System.out.println(keyVersion); + } + System.out.println(); + } + + public static String encryptTest(KmsCryptoClient kmsCryptoClient, String keyId) { + System.out.println("Encrypt Test: "); + String plaintext = "I love OCI!"; + EncryptDataDetails encryptDataDetails = + EncryptDataDetails.builder() + .keyId(keyId) + .plaintext(Base64.encodeBase64String(plaintext.getBytes())) + .build(); + EncryptRequest encryptRequest = + EncryptRequest.builder().encryptDataDetails(encryptDataDetails).build(); + EncryptResponse response = kmsCryptoClient.encrypt(encryptRequest); + + System.out.println("Plaintext: " + plaintext); + System.out.println("Cipheretext: " + response.getEncryptedData().getCiphertext()); + System.out.println(); + return response.getEncryptedData().getCiphertext(); + } + + public static void decryptTest( + KmsCryptoClient kmsCryptoClient, String keyId, String cipherText) { + System.out.println("Decrypt Test: "); + DecryptDataDetails decryptDataDetails = + DecryptDataDetails.builder().ciphertext(cipherText).keyId(keyId).build(); + DecryptRequest decryptRequest = + DecryptRequest.builder().decryptDataDetails(decryptDataDetails).build(); + DecryptResponse response = kmsCryptoClient.decrypt(decryptRequest); + System.out.println("Plaintext: " + response.getDecryptedData().getPlaintext()); + System.out.println(); + } + + public static void generateDataEncryptionKeyTest( + KmsCryptoClient kmsCryptoClient, String keyId) { + System.out.println("GenerateDataEncryptionKey Test: "); + GenerateKeyDetails generateKeyDetails = + GenerateKeyDetails.builder() + .keyId(keyId) + .keyShape(TEST_KEY_SHAPE) + .includePlaintextKey(true) + .build(); + GenerateDataEncryptionKeyRequest generateDataEncryptionKeyRequest = + GenerateDataEncryptionKeyRequest.builder() + .generateKeyDetails(generateKeyDetails) + .build(); + GenerateDataEncryptionKeyResponse response = + kmsCryptoClient.generateDataEncryptionKey(generateDataEncryptionKeyRequest); + System.out.println("GenerateDataEncryptionKey Response: "); + System.out.println(response.getGeneratedKey()); + System.out.println(); + } +} diff --git a/bmc-examples/src/main/java/ObjectStorageUpdateBucketKmsKeyExample.java b/bmc-examples/src/main/java/ObjectStorageUpdateBucketKmsKeyExample.java new file mode 100644 index 00000000000..364c02f6dbb --- /dev/null +++ b/bmc-examples/src/main/java/ObjectStorageUpdateBucketKmsKeyExample.java @@ -0,0 +1,122 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +import com.google.common.collect.ImmutableMap; +import com.oracle.bmc.ConfigFileReader; +import com.oracle.bmc.Region; +import com.oracle.bmc.auth.AuthenticationDetailsProvider; +import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider; +import com.oracle.bmc.objectstorage.ObjectStorageClient; +import com.oracle.bmc.objectstorage.model.CreateBucketDetails; +import com.oracle.bmc.objectstorage.model.UpdateBucketDetails; +import com.oracle.bmc.objectstorage.requests.CreateBucketRequest; +import com.oracle.bmc.objectstorage.requests.GetNamespaceRequest; +import com.oracle.bmc.objectstorage.requests.UpdateBucketRequest; +import com.oracle.bmc.objectstorage.responses.CreateBucketResponse; +import com.oracle.bmc.objectstorage.responses.UpdateBucketResponse; + +public class ObjectStorageUpdateBucketKmsKeyExample { + + private static final String CONFIG_LOCATION = "~/.oci/config"; + private static final String CONFIG_PROFILE = "DEFAULT"; + + /** + * The entry point for the example. + * + * @param args Arguments to provide to the example. The following arguments are expected: + *

+ */ + public static void main(String[] args) throws Exception { + if (args.length != 4) { + throw new IllegalArgumentException( + "Unexpected number of arguments received. Consult the script header comments for expected arguments"); + } + final String compartmentId = args[0]; + final String bucketName = args[1]; + final String kmsKeyOcid = args[2]; + final String kmsKeyUpdateOcid = args[3]; + + final ConfigFileReader.ConfigFile configFile = + ConfigFileReader.parse(CONFIG_LOCATION, CONFIG_PROFILE); + final AuthenticationDetailsProvider provider = + new ConfigFileAuthenticationDetailsProvider(configFile); + ObjectStorageClient objectStorageClient = new ObjectStorageClient(provider); + objectStorageClient.setRegion(Region.US_PHOENIX_1); + + final String namespace = + objectStorageClient.getNamespace(GetNamespaceRequest.builder().build()).getValue(); + + // create bucket with kmsKeyId + final CreateBucketDetails createBucketDetails = + CreateBucketDetails.builder() + .compartmentId(compartmentId) + .name(bucketName) + .kmsKeyId(kmsKeyOcid) + .build(); + final CreateBucketResponse createResponse = + objectStorageClient.createBucket( + CreateBucketRequest.builder() + .namespaceName(namespace) + .createBucketDetails(createBucketDetails) + .build()); + System.out.println("Created a bucket with kmsKey:\n " + createResponse.getBucket()); + + // update bucket kmsKeyId to a new kmsKeyId + final UpdateBucketDetails updateBucketkmsKeyId = + UpdateBucketDetails.builder() + .namespace(namespace) + .name(bucketName) + .kmsKeyId(kmsKeyUpdateOcid) + .build(); + UpdateBucketResponse updateResponse = + objectStorageClient.updateBucket( + UpdateBucketRequest.builder() + .namespaceName(namespace) + .bucketName(bucketName) + .updateBucketDetails(updateBucketkmsKeyId) + .build()); + System.out.println("Updated kmsKeyId of a to " + updateResponse.getBucket().getKmsKeyId()); + + // update bucket metadata without touching kmsKeyId + final UpdateBucketDetails updateBucketMetadata = + UpdateBucketDetails.builder() + .namespace(namespace) + .name(bucketName) + .metadata(ImmutableMap.of("a", "b")) + .build(); + updateResponse = + objectStorageClient.updateBucket( + UpdateBucketRequest.builder() + .namespaceName(namespace) + .bucketName(bucketName) + .updateBucketDetails(updateBucketMetadata) + .build()); + System.out.println( + "Update bucket without touching kmsKeyId " + + updateResponse.getBucket().getKmsKeyId()); + + // remove kmsKeyId from bucket + final UpdateBucketDetails removeBucketKmsKeyId = + UpdateBucketDetails.builder() + .namespace(namespace) + .name(bucketName) + .kmsKeyId( + "") // "" means remove the current kmsKeyId of the bucket if it has one + .build(); + updateResponse = + objectStorageClient.updateBucket( + UpdateBucketRequest.builder() + .namespaceName(namespace) + .bucketName(bucketName) + .updateBucketDetails(removeBucketKmsKeyId) + .build()); + System.out.println( + "Removed kmsKey from a bucket, now the kmsKey is " + + updateResponse.getBucket().getKmsKeyId()); + } +} diff --git a/bmc-examples/src/main/java/UpdateVolumeKmsKeyIdExample.java b/bmc-examples/src/main/java/UpdateVolumeKmsKeyIdExample.java new file mode 100644 index 00000000000..496b4a16fee --- /dev/null +++ b/bmc-examples/src/main/java/UpdateVolumeKmsKeyIdExample.java @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +import com.oracle.bmc.Region; +import com.oracle.bmc.auth.AuthenticationDetailsProvider; +import com.oracle.bmc.auth.ConfigFileAuthenticationDetailsProvider; +import com.oracle.bmc.core.Blockstorage; +import com.oracle.bmc.core.BlockstorageClient; +import com.oracle.bmc.core.BlockstorageWaiters; +import com.oracle.bmc.core.model.CreateVolumeDetails; +import com.oracle.bmc.core.model.Instance; +import com.oracle.bmc.core.model.UpdateVolumeKmsKeyDetails; +import com.oracle.bmc.core.model.Volume; +import com.oracle.bmc.core.requests.CreateVolumeRequest; +import com.oracle.bmc.core.requests.DeleteVolumeKmsKeyRequest; +import com.oracle.bmc.core.requests.GetInstanceRequest; +import com.oracle.bmc.core.requests.GetVolumeRequest; +import com.oracle.bmc.core.requests.UpdateVolumeKmsKeyRequest; +import com.oracle.bmc.core.responses.GetInstanceResponse; +import com.oracle.bmc.core.responses.GetVolumeResponse; +import com.oracle.bmc.identity.Identity; +import com.oracle.bmc.identity.IdentityClient; +import com.oracle.bmc.identity.model.AvailabilityDomain; +import com.oracle.bmc.identity.requests.ListAvailabilityDomainsRequest; +import com.oracle.bmc.identity.responses.ListAvailabilityDomainsResponse; + +import java.io.IOException; +import java.util.List; + +/** + * This example will demo how to use CRUD API to manipulate volume's KMS key. + * It will do follow things: + * 1) Create a volume with Oracle default encryption key. + * 2) User provide their own kms key to protect the volume. + * 3) User delete kms key and use default encryption key to protect the volume. + */ +public class UpdateVolumeKmsKeyIdExample { + public static void main(String[] args) throws Exception { + + // TODO: Fill in these values + String compartmentId = "A valid compartment OCID"; + String blockStorageDisplayName = "blockStorageDisplayName"; + String configurationFilePath = "~/.oci/config"; + String profile = "DEFAULT"; + + // When an instance is created, a boot volume is created at the same time. User could choose to use their own kms key to encrypt the data. + // fill out necessary kms key information to use your own key to protect kms. More information of volume security please refer to https://cloud.oracle.com/storage/block-volume/faq + String kmsKeyId = "SOME VALID KEY OCID"; + + AuthenticationDetailsProvider provider = + new ConfigFileAuthenticationDetailsProvider(configurationFilePath, profile); + + BlockstorageClient client = new BlockstorageClient(provider); + + // TODO: For this example we're just using the first AD returned. + // You'll probably want different logic around which AD to use + List availabilityDomains = + getAvailabilityDomains(provider, compartmentId); + AvailabilityDomain adToUse = availabilityDomains.get(1); + + CreateVolumeDetails createVolumeDetails = + CreateVolumeDetails.builder() + .availabilityDomain(adToUse.getName()) + .displayName(blockStorageDisplayName) + .compartmentId(compartmentId) + .build(); + CreateVolumeRequest createVolumeRequest = + CreateVolumeRequest.builder().createVolumeDetails(createVolumeDetails).build(); + System.out.println("started to create volume."); + Volume volume = client.createVolume(createVolumeRequest).getVolume(); + + System.out.println("checking if the volume is ready."); + BlockstorageWaiters waiter = client.getWaiters(); + GetVolumeResponse response = + waiter.forVolume( + GetVolumeRequest.builder().volumeId(volume.getId()).build(), + Volume.LifecycleState.Available) + .execute(); + + System.out.println("volume is ready."); + + UpdateVolumeKmsKeyDetails updateVolumeKmsKeyDetails = + UpdateVolumeKmsKeyDetails.builder().kmsKeyId(kmsKeyId).build(); + + UpdateVolumeKmsKeyRequest updateVolumeKmsKeyRequest = + UpdateVolumeKmsKeyRequest.builder() + .updateVolumeKmsKeyDetails(updateVolumeKmsKeyDetails) + .volumeId(volume.getId()) + .build(); + + System.out.println("started to update volume kms key."); + client.updateVolumeKmsKey(updateVolumeKmsKeyRequest); + System.out.println("checking if the volume is ready."); + // Data will remain the same, but now protected by the new key. Old key (if any) could be removed safely if the volume is marked as ready and if is ONLY used to protect this volume. + + GetVolumeResponse updateKeyResponse = + waiter.forVolume( + GetVolumeRequest.builder().volumeId(volume.getId()).build(), + Volume.LifecycleState.Available) + .execute(); + + System.out.println( + "Finished updating volume kms key. Now the kms key is :" + + updateKeyResponse.getVolume().getKmsKeyId()); + + System.out.println("started to delete volume kms key."); + + DeleteVolumeKmsKeyRequest deleteVolumeKmsKeyRequest = + DeleteVolumeKmsKeyRequest.builder().volumeId(volume.getId()).build(); + client.deleteVolumeKmsKey(deleteVolumeKmsKeyRequest); + System.out.println("checking if the volume is ready."); + GetVolumeResponse deleteKeyResponse = + waiter.forVolume( + GetVolumeRequest.builder().volumeId(volume.getId()).build(), + Volume.LifecycleState.Available) + .execute(); + + System.out.println( + "Finished updating volume kms key. Now the kms key is :" + + deleteKeyResponse.getVolume().getKmsKeyId()); + + System.out.println("This is the example for update/delete volume's kms key."); + + client.close(); + } + + private static List getAvailabilityDomains( + AuthenticationDetailsProvider provider, String compartmentId) throws Exception { + + Identity identityClient = new IdentityClient(provider); + identityClient.setRegion(Region.US_ASHBURN_1); + + ListAvailabilityDomainsResponse listAvailabilityDomainsResponse = + identityClient.listAvailabilityDomains( + ListAvailabilityDomainsRequest.builder() + .compartmentId(compartmentId) + .build()); + + identityClient.close(); + + return listAvailabilityDomainsResponse.getItems(); + } +} diff --git a/bmc-examples/src/main/java/VolumeAttachmentExample.java b/bmc-examples/src/main/java/VolumeAttachmentExample.java index 4d674ae4b77..ef370522142 100644 --- a/bmc-examples/src/main/java/VolumeAttachmentExample.java +++ b/bmc-examples/src/main/java/VolumeAttachmentExample.java @@ -93,7 +93,7 @@ public class VolumeAttachmentExample { private static final String INSTANCE_SHAPE = "VM.Standard1.1"; private static final String INSTANCE_OS = "Oracle Linux"; - private static final String INSTANCE_OS_VERSION = "7.4"; + private static final String INSTANCE_OS_VERSION = "7.5"; private static final String INSTANCE_DISPLAY_NAME = "VolAttachExampleInstance"; /** @@ -102,6 +102,7 @@ public class VolumeAttachmentExample { * @param args Arguments to provide to the example. The following arguments are expected: *
    *
  • The OCID of the compartment where the volumes and associated resources will be created
  • + *
  • Optional. The OCID of the KMS key used to generated volume's data encryption key.
  • *
*/ public static void main(String[] args) throws Exception { @@ -111,7 +112,7 @@ public static void main(String[] args) throws Exception { } final String compartmentId = args[0]; - + final String kmsKeyId = args.length == 1 ? null : args[2]; final AuthenticationDetailsProvider provider = new ConfigFileAuthenticationDetailsProvider(CONFIG_LOCATION, CONFIG_PROFILE); final BlockstorageClient blockStorageClient = new BlockstorageClient(provider); @@ -145,9 +146,19 @@ public static void main(String[] args) throws Exception { System.out.println(); volumeOne = - createVolume(blockStorageClient, compartmentId, adToUse, VOL_ONE_DISPLAY_NAME); + createVolume( + blockStorageClient, + compartmentId, + adToUse, + kmsKeyId, + VOL_ONE_DISPLAY_NAME); volumeTwo = - createVolume(blockStorageClient, compartmentId, adToUse, VOL_TWO_DISPLAY_NAME); + createVolume( + blockStorageClient, + compartmentId, + adToUse, + kmsKeyId, + VOL_TWO_DISPLAY_NAME); final VolumeAttachment iscsiAttachment = attachIscsiVolume(computeClient, volumeOne, instance); @@ -214,6 +225,7 @@ private static Volume createVolume( final BlockstorageClient blockStorageClient, final String compartmentId, final AvailabilityDomain availabilityDomain, + final String kmsKeyId, final String displayName) throws Exception { @@ -224,11 +236,11 @@ private static Volume createVolume( blockStorageClient.createVolume( CreateVolumeRequest.builder() .createVolumeDetails( - CreateVolumeDetails.builder() - .availabilityDomain(availabilityDomain.getName()) - .compartmentId(compartmentId) - .displayName(displayName) - .build()) + getCreateVolumeDetails( + compartmentId, + availabilityDomain, + displayName, + kmsKeyId)) .build()); System.out.println("Created volume: " + createResponse.getVolume().toString()); @@ -247,6 +259,27 @@ private static Volume createVolume( return getResponse.getVolume(); } + private static CreateVolumeDetails getCreateVolumeDetails( + final String compartmentId, + final AvailabilityDomain availabilityDomain, + final String displayName, + final String kmsKeyId) { + if (kmsKeyId == null) { + return CreateVolumeDetails.builder() + .availabilityDomain(availabilityDomain.getName()) + .compartmentId(compartmentId) + .displayName(displayName) + .build(); + } + + return CreateVolumeDetails.builder() + .availabilityDomain(availabilityDomain.getName()) + .compartmentId(compartmentId) + .kmsKeyId(kmsKeyId) + .displayName(displayName) + .build(); + } + /** * Deletes a volume and waits for it to be deleted * diff --git a/bmc-filestorage/pom.xml b/bmc-filestorage/pom.xml index ed223d08276..5094a6474ac 100644 --- a/bmc-filestorage/pom.xml +++ b/bmc-filestorage/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-filestorage/src/main/java/com/oracle/bmc/filestorage/FileStorageAsyncClient.java b/bmc-filestorage/src/main/java/com/oracle/bmc/filestorage/FileStorageAsyncClient.java index c0b8f7e01cc..31db98562d5 100644 --- a/bmc-filestorage/src/main/java/com/oracle/bmc/filestorage/FileStorageAsyncClient.java +++ b/bmc-filestorage/src/main/java/com/oracle/bmc/filestorage/FileStorageAsyncClient.java @@ -15,7 +15,10 @@ public class FileStorageAsyncClient implements FileStorageAsync { * Service instance for FileStorage. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("FILESTORAGE", "filestorage"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("FILESTORAGE") + .serviceEndpointPrefix("filestorage") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-filestorage/src/main/java/com/oracle/bmc/filestorage/FileStorageClient.java b/bmc-filestorage/src/main/java/com/oracle/bmc/filestorage/FileStorageClient.java index ac6853b5d7c..c5751463acc 100644 --- a/bmc-filestorage/src/main/java/com/oracle/bmc/filestorage/FileStorageClient.java +++ b/bmc-filestorage/src/main/java/com/oracle/bmc/filestorage/FileStorageClient.java @@ -15,7 +15,10 @@ public class FileStorageClient implements FileStorage { * Service instance for FileStorage. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("FILESTORAGE", "filestorage"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("FILESTORAGE") + .serviceEndpointPrefix("filestorage") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-full/pom.xml b/bmc-full/pom.xml index 42a65fb7a14..50b31d8a65e 100644 --- a/bmc-full/pom.xml +++ b/bmc-full/pom.xml @@ -4,7 +4,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml oci-java-sdk-full @@ -16,7 +16,7 @@ com.oracle.oci.sdk oci-java-sdk-bom - 1.2.46 + 1.2.47 pom import @@ -62,7 +62,6 @@ com.oracle.oci.sdk oci-java-sdk-objectstorage - pom com.oracle.oci.sdk @@ -72,5 +71,9 @@ com.oracle.oci.sdk oci-java-sdk-resourcesearch + + com.oracle.oci.sdk + oci-java-sdk-keymanagement + \ No newline at end of file diff --git a/bmc-identity/pom.xml b/bmc-identity/pom.xml index eb43373ec54..7b09dcbedfb 100644 --- a/bmc-identity/pom.xml +++ b/bmc-identity/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-identity/src/main/java/com/oracle/bmc/identity/IdentityAsyncClient.java b/bmc-identity/src/main/java/com/oracle/bmc/identity/IdentityAsyncClient.java index 1e02080490c..13ee4d34cf1 100644 --- a/bmc-identity/src/main/java/com/oracle/bmc/identity/IdentityAsyncClient.java +++ b/bmc-identity/src/main/java/com/oracle/bmc/identity/IdentityAsyncClient.java @@ -15,7 +15,10 @@ public class IdentityAsyncClient implements IdentityAsync { * Service instance for Identity. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("IDENTITY", "identity"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("IDENTITY") + .serviceEndpointPrefix("identity") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-identity/src/main/java/com/oracle/bmc/identity/IdentityClient.java b/bmc-identity/src/main/java/com/oracle/bmc/identity/IdentityClient.java index 0a94b1c2dc3..b07e8d76b99 100644 --- a/bmc-identity/src/main/java/com/oracle/bmc/identity/IdentityClient.java +++ b/bmc-identity/src/main/java/com/oracle/bmc/identity/IdentityClient.java @@ -15,7 +15,10 @@ public class IdentityClient implements Identity { * Service instance for Identity. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("IDENTITY", "identity"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("IDENTITY") + .serviceEndpointPrefix("identity") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-keymanagement/pom.xml b/bmc-keymanagement/pom.xml new file mode 100644 index 00000000000..f1552977178 --- /dev/null +++ b/bmc-keymanagement/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + com.oracle.oci.sdk + oci-java-sdk + 1.2.47 + ../pom.xml + + oci-java-sdk-keymanagement + Oracle Cloud Infrastructure SDK - Key Management + This project contains the SDK used for Oracle Cloud Infrastructure Key Management + https://docs.us-phoenix-1.oraclecloud.com/Content/API/SDKDocs/javasdk.htm + + + com.oracle.oci.sdk + oci-java-sdk-common + 1.2.47 + + + \ No newline at end of file diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/AbstractKmsCryptoClientBuilder.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/AbstractKmsCryptoClientBuilder.java new file mode 100644 index 00000000000..e3913e77996 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/AbstractKmsCryptoClientBuilder.java @@ -0,0 +1,49 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.Service; + +/** + * An abstract client builder for clients that need the cryptoEndpoint + * @param actual builder class + * @param client class + */ +public abstract class AbstractKmsCryptoClientBuilder + extends AbstractVaultBasedClientBuilder { + public AbstractKmsCryptoClientBuilder(Service service) { + super(service); + } + + protected String getEndpoint() { + String cryptoEndpoint = null; + + // vault and vault summary are exclusive + int endpointsProvided = 0; + if (vault != null) { + ++endpointsProvided; + } + if (vaultSummary != null) { + ++endpointsProvided; + } + if (endpoint != null) { + ++endpointsProvided; + } + if (endpointsProvided != 1) { + throw new IllegalArgumentException( + "Must provide exactly one of vault, vault summary, or endpoint"); + } + + if (vault != null) { + cryptoEndpoint = vault.getCryptoEndpoint(); + } + if (vaultSummary != null) { + cryptoEndpoint = vaultSummary.getCryptoEndpoint(); + } + if (endpoint != null) { + cryptoEndpoint = endpoint; + } + return cryptoEndpoint; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/AbstractKmsManagementClientBuilder.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/AbstractKmsManagementClientBuilder.java new file mode 100644 index 00000000000..e626890fe59 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/AbstractKmsManagementClientBuilder.java @@ -0,0 +1,50 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.Service; + +/** + * An abstract client builder for clients that need the managementEndpoint + * @param actual builder class + * @param client class + */ +public abstract class AbstractKmsManagementClientBuilder< + B extends AbstractKmsManagementClientBuilder, C> + extends AbstractVaultBasedClientBuilder { + public AbstractKmsManagementClientBuilder(Service service) { + super(service); + } + + protected String getEndpoint() { + String managementEndpoint = null; + + // vault and vault summary are exclusive + int endpointsProvided = 0; + if (vault != null) { + ++endpointsProvided; + } + if (vaultSummary != null) { + ++endpointsProvided; + } + if (endpoint != null) { + ++endpointsProvided; + } + if (endpointsProvided != 1) { + throw new IllegalArgumentException( + "Must provide exactly one of vault, vault summary, or endpoint"); + } + + if (vault != null) { + managementEndpoint = vault.getManagementEndpoint(); + } + if (vaultSummary != null) { + managementEndpoint = vaultSummary.getManagementEndpoint(); + } + if (endpoint != null) { + managementEndpoint = endpoint; + } + return managementEndpoint; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/AbstractVaultBasedClientBuilder.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/AbstractVaultBasedClientBuilder.java new file mode 100644 index 00000000000..d041ba0820b --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/AbstractVaultBasedClientBuilder.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.Service; +import com.oracle.bmc.common.ClientBuilderBase; +import com.oracle.bmc.keymanagement.model.Vault; +import com.oracle.bmc.keymanagement.model.VaultSummary; + +/** + * A builder for a client that requires a vault. + * @param actual class of the builder + * @param client class + */ +public abstract class AbstractVaultBasedClientBuilder + extends ClientBuilderBase { + protected Vault vault = null; + protected VaultSummary vaultSummary = null; + + /** + * Set the vault. May be null + * @param vault the vault to use. May be null. + * @return this builder + */ + public B vault(Vault vault) { + this.vault = vault; + return (B) this; + } + + /** + * Set the vault summary. May be null + * @param vaultSummary the vault summary to use. May be null + * @return this builder + */ + public B vaultSummary(VaultSummary vaultSummary) { + this.vaultSummary = vaultSummary; + return (B) this; + } + + public AbstractVaultBasedClientBuilder(Service service) { + super(service); + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCrypto.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCrypto.java new file mode 100644 index 00000000000..01e5446856d --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCrypto.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +public interface KmsCrypto extends AutoCloseable { + + /** + * Sets the endpoint to call (ex, https://www.example.com). + * @param endpoint The endpoint of the service. + */ + void setEndpoint(String endpoint); + + /** + * Decrypts data using the given DecryptDataDetails resource. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + DecryptResponse decrypt(DecryptRequest request); + + /** + * Encrypts data using the given EncryptDataDetails resource. + * Plaintext included in the example request is a base64-encoded value + * of a UTF-8 string. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + EncryptResponse encrypt(EncryptRequest request); + + /** + * Generates a key that you can use to encrypt or decrypt data. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + GenerateDataEncryptionKeyResponse generateDataEncryptionKey( + GenerateDataEncryptionKeyRequest request); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoAsync.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoAsync.java new file mode 100644 index 00000000000..461135d43b0 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoAsync.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +public interface KmsCryptoAsync extends AutoCloseable { + + /** + * Sets the endpoint to call (ex, https://www.example.com). + * @param endpoint The endpoint of the serice. + */ + void setEndpoint(String endpoint); + + /** + * Decrypts data using the given DecryptDataDetails resource. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future decrypt( + DecryptRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Encrypts data using the given EncryptDataDetails resource. + * Plaintext included in the example request is a base64-encoded value + * of a UTF-8 string. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future encrypt( + EncryptRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Generates a key that you can use to encrypt or decrypt data. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future generateDataEncryptionKey( + GenerateDataEncryptionKeyRequest request, + com.oracle.bmc.responses.AsyncHandler< + GenerateDataEncryptionKeyRequest, GenerateDataEncryptionKeyResponse> + handler); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoAsyncClient.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoAsyncClient.java new file mode 100644 index 00000000000..4d9c0cfada7 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoAsyncClient.java @@ -0,0 +1,468 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import java.util.Locale; +import com.oracle.bmc.keymanagement.internal.http.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class KmsCryptoAsyncClient implements KmsCryptoAsync { + /** + * Service instance for KmsCrypto. + */ + public static final com.oracle.bmc.Service SERVICE = + com.oracle.bmc.Services.serviceBuilder() + .serviceName("KMSCRYPTO") + .serviceEndpointPrefix("kms") + .build(); + + @lombok.Getter(value = lombok.AccessLevel.PACKAGE) + private final com.oracle.bmc.http.internal.RestClient client; + + private final com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider + authenticationDetailsProvider; + + /** + * Creates a new service instance using the given authentication provider. + * @param authenticationDetailsProvider The authentication details provider, required. + */ + public KmsCryptoAsyncClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider) { + this(authenticationDetailsProvider, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + */ + public KmsCryptoAsyncClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration) { + this(authenticationDetailsProvider, configuration, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + */ + public KmsCryptoAsyncClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + new com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory( + com.oracle.bmc.http.signing.SigningStrategy.STANDARD)); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + */ + public KmsCryptoAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + new java.util.ArrayList()); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + */ + public KmsCryptoAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + additionalClientConfigurators, + null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsCryptoAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators, + String endpoint) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory + .createDefaultRequestSignerFactories(), + additionalClientConfigurators, + endpoint); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param signingStrategyRequestSignerFactories The request signer factories for each signing strategy used to create the request signer + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsCryptoAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSignerFactory> + signingStrategyRequestSignerFactories, + java.util.List additionalClientConfigurators, + String endpoint) { + this.authenticationDetailsProvider = authenticationDetailsProvider; + com.oracle.bmc.http.internal.RestClientFactory restClientFactory = + com.oracle.bmc.http.internal.RestClientFactoryBuilder.builder() + .clientConfigurator(clientConfigurator) + .additionalClientConfigurators(additionalClientConfigurators) + .build(); + com.oracle.bmc.http.signing.RequestSigner defaultRequestSigner = + defaultRequestSignerFactory.createRequestSigner( + SERVICE, this.authenticationDetailsProvider); + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSigner> + requestSigners = new java.util.HashMap<>(); + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.BasicAuthenticationDetailsProvider) { + for (com.oracle.bmc.http.signing.SigningStrategy s : + com.oracle.bmc.http.signing.SigningStrategy.values()) { + requestSigners.put( + s, + signingStrategyRequestSignerFactories + .get(s) + .createRequestSigner(SERVICE, authenticationDetailsProvider)); + } + } + this.client = restClientFactory.create(defaultRequestSigner, requestSigners, configuration); + + if (endpoint != null) { + setEndpoint(endpoint); + } + } + + /** + * Create a builder for this client. + * @return builder + */ + public static com.oracle.bmc.keymanagement.KmsCryptoAsyncClientBuilder builder() { + return new com.oracle.bmc.keymanagement.KmsCryptoAsyncClientBuilder(SERVICE); + } + + @Override + public void setEndpoint(String endpoint) { + LOG.info("Setting endpoint to {}", endpoint); + client.setEndpoint(endpoint); + } + + @Override + public void close() { + client.close(); + } + + @Override + public java.util.concurrent.Future decrypt( + final DecryptRequest request, + final com.oracle.bmc.responses.AsyncHandler handler) { + LOG.trace("Called async decrypt"); + final DecryptRequest interceptedRequest = DecryptConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + DecryptConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = DecryptConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = + handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + DecryptRequest, DecryptResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post( + ib, + interceptedRequest.getDecryptDataDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post( + ib, + interceptedRequest.getDecryptDataDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, DecryptResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post( + ib, + interceptedRequest.getDecryptDataDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future encrypt( + final EncryptRequest request, + final com.oracle.bmc.responses.AsyncHandler handler) { + LOG.trace("Called async encrypt"); + final EncryptRequest interceptedRequest = EncryptConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + EncryptConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = EncryptConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = + handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + EncryptRequest, EncryptResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post( + ib, + interceptedRequest.getEncryptDataDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post( + ib, + interceptedRequest.getEncryptDataDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, EncryptResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post( + ib, + interceptedRequest.getEncryptDataDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future generateDataEncryptionKey( + final GenerateDataEncryptionKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler< + GenerateDataEncryptionKeyRequest, GenerateDataEncryptionKeyResponse> + handler) { + LOG.trace("Called async generateDataEncryptionKey"); + final GenerateDataEncryptionKeyRequest interceptedRequest = + GenerateDataEncryptionKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GenerateDataEncryptionKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function< + javax.ws.rs.core.Response, GenerateDataEncryptionKeyResponse> + transformer = GenerateDataEncryptionKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler< + GenerateDataEncryptionKeyRequest, GenerateDataEncryptionKeyResponse> + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + GenerateDataEncryptionKeyRequest, GenerateDataEncryptionKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post( + ib, + interceptedRequest.getGenerateKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post( + ib, + interceptedRequest.getGenerateKeyDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, GenerateDataEncryptionKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post( + ib, + interceptedRequest.getGenerateKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoAsyncClientBuilder.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoAsyncClientBuilder.java new file mode 100644 index 00000000000..a4c787d3a68 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoAsyncClientBuilder.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.Service; +import com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider; + +@lombok.extern.slf4j.Slf4j +public class KmsCryptoAsyncClientBuilder + extends AbstractKmsCryptoClientBuilder { + public KmsCryptoAsyncClientBuilder(Service service) { + super(service); + } + + @Override + public KmsCryptoAsyncClient build( + AbstractAuthenticationDetailsProvider authenticationDetailsProvider) { + String cryptoEndpoint = getEndpoint(); + + return new KmsCryptoAsyncClient( + authenticationDetailsProvider, + configuration, + clientConfigurator, + requestSignerFactory, + additionalClientConfigurators, + cryptoEndpoint); + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoClient.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoClient.java new file mode 100644 index 00000000000..307f29d8f49 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoClient.java @@ -0,0 +1,314 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import java.util.Locale; +import com.oracle.bmc.keymanagement.internal.http.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class KmsCryptoClient implements KmsCrypto { + /** + * Service instance for KmsCrypto. + */ + public static final com.oracle.bmc.Service SERVICE = + com.oracle.bmc.Services.serviceBuilder() + .serviceName("KMSCRYPTO") + .serviceEndpointPrefix("kms") + .build(); + // attempt twice if it's instance principals, immediately failures will try to refresh the token + private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; + + @lombok.Getter(value = lombok.AccessLevel.PACKAGE) + private final com.oracle.bmc.http.internal.RestClient client; + + private final com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider + authenticationDetailsProvider; + + /** + * Creates a new service instance using the given authentication provider. + * @param authenticationDetailsProvider The authentication details provider, required. + */ + public KmsCryptoClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider) { + this(authenticationDetailsProvider, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + */ + public KmsCryptoClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration) { + this(authenticationDetailsProvider, configuration, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + */ + public KmsCryptoClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + new com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory( + com.oracle.bmc.http.signing.SigningStrategy.STANDARD)); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + */ + public KmsCryptoClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + new java.util.ArrayList()); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + */ + public KmsCryptoClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + additionalClientConfigurators, + null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsCryptoClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators, + String endpoint) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory + .createDefaultRequestSignerFactories(), + additionalClientConfigurators, + endpoint); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param signingStrategyRequestSignerFactories The request signer factories for each signing strategy used to create the request signer + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsCryptoClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSignerFactory> + signingStrategyRequestSignerFactories, + java.util.List additionalClientConfigurators, + String endpoint) { + this.authenticationDetailsProvider = authenticationDetailsProvider; + com.oracle.bmc.http.internal.RestClientFactory restClientFactory = + com.oracle.bmc.http.internal.RestClientFactoryBuilder.builder() + .clientConfigurator(clientConfigurator) + .additionalClientConfigurators(additionalClientConfigurators) + .build(); + com.oracle.bmc.http.signing.RequestSigner defaultRequestSigner = + defaultRequestSignerFactory.createRequestSigner( + SERVICE, this.authenticationDetailsProvider); + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSigner> + requestSigners = new java.util.HashMap<>(); + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.BasicAuthenticationDetailsProvider) { + for (com.oracle.bmc.http.signing.SigningStrategy s : + com.oracle.bmc.http.signing.SigningStrategy.values()) { + requestSigners.put( + s, + signingStrategyRequestSignerFactories + .get(s) + .createRequestSigner(SERVICE, authenticationDetailsProvider)); + } + } + this.client = restClientFactory.create(defaultRequestSigner, requestSigners, configuration); + + if (endpoint != null) { + setEndpoint(endpoint); + } + } + + /** + * Create a builder for this client. + * @return builder + */ + public static com.oracle.bmc.keymanagement.KmsCryptoClientBuilder builder() { + return new com.oracle.bmc.keymanagement.KmsCryptoClientBuilder(SERVICE); + } + + @Override + public void setEndpoint(String endpoint) { + LOG.info("Setting endpoint to {}", endpoint); + client.setEndpoint(endpoint); + } + + @Override + public void close() { + client.close(); + } + + @Override + public DecryptResponse decrypt(DecryptRequest request) { + LOG.trace("Called decrypt"); + request = DecryptConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + DecryptConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + DecryptConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.post(ib, request.getDecryptDataDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public EncryptResponse encrypt(EncryptRequest request) { + LOG.trace("Called encrypt"); + request = EncryptConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + EncryptConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + EncryptConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.post(ib, request.getEncryptDataDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public GenerateDataEncryptionKeyResponse generateDataEncryptionKey( + GenerateDataEncryptionKeyRequest request) { + LOG.trace("Called generateDataEncryptionKey"); + request = GenerateDataEncryptionKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GenerateDataEncryptionKeyConverter.fromRequest(client, request); + com.google.common.base.Function< + javax.ws.rs.core.Response, GenerateDataEncryptionKeyResponse> + transformer = GenerateDataEncryptionKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.post(ib, request.getGenerateKeyDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + private boolean canRetryRequestIfRefreshableAuthTokenUsed(com.oracle.bmc.model.BmcException e) { + if (e.getStatusCode() == 401 + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + ((com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider) + .refresh(); + return true; + } + return false; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoClientBuilder.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoClientBuilder.java new file mode 100644 index 00000000000..fb8796a06e7 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsCryptoClientBuilder.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.Service; +import com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider; + +@lombok.extern.slf4j.Slf4j +public class KmsCryptoClientBuilder + extends AbstractKmsCryptoClientBuilder { + public KmsCryptoClientBuilder(Service service) { + super(service); + } + + @Override + public KmsCryptoClient build( + AbstractAuthenticationDetailsProvider authenticationDetailsProvider) { + String cryptoEndpoint = getEndpoint(); + + return new KmsCryptoClient( + authenticationDetailsProvider, + configuration, + clientConfigurator, + requestSignerFactory, + additionalClientConfigurators, + cryptoEndpoint); + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagement.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagement.java new file mode 100644 index 00000000000..3311f21535f --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagement.java @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +public interface KmsManagement extends AutoCloseable { + + /** + * Sets the endpoint to call (ex, https://www.example.com). + * @param endpoint The endpoint of the service. + */ + void setEndpoint(String endpoint); + + /** + * Creates a new key. + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + CreateKeyResponse createKey(CreateKeyRequest request); + + /** + * Generates new cryptographic material for a key. Key must be in an `ENABLED` state to be + * rotated. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + CreateKeyVersionResponse createKeyVersion(CreateKeyVersionRequest request); + + /** + * Disables a key to make it unavailable for encryption + * or decryption. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + DisableKeyResponse disableKey(DisableKeyRequest request); + + /** + * Enables a key to make it available for encryption or + * decryption. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + EnableKeyResponse enableKey(EnableKeyRequest request); + + /** + * Gets information about the specified key. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + GetKeyResponse getKey(GetKeyRequest request); + + /** + * Gets information about the specified key version. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + GetKeyVersionResponse getKeyVersion(GetKeyVersionRequest request); + + /** + * Lists all key versions for the specified key. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + ListKeyVersionsResponse listKeyVersions(ListKeyVersionsRequest request); + + /** + * Lists the keys in the specified vault and compartment. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + ListKeysResponse listKeys(ListKeysRequest request); + + /** + * Updates the properties of a key. Specifically, you can + * only update the `displayName` property. Furthermore, the + * key must in an `ACTIVE` or `CREATING` state. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + UpdateKeyResponse updateKey(UpdateKeyRequest request); + + /** + * Gets the pre-configured waiters available for resources for this service. + * + * @return The service waiters. + */ + KmsManagementWaiters getWaiters(); + + /** + * Gets the pre-configured paginators available for list operations in this service which may return multiple + * pages of data. These paginators provide an {@link java.lang.Iterable} interface so that service responses, or + * resources/records, can be iterated through without having to manually deal with pagination and page tokens. + * + * @return The service paginators. + */ + KmsManagementPaginators getPaginators(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementAsync.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementAsync.java new file mode 100644 index 00000000000..5c73b311b29 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementAsync.java @@ -0,0 +1,159 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +public interface KmsManagementAsync extends AutoCloseable { + + /** + * Sets the endpoint to call (ex, https://www.example.com). + * @param endpoint The endpoint of the serice. + */ + void setEndpoint(String endpoint); + + /** + * Creates a new key. + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future createKey( + CreateKeyRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Generates new cryptographic material for a key. Key must be in an `ENABLED` state to be + * rotated. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future createKeyVersion( + CreateKeyVersionRequest request, + com.oracle.bmc.responses.AsyncHandler + handler); + + /** + * Disables a key to make it unavailable for encryption + * or decryption. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future disableKey( + DisableKeyRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Enables a key to make it available for encryption or + * decryption. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future enableKey( + EnableKeyRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Gets information about the specified key. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future getKey( + GetKeyRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Gets information about the specified key version. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future getKeyVersion( + GetKeyVersionRequest request, + com.oracle.bmc.responses.AsyncHandler + handler); + + /** + * Lists all key versions for the specified key. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future listKeyVersions( + ListKeyVersionsRequest request, + com.oracle.bmc.responses.AsyncHandler + handler); + + /** + * Lists the keys in the specified vault and compartment. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future listKeys( + ListKeysRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Updates the properties of a key. Specifically, you can + * only update the `displayName` property. Furthermore, the + * key must in an `ACTIVE` or `CREATING` state. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future updateKey( + UpdateKeyRequest request, + com.oracle.bmc.responses.AsyncHandler handler); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementAsyncClient.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementAsyncClient.java new file mode 100644 index 00000000000..100d18c939c --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementAsyncClient.java @@ -0,0 +1,856 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import java.util.Locale; +import com.oracle.bmc.keymanagement.internal.http.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class KmsManagementAsyncClient implements KmsManagementAsync { + /** + * Service instance for KmsManagement. + */ + public static final com.oracle.bmc.Service SERVICE = + com.oracle.bmc.Services.serviceBuilder() + .serviceName("KMSMANAGEMENT") + .serviceEndpointPrefix("kms") + .build(); + + @lombok.Getter(value = lombok.AccessLevel.PACKAGE) + private final com.oracle.bmc.http.internal.RestClient client; + + private final com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider + authenticationDetailsProvider; + + /** + * Creates a new service instance using the given authentication provider. + * @param authenticationDetailsProvider The authentication details provider, required. + */ + public KmsManagementAsyncClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider) { + this(authenticationDetailsProvider, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + */ + public KmsManagementAsyncClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration) { + this(authenticationDetailsProvider, configuration, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + */ + public KmsManagementAsyncClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + new com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory( + com.oracle.bmc.http.signing.SigningStrategy.STANDARD)); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + */ + public KmsManagementAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + new java.util.ArrayList()); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + */ + public KmsManagementAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + additionalClientConfigurators, + null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsManagementAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators, + String endpoint) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory + .createDefaultRequestSignerFactories(), + additionalClientConfigurators, + endpoint); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param signingStrategyRequestSignerFactories The request signer factories for each signing strategy used to create the request signer + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsManagementAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSignerFactory> + signingStrategyRequestSignerFactories, + java.util.List additionalClientConfigurators, + String endpoint) { + this.authenticationDetailsProvider = authenticationDetailsProvider; + com.oracle.bmc.http.internal.RestClientFactory restClientFactory = + com.oracle.bmc.http.internal.RestClientFactoryBuilder.builder() + .clientConfigurator(clientConfigurator) + .additionalClientConfigurators(additionalClientConfigurators) + .build(); + com.oracle.bmc.http.signing.RequestSigner defaultRequestSigner = + defaultRequestSignerFactory.createRequestSigner( + SERVICE, this.authenticationDetailsProvider); + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSigner> + requestSigners = new java.util.HashMap<>(); + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.BasicAuthenticationDetailsProvider) { + for (com.oracle.bmc.http.signing.SigningStrategy s : + com.oracle.bmc.http.signing.SigningStrategy.values()) { + requestSigners.put( + s, + signingStrategyRequestSignerFactories + .get(s) + .createRequestSigner(SERVICE, authenticationDetailsProvider)); + } + } + this.client = restClientFactory.create(defaultRequestSigner, requestSigners, configuration); + + if (endpoint != null) { + setEndpoint(endpoint); + } + } + + /** + * Create a builder for this client. + * @return builder + */ + public static com.oracle.bmc.keymanagement.KmsManagementAsyncClientBuilder builder() { + return new com.oracle.bmc.keymanagement.KmsManagementAsyncClientBuilder(SERVICE); + } + + @Override + public void setEndpoint(String endpoint) { + LOG.info("Setting endpoint to {}", endpoint); + client.setEndpoint(endpoint); + } + + @Override + public void close() { + client.close(); + } + + @Override + public java.util.concurrent.Future createKey( + final CreateKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async createKey"); + final CreateKeyRequest interceptedRequest = CreateKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + CreateKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = CreateKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = + handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + CreateKeyRequest, CreateKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post( + ib, + interceptedRequest.getCreateKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post( + ib, + interceptedRequest.getCreateKeyDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, CreateKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post( + ib, + interceptedRequest.getCreateKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future createKeyVersion( + final CreateKeyVersionRequest request, + final com.oracle.bmc.responses.AsyncHandler< + CreateKeyVersionRequest, CreateKeyVersionResponse> + handler) { + LOG.trace("Called async createKeyVersion"); + final CreateKeyVersionRequest interceptedRequest = + CreateKeyVersionConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + CreateKeyVersionConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = CreateKeyVersionConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + CreateKeyVersionRequest, CreateKeyVersionResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, CreateKeyVersionResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future disableKey( + final DisableKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async disableKey"); + final DisableKeyRequest interceptedRequest = DisableKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + DisableKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = DisableKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = + handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + DisableKeyRequest, DisableKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, DisableKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future enableKey( + final EnableKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async enableKey"); + final EnableKeyRequest interceptedRequest = EnableKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + EnableKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = EnableKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = + handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + EnableKeyRequest, EnableKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, EnableKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future getKey( + final GetKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler handler) { + LOG.trace("Called async getKey"); + final GetKeyRequest interceptedRequest = GetKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = GetKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + GetKeyRequest, GetKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.get(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.get(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, GetKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.get(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future getKeyVersion( + final GetKeyVersionRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async getKeyVersion"); + final GetKeyVersionRequest interceptedRequest = + GetKeyVersionConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetKeyVersionConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = GetKeyVersionConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + GetKeyVersionRequest, GetKeyVersionResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.get(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.get(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, GetKeyVersionResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.get(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future listKeyVersions( + final ListKeyVersionsRequest request, + final com.oracle.bmc.responses.AsyncHandler< + ListKeyVersionsRequest, ListKeyVersionsResponse> + handler) { + LOG.trace("Called async listKeyVersions"); + final ListKeyVersionsRequest interceptedRequest = + ListKeyVersionsConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + ListKeyVersionsConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = ListKeyVersionsConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + ListKeyVersionsRequest, ListKeyVersionsResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.get(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.get(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, ListKeyVersionsResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.get(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future listKeys( + final ListKeysRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async listKeys"); + final ListKeysRequest interceptedRequest = ListKeysConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + ListKeysConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = ListKeysConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = + handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + ListKeysRequest, ListKeysResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.get(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.get(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, ListKeysResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.get(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future updateKey( + final UpdateKeyRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async updateKey"); + final UpdateKeyRequest interceptedRequest = UpdateKeyConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + UpdateKeyConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = UpdateKeyConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = + handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + UpdateKeyRequest, UpdateKeyResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.put( + ib, + interceptedRequest.getUpdateKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.put( + ib, + interceptedRequest.getUpdateKeyDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, UpdateKeyResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.put( + ib, + interceptedRequest.getUpdateKeyDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementAsyncClientBuilder.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementAsyncClientBuilder.java new file mode 100644 index 00000000000..1590082a9e6 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementAsyncClientBuilder.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.Service; +import com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider; + +@lombok.extern.slf4j.Slf4j +public class KmsManagementAsyncClientBuilder + extends AbstractKmsManagementClientBuilder< + KmsManagementAsyncClientBuilder, KmsManagementAsyncClient> { + public KmsManagementAsyncClientBuilder(Service service) { + super(service); + } + + @Override + public KmsManagementAsyncClient build( + AbstractAuthenticationDetailsProvider authenticationDetailsProvider) { + String cryptoEndpoint = getEndpoint(); + + return new KmsManagementAsyncClient( + authenticationDetailsProvider, + configuration, + clientConfigurator, + requestSignerFactory, + additionalClientConfigurators, + cryptoEndpoint); + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementClient.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementClient.java new file mode 100644 index 00000000000..62b29401f53 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementClient.java @@ -0,0 +1,491 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import java.util.Locale; +import com.oracle.bmc.keymanagement.internal.http.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class KmsManagementClient implements KmsManagement { + /** + * Service instance for KmsManagement. + */ + public static final com.oracle.bmc.Service SERVICE = + com.oracle.bmc.Services.serviceBuilder() + .serviceName("KMSMANAGEMENT") + .serviceEndpointPrefix("kms") + .build(); + // attempt twice if it's instance principals, immediately failures will try to refresh the token + private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; + + private final KmsManagementWaiters waiters; + private final KmsManagementPaginators paginators; + + @lombok.Getter(value = lombok.AccessLevel.PACKAGE) + private final com.oracle.bmc.http.internal.RestClient client; + + private final com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider + authenticationDetailsProvider; + + /** + * Creates a new service instance using the given authentication provider. + * @param authenticationDetailsProvider The authentication details provider, required. + */ + public KmsManagementClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider) { + this(authenticationDetailsProvider, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + */ + public KmsManagementClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration) { + this(authenticationDetailsProvider, configuration, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + */ + public KmsManagementClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + new com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory( + com.oracle.bmc.http.signing.SigningStrategy.STANDARD)); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + */ + public KmsManagementClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + new java.util.ArrayList()); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + */ + public KmsManagementClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + additionalClientConfigurators, + null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsManagementClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators, + String endpoint) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory + .createDefaultRequestSignerFactories(), + additionalClientConfigurators, + endpoint); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param signingStrategyRequestSignerFactories The request signer factories for each signing strategy used to create the request signer + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsManagementClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSignerFactory> + signingStrategyRequestSignerFactories, + java.util.List additionalClientConfigurators, + String endpoint) { + this.authenticationDetailsProvider = authenticationDetailsProvider; + com.oracle.bmc.http.internal.RestClientFactory restClientFactory = + com.oracle.bmc.http.internal.RestClientFactoryBuilder.builder() + .clientConfigurator(clientConfigurator) + .additionalClientConfigurators(additionalClientConfigurators) + .build(); + com.oracle.bmc.http.signing.RequestSigner defaultRequestSigner = + defaultRequestSignerFactory.createRequestSigner( + SERVICE, this.authenticationDetailsProvider); + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSigner> + requestSigners = new java.util.HashMap<>(); + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.BasicAuthenticationDetailsProvider) { + for (com.oracle.bmc.http.signing.SigningStrategy s : + com.oracle.bmc.http.signing.SigningStrategy.values()) { + requestSigners.put( + s, + signingStrategyRequestSignerFactories + .get(s) + .createRequestSigner(SERVICE, authenticationDetailsProvider)); + } + } + this.client = restClientFactory.create(defaultRequestSigner, requestSigners, configuration); + // up to 50 (core) threads, time out after 60s idle, all daemon + java.util.concurrent.ThreadPoolExecutor executorService = + new java.util.concurrent.ThreadPoolExecutor( + 50, + 50, + 60L, + java.util.concurrent.TimeUnit.SECONDS, + new java.util.concurrent.LinkedBlockingQueue(), + new com.google.common.util.concurrent.ThreadFactoryBuilder() + .setDaemon(false) + .setNameFormat("KmsManagement-waiters-%d") + .build()); + executorService.allowCoreThreadTimeOut(true); + + this.waiters = new KmsManagementWaiters(executorService, this); + + this.paginators = new KmsManagementPaginators(this); + + if (endpoint != null) { + setEndpoint(endpoint); + } + } + + /** + * Create a builder for this client. + * @return builder + */ + public static com.oracle.bmc.keymanagement.KmsManagementClientBuilder builder() { + return new com.oracle.bmc.keymanagement.KmsManagementClientBuilder(SERVICE); + } + + @Override + public void setEndpoint(String endpoint) { + LOG.info("Setting endpoint to {}", endpoint); + client.setEndpoint(endpoint); + } + + @Override + public void close() { + client.close(); + } + + @Override + public CreateKeyResponse createKey(CreateKeyRequest request) { + LOG.trace("Called createKey"); + request = CreateKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + CreateKeyConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + CreateKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.post(ib, request.getCreateKeyDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public CreateKeyVersionResponse createKeyVersion(CreateKeyVersionRequest request) { + LOG.trace("Called createKeyVersion"); + request = CreateKeyVersionConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + CreateKeyVersionConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = CreateKeyVersionConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.post(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public DisableKeyResponse disableKey(DisableKeyRequest request) { + LOG.trace("Called disableKey"); + request = DisableKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + DisableKeyConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + DisableKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.post(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public EnableKeyResponse enableKey(EnableKeyRequest request) { + LOG.trace("Called enableKey"); + request = EnableKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + EnableKeyConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + EnableKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.post(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public GetKeyResponse getKey(GetKeyRequest request) { + LOG.trace("Called getKey"); + request = GetKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetKeyConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + GetKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.get(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public GetKeyVersionResponse getKeyVersion(GetKeyVersionRequest request) { + LOG.trace("Called getKeyVersion"); + request = GetKeyVersionConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetKeyVersionConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = GetKeyVersionConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.get(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public ListKeyVersionsResponse listKeyVersions(ListKeyVersionsRequest request) { + LOG.trace("Called listKeyVersions"); + request = ListKeyVersionsConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + ListKeyVersionsConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = ListKeyVersionsConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.get(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public ListKeysResponse listKeys(ListKeysRequest request) { + LOG.trace("Called listKeys"); + request = ListKeysConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + ListKeysConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + ListKeysConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.get(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public UpdateKeyResponse updateKey(UpdateKeyRequest request) { + LOG.trace("Called updateKey"); + request = UpdateKeyConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + UpdateKeyConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + UpdateKeyConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.put(ib, request.getUpdateKeyDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + private boolean canRetryRequestIfRefreshableAuthTokenUsed(com.oracle.bmc.model.BmcException e) { + if (e.getStatusCode() == 401 + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + ((com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider) + .refresh(); + return true; + } + return false; + } + + @Override + public KmsManagementWaiters getWaiters() { + return waiters; + } + + @Override + public KmsManagementPaginators getPaginators() { + return paginators; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementClientBuilder.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementClientBuilder.java new file mode 100644 index 00000000000..9915abfdd22 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementClientBuilder.java @@ -0,0 +1,30 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.Service; +import com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider; + +@lombok.extern.slf4j.Slf4j +public class KmsManagementClientBuilder + extends AbstractKmsManagementClientBuilder< + KmsManagementClientBuilder, KmsManagementClient> { + public KmsManagementClientBuilder(Service service) { + super(service); + } + + @Override + public KmsManagementClient build( + AbstractAuthenticationDetailsProvider authenticationDetailsProvider) { + String managementEndpoint = getEndpoint(); + + return new KmsManagementClient( + authenticationDetailsProvider, + configuration, + clientConfigurator, + requestSignerFactory, + additionalClientConfigurators, + managementEndpoint); + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementPaginators.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementPaginators.java new file mode 100644 index 00000000000..6795373d7e0 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementPaginators.java @@ -0,0 +1,252 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +/** + * Collection of helper methods that can be used to provide an {@link java.lang.Iterable} interface + * to any list operations of KmsManagement where multiple pages of data may be fetched. + * Two styles of iteration are supported: + * + *

    + *
  • Iterating over the Response objects returned by the list operation. These are referred to as ResponseIterators, and the methods are suffixed with ResponseIterator. For example: listUsersResponseIterator
  • + *
  • Iterating over the resources/records being listed. These are referred to as RecordIterators, and the methods are suffixed with RecordIterator. For example: listUsersRecordIterator
  • + *
+ * + * These iterables abstract away the need to write code to manually handle pagination via looping and using the page tokens. + * They will automatically fetch more data from the service when required. + * + * As an example, if we were using the ListUsers operation in IdentityService, then the {@link java.lang.Iterable} returned by calling a + * ResponseIterator method would iterate over the ListUsersResponse objects returned by each ListUsers call, whereas the {@link java.lang.Iterable} + * returned by calling a RecordIterator method would iterate over the User records and we don't have to deal with ListUsersResponse objects at all. + * In either case, pagination will be automatically handled so we can iterate until there are no more responses or no more resources/records available. + */ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.RequiredArgsConstructor +public class KmsManagementPaginators { + private final KmsManagement client; + + /** + * Creates a new iterable which will iterate over the responses received from the listKeyVersions operation. This iterable + * will fetch more data from the server as needed. + * + * @param request a request which can be sent to the service operation + * @return an {@link java.lang.Iterable} which can be used to iterate over the responses received from the service. + */ + public Iterable listKeyVersionsResponseIterator( + final ListKeyVersionsRequest request) { + return new com.oracle.bmc.paginator.internal.ResponseIterable< + ListKeyVersionsRequest.Builder, ListKeyVersionsRequest, ListKeyVersionsResponse>( + new com.google.common.base.Supplier() { + @Override + public ListKeyVersionsRequest.Builder get() { + return ListKeyVersionsRequest.builder().copy(request); + } + }, + new com.google.common.base.Function() { + @Override + public String apply(ListKeyVersionsResponse response) { + return response.getOpcNextPage(); + } + }, + new com.google.common.base.Function< + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListKeyVersionsRequest.Builder>, + ListKeyVersionsRequest>() { + @Override + public ListKeyVersionsRequest apply( + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListKeyVersionsRequest.Builder> + input) { + if (input.getToken() == null) { + return input.getRequestBuilder().build(); + } else { + return input.getRequestBuilder() + .page(input.getToken().orNull()) + .build(); + } + } + }, + new com.google.common.base.Function< + ListKeyVersionsRequest, ListKeyVersionsResponse>() { + @Override + public ListKeyVersionsResponse apply(ListKeyVersionsRequest request) { + return client.listKeyVersions(request); + } + }); + } + + /** + * Creates a new iterable which will iterate over the {@link com.oracle.bmc.keymanagement.model.KeyVersionSummary} objects + * contained in responses from the listKeyVersions operation. This iterable will fetch more data from the + * server as needed. + * + * @param request a request which can be sent to the service operation + * @return an {@link java.lang.Iterable} which can be used to iterate over the {@link com.oracle.bmc.keymanagement.model.KeyVersionSummary} objects + * contained in responses received from the service. + */ + public Iterable + listKeyVersionsRecordIterator(final ListKeyVersionsRequest request) { + return new com.oracle.bmc.paginator.internal.ResponseRecordIterable< + ListKeyVersionsRequest.Builder, ListKeyVersionsRequest, ListKeyVersionsResponse, + com.oracle.bmc.keymanagement.model.KeyVersionSummary>( + new com.google.common.base.Supplier() { + @Override + public ListKeyVersionsRequest.Builder get() { + return ListKeyVersionsRequest.builder().copy(request); + } + }, + new com.google.common.base.Function() { + @Override + public String apply(ListKeyVersionsResponse response) { + return response.getOpcNextPage(); + } + }, + new com.google.common.base.Function< + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListKeyVersionsRequest.Builder>, + ListKeyVersionsRequest>() { + @Override + public ListKeyVersionsRequest apply( + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListKeyVersionsRequest.Builder> + input) { + if (input.getToken() == null) { + return input.getRequestBuilder().build(); + } else { + return input.getRequestBuilder() + .page(input.getToken().orNull()) + .build(); + } + } + }, + new com.google.common.base.Function< + ListKeyVersionsRequest, ListKeyVersionsResponse>() { + @Override + public ListKeyVersionsResponse apply(ListKeyVersionsRequest request) { + return client.listKeyVersions(request); + } + }, + new com.google.common.base.Function< + ListKeyVersionsResponse, + java.util.List>() { + @Override + public java.util.List + apply(ListKeyVersionsResponse response) { + return response.getItems(); + } + }); + } + + /** + * Creates a new iterable which will iterate over the responses received from the listKeys operation. This iterable + * will fetch more data from the server as needed. + * + * @param request a request which can be sent to the service operation + * @return an {@link java.lang.Iterable} which can be used to iterate over the responses received from the service. + */ + public Iterable listKeysResponseIterator(final ListKeysRequest request) { + return new com.oracle.bmc.paginator.internal.ResponseIterable< + ListKeysRequest.Builder, ListKeysRequest, ListKeysResponse>( + new com.google.common.base.Supplier() { + @Override + public ListKeysRequest.Builder get() { + return ListKeysRequest.builder().copy(request); + } + }, + new com.google.common.base.Function() { + @Override + public String apply(ListKeysResponse response) { + return response.getOpcNextPage(); + } + }, + new com.google.common.base.Function< + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListKeysRequest.Builder>, + ListKeysRequest>() { + @Override + public ListKeysRequest apply( + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListKeysRequest.Builder> + input) { + if (input.getToken() == null) { + return input.getRequestBuilder().build(); + } else { + return input.getRequestBuilder() + .page(input.getToken().orNull()) + .build(); + } + } + }, + new com.google.common.base.Function() { + @Override + public ListKeysResponse apply(ListKeysRequest request) { + return client.listKeys(request); + } + }); + } + + /** + * Creates a new iterable which will iterate over the {@link com.oracle.bmc.keymanagement.model.KeySummary} objects + * contained in responses from the listKeys operation. This iterable will fetch more data from the + * server as needed. + * + * @param request a request which can be sent to the service operation + * @return an {@link java.lang.Iterable} which can be used to iterate over the {@link com.oracle.bmc.keymanagement.model.KeySummary} objects + * contained in responses received from the service. + */ + public Iterable listKeysRecordIterator( + final ListKeysRequest request) { + return new com.oracle.bmc.paginator.internal.ResponseRecordIterable< + ListKeysRequest.Builder, ListKeysRequest, ListKeysResponse, + com.oracle.bmc.keymanagement.model.KeySummary>( + new com.google.common.base.Supplier() { + @Override + public ListKeysRequest.Builder get() { + return ListKeysRequest.builder().copy(request); + } + }, + new com.google.common.base.Function() { + @Override + public String apply(ListKeysResponse response) { + return response.getOpcNextPage(); + } + }, + new com.google.common.base.Function< + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListKeysRequest.Builder>, + ListKeysRequest>() { + @Override + public ListKeysRequest apply( + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListKeysRequest.Builder> + input) { + if (input.getToken() == null) { + return input.getRequestBuilder().build(); + } else { + return input.getRequestBuilder() + .page(input.getToken().orNull()) + .build(); + } + } + }, + new com.google.common.base.Function() { + @Override + public ListKeysResponse apply(ListKeysRequest request) { + return client.listKeys(request); + } + }, + new com.google.common.base.Function< + ListKeysResponse, + java.util.List>() { + @Override + public java.util.List apply( + ListKeysResponse response) { + return response.getItems(); + } + }); + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementWaiters.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementWaiters.java new file mode 100644 index 00000000000..6e1916deb16 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsManagementWaiters.java @@ -0,0 +1,115 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +/** + * Collection of helper methods to produce {@link Waiter}s for different + * resources of KmsManagement. + *

+ * The default configuration used is defined by {@link Waiters#DEFAULT_POLLING_WAITER}. + */ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.RequiredArgsConstructor +public class KmsManagementWaiters { + private final java.util.concurrent.ExecutorService executorService; + private final KmsManagement client; + + /** + * Creates a new {@link Waiter} using default configuration. + * + * @param request the request to send + * @param targetStates the desired states to wait for. If multiple states are provided then the waiter will return once the resource reaches any of the provided states + * @return a new {@code Waiter} instance + */ + public com.oracle.bmc.waiter.Waiter forKey( + GetKeyRequest request, + com.oracle.bmc.keymanagement.model.Key.LifecycleState... targetStates) { + org.apache.commons.lang3.Validate.notEmpty( + targetStates, "At least one targetState must be provided"); + org.apache.commons.lang3.Validate.noNullElements( + targetStates, "Null targetState values are not permitted"); + + return forKey(com.oracle.bmc.waiter.Waiters.DEFAULT_POLLING_WAITER, request, targetStates); + } + + /** + * Creates a new {@link Waiter} using the provided configuration. + * + * @param request the request to send + * @param targetState the desired state to wait for + * @param terminationStrategy the {@link TerminationStrategy} to use + * @param delayStrategy the {@link DelayStrategy} to use + * @return a new {@code Waiter} instance + */ + public com.oracle.bmc.waiter.Waiter forKey( + GetKeyRequest request, + com.oracle.bmc.keymanagement.model.Key.LifecycleState targetState, + com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, + com.oracle.bmc.waiter.DelayStrategy delayStrategy) { + org.apache.commons.lang3.Validate.notNull(targetState, "The targetState cannot be null"); + + return forKey( + com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), + request, + targetState); + } + + /** + * Creates a new {@link Waiter} using the provided configuration. + * + * @param request the request to send + * @param terminationStrategy the {@link TerminationStrategy} to use + * @param delayStrategy the {@link DelayStrategy} to use + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states + * @return a new {@code Waiter} instance + */ + public com.oracle.bmc.waiter.Waiter forKey( + GetKeyRequest request, + com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, + com.oracle.bmc.waiter.DelayStrategy delayStrategy, + com.oracle.bmc.keymanagement.model.Key.LifecycleState... targetStates) { + org.apache.commons.lang3.Validate.notEmpty( + targetStates, "At least one target state must be provided"); + org.apache.commons.lang3.Validate.noNullElements( + targetStates, "Null target states are not permitted"); + + return forKey( + com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), + request, + targetStates); + } + + // Helper method to create a new Waiter for Key. + private com.oracle.bmc.waiter.Waiter forKey( + com.oracle.bmc.waiter.BmcGenericWaiter waiter, + final GetKeyRequest request, + final com.oracle.bmc.keymanagement.model.Key.LifecycleState... targetStates) { + final java.util.Set targetStatesSet = + new java.util.HashSet<>(java.util.Arrays.asList(targetStates)); + + return new com.oracle.bmc.waiter.internal.SimpleWaiterImpl<>( + executorService, + waiter.toCallable( + com.google.common.base.Suppliers.ofInstance(request), + new com.google.common.base.Function() { + @Override + public GetKeyResponse apply(GetKeyRequest request) { + return client.getKey(request); + } + }, + new com.google.common.base.Predicate() { + @Override + public boolean apply(GetKeyResponse response) { + return targetStatesSet.contains( + response.getKey().getLifecycleState()); + } + }, + targetStatesSet.contains( + com.oracle.bmc.keymanagement.model.Key.LifecycleState.Deleted)), + request); + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVault.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVault.java new file mode 100644 index 00000000000..4dbafb006bf --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVault.java @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +public interface KmsVault extends AutoCloseable { + + /** + * Sets the endpoint to call (ex, https://www.example.com). + * @param endpoint The endpoint of the service. + */ + void setEndpoint(String endpoint); + + /** + * Sets the region to call (ex, Region.US_PHOENIX_1). + *

+ * Note, this will call {@link #setEndpoint(String) setEndpoint} after resolving the endpoint. If the service is not available in this Region, however, an IllegalArgumentException will be raised. + * @param region The region of the service. + */ + void setRegion(com.oracle.bmc.Region region); + + /** + * Sets the region to call (ex, 'us-phoenix-1'). + *

+ * Note, this will first try to map the region ID to a known Region and call + * {@link #setRegion(Region) setRegion}. + *

+ * If no known Region could be determined, it will create an endpoint based on the + * default endpoint format ({@link Region#formatDefaultRegionEndpoint(Service, String)} + * and then call {@link #setEndpoint(String) setEndpoint}. + * @param regionId The public region ID. + */ + void setRegion(String regionId); + + /** + * Cancels the scheduled deletion of the specified Vault, which must be in PendingDeletion + * state. The Vault and all Keys in it will be moved back to their previous states before + * the deletion was scheduled. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + CancelVaultDeletionResponse cancelVaultDeletion(CancelVaultDeletionRequest request); + + /** + * Creates a new vault. The type of vault you create determines key + * placement, pricing, and available options. Options include storage + * isolation, a dedicated service endpoint instead of a shared service + * endpoint for API calls, and a dedicated HSM or a multitenant HSM. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + CreateVaultResponse createVault(CreateVaultRequest request); + + /** + * Gets the specified vault's configuration information. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + GetVaultResponse getVault(GetVaultRequest request); + + /** + * Lists vaults in the specified compartment. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + ListVaultsResponse listVaults(ListVaultsRequest request); + + /** + * Schedules the deletion of the specified Vault. The Vault and all Keys in it + * will be moved to PendingDeletion state and deleted after the retention period. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + ScheduleVaultDeletionResponse scheduleVaultDeletion(ScheduleVaultDeletionRequest request); + + /** + * Updates the properties of a vault. Specifically, you can + * only update the `displayName` property. Furthermore, the vault + * must be in an `ACTIVE` or `CREATING` state. + * + * @param request The request object containing the details to send + * @return A response object containing details about the completed operation + * @throws BmcException when an error occurs. + */ + UpdateVaultResponse updateVault(UpdateVaultRequest request); + + /** + * Gets the pre-configured waiters available for resources for this service. + * + * @return The service waiters. + */ + KmsVaultWaiters getWaiters(); + + /** + * Gets the pre-configured paginators available for list operations in this service which may return multiple + * pages of data. These paginators provide an {@link java.lang.Iterable} interface so that service responses, or + * resources/records, can be iterated through without having to manually deal with pagination and page tokens. + * + * @return The service paginators. + */ + KmsVaultPaginators getPaginators(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultAsync.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultAsync.java new file mode 100644 index 00000000000..a09490d9190 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultAsync.java @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +public interface KmsVaultAsync extends AutoCloseable { + + /** + * Sets the endpoint to call (ex, https://www.example.com). + * @param endpoint The endpoint of the serice. + */ + void setEndpoint(String endpoint); + + /** + * Sets the region to call (ex, Region.US_PHOENIX_1). + *

+ * Note, this will call {@link #setEndpoint(String) setEndpoint} after resolving the endpoint. If the service is not available in this region, however, an IllegalArgumentException will be raised. + * @param region The region of the service. + */ + void setRegion(com.oracle.bmc.Region region); + + /** + * Sets the region to call (ex, 'us-phoenix-1'). + *

+ * Note, this will first try to map the region ID to a known Region and call + * {@link #setRegion(Region) setRegion}. + *

+ * If no known Region could be determined, it will create an endpoint based on the + * default endpoint format ({@link Region#formatDefaultRegionEndpoint(Service, String)} + * and then call {@link #setEndpoint(String) setEndpoint}. + * @param regionId The public region ID. + */ + void setRegion(String regionId); + + /** + * Cancels the scheduled deletion of the specified Vault, which must be in PendingDeletion + * state. The Vault and all Keys in it will be moved back to their previous states before + * the deletion was scheduled. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future cancelVaultDeletion( + CancelVaultDeletionRequest request, + com.oracle.bmc.responses.AsyncHandler< + CancelVaultDeletionRequest, CancelVaultDeletionResponse> + handler); + + /** + * Creates a new vault. The type of vault you create determines key + * placement, pricing, and available options. Options include storage + * isolation, a dedicated service endpoint instead of a shared service + * endpoint for API calls, and a dedicated HSM or a multitenant HSM. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future createVault( + CreateVaultRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Gets the specified vault's configuration information. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future getVault( + GetVaultRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Lists vaults in the specified compartment. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future listVaults( + ListVaultsRequest request, + com.oracle.bmc.responses.AsyncHandler handler); + + /** + * Schedules the deletion of the specified Vault. The Vault and all Keys in it + * will be moved to PendingDeletion state and deleted after the retention period. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future scheduleVaultDeletion( + ScheduleVaultDeletionRequest request, + com.oracle.bmc.responses.AsyncHandler< + ScheduleVaultDeletionRequest, ScheduleVaultDeletionResponse> + handler); + + /** + * Updates the properties of a vault. Specifically, you can + * only update the `displayName` property. Furthermore, the vault + * must be in an `ACTIVE` or `CREATING` state. + * + * + * @param request The request object containing the details to send + * @param handler The request handler to invoke upon completion, may be null. + * @return A Future that can be used to get the response if no AsyncHandler was + * provided. Note, if you provide an AsyncHandler and use the Future, some + * types of responses (like java.io.InputStream) may not be able to be read in + * both places as the underlying stream may only be consumed once. + */ + java.util.concurrent.Future updateVault( + UpdateVaultRequest request, + com.oracle.bmc.responses.AsyncHandler handler); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultAsyncClient.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultAsyncClient.java new file mode 100644 index 00000000000..460d0f715ad --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultAsyncClient.java @@ -0,0 +1,747 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import java.util.Locale; +import com.oracle.bmc.keymanagement.internal.http.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class KmsVaultAsyncClient implements KmsVaultAsync { + /** + * Service instance for KmsVault. + */ + public static final com.oracle.bmc.Service SERVICE = + com.oracle.bmc.Services.serviceBuilder() + .serviceName("KMSVAULT") + .serviceEndpointPrefix("kms") + .build(); + + @lombok.Getter(value = lombok.AccessLevel.PACKAGE) + private final com.oracle.bmc.http.internal.RestClient client; + + private final com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider + authenticationDetailsProvider; + + /** + * Creates a new service instance using the given authentication provider. + * @param authenticationDetailsProvider The authentication details provider, required. + */ + public KmsVaultAsyncClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider) { + this(authenticationDetailsProvider, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + */ + public KmsVaultAsyncClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration) { + this(authenticationDetailsProvider, configuration, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + */ + public KmsVaultAsyncClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + new com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory( + com.oracle.bmc.http.signing.SigningStrategy.STANDARD)); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + */ + public KmsVaultAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + new java.util.ArrayList()); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + */ + public KmsVaultAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + additionalClientConfigurators, + null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsVaultAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators, + String endpoint) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory + .createDefaultRequestSignerFactories(), + additionalClientConfigurators, + endpoint); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param signingStrategyRequestSignerFactories The request signer factories for each signing strategy used to create the request signer + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsVaultAsyncClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSignerFactory> + signingStrategyRequestSignerFactories, + java.util.List additionalClientConfigurators, + String endpoint) { + this.authenticationDetailsProvider = authenticationDetailsProvider; + com.oracle.bmc.http.internal.RestClientFactory restClientFactory = + com.oracle.bmc.http.internal.RestClientFactoryBuilder.builder() + .clientConfigurator(clientConfigurator) + .additionalClientConfigurators(additionalClientConfigurators) + .build(); + com.oracle.bmc.http.signing.RequestSigner defaultRequestSigner = + defaultRequestSignerFactory.createRequestSigner( + SERVICE, this.authenticationDetailsProvider); + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSigner> + requestSigners = new java.util.HashMap<>(); + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.BasicAuthenticationDetailsProvider) { + for (com.oracle.bmc.http.signing.SigningStrategy s : + com.oracle.bmc.http.signing.SigningStrategy.values()) { + requestSigners.put( + s, + signingStrategyRequestSignerFactories + .get(s) + .createRequestSigner(SERVICE, authenticationDetailsProvider)); + } + } + this.client = restClientFactory.create(defaultRequestSigner, requestSigners, configuration); + + if (this.authenticationDetailsProvider instanceof com.oracle.bmc.auth.RegionProvider) { + com.oracle.bmc.auth.RegionProvider provider = + (com.oracle.bmc.auth.RegionProvider) this.authenticationDetailsProvider; + + if (provider.getRegion() != null) { + this.setRegion(provider.getRegion()); + if (endpoint != null) { + LOG.info( + "Authentication details provider configured for region '{}', but endpoint specifically set to '{}'. Using endpoint setting instead of region.", + provider.getRegion(), + endpoint); + } + } + } + if (endpoint != null) { + setEndpoint(endpoint); + } + } + + /** + * Create a builder for this client. + * @return builder + */ + public static Builder builder() { + return new Builder(SERVICE); + } + + /** + * Builder class for this client. The "authenticationDetailsProvider" is required and must be passed to the + * {@link #build(AbstractAuthenticationDetailsProvider)} or {@link #buildAsync(AbstractAuthenticationDetailsProvider)} method. + */ + public static class Builder + extends com.oracle.bmc.common.RegionalClientBuilder { + private Builder(com.oracle.bmc.Service service) { + super(service); + requestSignerFactory = + new com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory( + com.oracle.bmc.http.signing.SigningStrategy.STANDARD); + } + + /** + * Build the client. + * @param authenticationDetailsProvider authentication details provider + * @return the client + */ + public KmsVaultAsyncClient build( + @lombok.NonNull + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider + authenticationDetailsProvider) { + return new KmsVaultAsyncClient( + authenticationDetailsProvider, + configuration, + clientConfigurator, + requestSignerFactory, + additionalClientConfigurators, + endpoint); + } + } + + @Override + public void setEndpoint(String endpoint) { + LOG.info("Setting endpoint to {}", endpoint); + client.setEndpoint(endpoint); + } + + @Override + public void setRegion(com.oracle.bmc.Region region) { + com.google.common.base.Optional endpoint = region.getEndpoint(SERVICE); + if (endpoint.isPresent()) { + setEndpoint(endpoint.get()); + } else { + throw new IllegalArgumentException( + "Endpoint for " + SERVICE + " is not known in region " + region); + } + } + + @Override + public void setRegion(String regionId) { + regionId = regionId.toLowerCase(Locale.ENGLISH); + try { + com.oracle.bmc.Region region = com.oracle.bmc.Region.fromRegionId(regionId); + setRegion(region); + } catch (IllegalArgumentException e) { + LOG.info("Unknown regionId '{}', falling back to default endpoint format", regionId); + String endpoint = com.oracle.bmc.Region.formatDefaultRegionEndpoint(SERVICE, regionId); + setEndpoint(endpoint); + } + } + + @Override + public void close() { + client.close(); + } + + @Override + public java.util.concurrent.Future cancelVaultDeletion( + final CancelVaultDeletionRequest request, + final com.oracle.bmc.responses.AsyncHandler< + CancelVaultDeletionRequest, CancelVaultDeletionResponse> + handler) { + LOG.trace("Called async cancelVaultDeletion"); + final CancelVaultDeletionRequest interceptedRequest = + CancelVaultDeletionConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + CancelVaultDeletionConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function< + javax.ws.rs.core.Response, CancelVaultDeletionResponse> + transformer = CancelVaultDeletionConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler< + CancelVaultDeletionRequest, CancelVaultDeletionResponse> + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + CancelVaultDeletionRequest, CancelVaultDeletionResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, CancelVaultDeletionResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future createVault( + final CreateVaultRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async createVault"); + final CreateVaultRequest interceptedRequest = + CreateVaultConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + CreateVaultConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = CreateVaultConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + CreateVaultRequest, CreateVaultResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post( + ib, + interceptedRequest.getCreateVaultDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post( + ib, + interceptedRequest.getCreateVaultDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, CreateVaultResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post( + ib, + interceptedRequest.getCreateVaultDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future getVault( + final GetVaultRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async getVault"); + final GetVaultRequest interceptedRequest = GetVaultConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetVaultConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = GetVaultConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = + handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + GetVaultRequest, GetVaultResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.get(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.get(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, GetVaultResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.get(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future listVaults( + final ListVaultsRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async listVaults"); + final ListVaultsRequest interceptedRequest = ListVaultsConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + ListVaultsConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = ListVaultsConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler handlerToUse = + handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + ListVaultsRequest, ListVaultsResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.get(ib, interceptedRequest, onSuccess, onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.get(ib, interceptedRequest, onSuccess, onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, ListVaultsResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.get(ib, interceptedRequest, onSuccess, onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future scheduleVaultDeletion( + final ScheduleVaultDeletionRequest request, + final com.oracle.bmc.responses.AsyncHandler< + ScheduleVaultDeletionRequest, ScheduleVaultDeletionResponse> + handler) { + LOG.trace("Called async scheduleVaultDeletion"); + final ScheduleVaultDeletionRequest interceptedRequest = + ScheduleVaultDeletionConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + ScheduleVaultDeletionConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function< + javax.ws.rs.core.Response, ScheduleVaultDeletionResponse> + transformer = ScheduleVaultDeletionConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler< + ScheduleVaultDeletionRequest, ScheduleVaultDeletionResponse> + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + ScheduleVaultDeletionRequest, ScheduleVaultDeletionResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.post( + ib, + interceptedRequest.getScheduleVaultDeletionDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.post( + ib, + interceptedRequest.getScheduleVaultDeletionDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, ScheduleVaultDeletionResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.post( + ib, + interceptedRequest.getScheduleVaultDeletionDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } + + @Override + public java.util.concurrent.Future updateVault( + final UpdateVaultRequest request, + final com.oracle.bmc.responses.AsyncHandler + handler) { + LOG.trace("Called async updateVault"); + final UpdateVaultRequest interceptedRequest = + UpdateVaultConverter.interceptRequest(request); + final com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + UpdateVaultConverter.fromRequest(client, interceptedRequest); + final com.google.common.base.Function + transformer = UpdateVaultConverter.fromResponse(); + + com.oracle.bmc.responses.AsyncHandler + handlerToUse = handler; + if (handler != null + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + handlerToUse = + new com.oracle.bmc.util.internal.RefreshAuthTokenWrappingAsyncHandler< + UpdateVaultRequest, UpdateVaultResponse>( + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + handler) { + @Override + public void retryCall() { + final com.oracle.bmc.util.internal.Consumer + onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + this, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>( + this, interceptedRequest); + client.put( + ib, + interceptedRequest.getUpdateVaultDetails(), + interceptedRequest, + onSuccess, + onError); + } + }; + } + + final com.oracle.bmc.util.internal.Consumer onSuccess = + new com.oracle.bmc.http.internal.SuccessConsumer<>( + handlerToUse, transformer, interceptedRequest); + final com.oracle.bmc.util.internal.Consumer onError = + new com.oracle.bmc.http.internal.ErrorConsumer<>(handlerToUse, interceptedRequest); + + java.util.concurrent.Future responseFuture = + client.put( + ib, + interceptedRequest.getUpdateVaultDetails(), + interceptedRequest, + onSuccess, + onError); + + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + return new com.oracle.bmc.util.internal.RefreshAuthTokenTransformingFuture< + javax.ws.rs.core.Response, UpdateVaultResponse>( + responseFuture, + transformer, + (com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider, + new com.google.common.base.Supplier< + java.util.concurrent.Future>() { + @Override + public java.util.concurrent.Future get() { + return client.put( + ib, + interceptedRequest.getUpdateVaultDetails(), + interceptedRequest, + onSuccess, + onError); + } + }); + } else { + return new com.oracle.bmc.util.internal.TransformingFuture<>( + responseFuture, transformer); + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultClient.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultClient.java new file mode 100644 index 00000000000..6b2c22c8eda --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultClient.java @@ -0,0 +1,489 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import java.util.Locale; +import com.oracle.bmc.keymanagement.internal.http.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class KmsVaultClient implements KmsVault { + /** + * Service instance for KmsVault. + */ + public static final com.oracle.bmc.Service SERVICE = + com.oracle.bmc.Services.serviceBuilder() + .serviceName("KMSVAULT") + .serviceEndpointPrefix("kms") + .build(); + // attempt twice if it's instance principals, immediately failures will try to refresh the token + private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; + + private final KmsVaultWaiters waiters; + private final KmsVaultPaginators paginators; + + @lombok.Getter(value = lombok.AccessLevel.PACKAGE) + private final com.oracle.bmc.http.internal.RestClient client; + + private final com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider + authenticationDetailsProvider; + + /** + * Creates a new service instance using the given authentication provider. + * @param authenticationDetailsProvider The authentication details provider, required. + */ + public KmsVaultClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider) { + this(authenticationDetailsProvider, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + */ + public KmsVaultClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration) { + this(authenticationDetailsProvider, configuration, null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + */ + public KmsVaultClient( + com.oracle.bmc.auth.BasicAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + new com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory( + com.oracle.bmc.http.signing.SigningStrategy.STANDARD)); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + */ + public KmsVaultClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + new java.util.ArrayList()); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + */ + public KmsVaultClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + additionalClientConfigurators, + null); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsVaultClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.List additionalClientConfigurators, + String endpoint) { + this( + authenticationDetailsProvider, + configuration, + clientConfigurator, + defaultRequestSignerFactory, + com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory + .createDefaultRequestSignerFactories(), + additionalClientConfigurators, + endpoint); + } + + /** + * Creates a new service instance using the given authentication provider and client configuration. Additionally, + * a Consumer can be provided that will be invoked whenever a REST Client is created to allow for additional configuration/customization. + *

+ * This is an advanced constructor for clients that want to take control over how requests are signed. + * @param authenticationDetailsProvider The authentication details provider, required. + * @param configuration The client configuration, optional. + * @param clientConfigurator ClientConfigurator that will be invoked for additional configuration of a REST client, optional. + * @param defaultRequestSignerFactory The request signer factory used to create the request signer for this service. + * @param signingStrategyRequestSignerFactories The request signer factories for each signing strategy used to create the request signer + * @param additionalClientConfigurators Additional client configurators to be run after the primary configurator. + * @param endpoint Endpoint, or null to leave unset (note, may be overridden by {@code authenticationDetailsProvider}) + */ + public KmsVaultClient( + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider authenticationDetailsProvider, + com.oracle.bmc.ClientConfiguration configuration, + com.oracle.bmc.http.ClientConfigurator clientConfigurator, + com.oracle.bmc.http.signing.RequestSignerFactory defaultRequestSignerFactory, + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSignerFactory> + signingStrategyRequestSignerFactories, + java.util.List additionalClientConfigurators, + String endpoint) { + this.authenticationDetailsProvider = authenticationDetailsProvider; + com.oracle.bmc.http.internal.RestClientFactory restClientFactory = + com.oracle.bmc.http.internal.RestClientFactoryBuilder.builder() + .clientConfigurator(clientConfigurator) + .additionalClientConfigurators(additionalClientConfigurators) + .build(); + com.oracle.bmc.http.signing.RequestSigner defaultRequestSigner = + defaultRequestSignerFactory.createRequestSigner( + SERVICE, this.authenticationDetailsProvider); + java.util.Map< + com.oracle.bmc.http.signing.SigningStrategy, + com.oracle.bmc.http.signing.RequestSigner> + requestSigners = new java.util.HashMap<>(); + if (this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.BasicAuthenticationDetailsProvider) { + for (com.oracle.bmc.http.signing.SigningStrategy s : + com.oracle.bmc.http.signing.SigningStrategy.values()) { + requestSigners.put( + s, + signingStrategyRequestSignerFactories + .get(s) + .createRequestSigner(SERVICE, authenticationDetailsProvider)); + } + } + this.client = restClientFactory.create(defaultRequestSigner, requestSigners, configuration); + // up to 50 (core) threads, time out after 60s idle, all daemon + java.util.concurrent.ThreadPoolExecutor executorService = + new java.util.concurrent.ThreadPoolExecutor( + 50, + 50, + 60L, + java.util.concurrent.TimeUnit.SECONDS, + new java.util.concurrent.LinkedBlockingQueue(), + new com.google.common.util.concurrent.ThreadFactoryBuilder() + .setDaemon(false) + .setNameFormat("KmsVault-waiters-%d") + .build()); + executorService.allowCoreThreadTimeOut(true); + + this.waiters = new KmsVaultWaiters(executorService, this); + + this.paginators = new KmsVaultPaginators(this); + + if (this.authenticationDetailsProvider instanceof com.oracle.bmc.auth.RegionProvider) { + com.oracle.bmc.auth.RegionProvider provider = + (com.oracle.bmc.auth.RegionProvider) this.authenticationDetailsProvider; + + if (provider.getRegion() != null) { + this.setRegion(provider.getRegion()); + if (endpoint != null) { + LOG.info( + "Authentication details provider configured for region '{}', but endpoint specifically set to '{}'. Using endpoint setting instead of region.", + provider.getRegion(), + endpoint); + } + } + } + if (endpoint != null) { + setEndpoint(endpoint); + } + } + + /** + * Create a builder for this client. + * @return builder + */ + public static Builder builder() { + return new Builder(SERVICE); + } + + /** + * Builder class for this client. The "authenticationDetailsProvider" is required and must be passed to the + * {@link #build(AbstractAuthenticationDetailsProvider)} or {@link #buildAsync(AbstractAuthenticationDetailsProvider)} method. + */ + public static class Builder + extends com.oracle.bmc.common.RegionalClientBuilder { + private Builder(com.oracle.bmc.Service service) { + super(service); + requestSignerFactory = + new com.oracle.bmc.http.signing.internal.DefaultRequestSignerFactory( + com.oracle.bmc.http.signing.SigningStrategy.STANDARD); + } + + /** + * Build the client. + * @param authenticationDetailsProvider authentication details provider + * @return the client + */ + public KmsVaultClient build( + @lombok.NonNull + com.oracle.bmc.auth.AbstractAuthenticationDetailsProvider + authenticationDetailsProvider) { + return new KmsVaultClient( + authenticationDetailsProvider, + configuration, + clientConfigurator, + requestSignerFactory, + signingStrategyRequestSignerFactories, + additionalClientConfigurators, + endpoint); + } + } + + @Override + public void setEndpoint(String endpoint) { + LOG.info("Setting endpoint to {}", endpoint); + client.setEndpoint(endpoint); + } + + @Override + public void setRegion(com.oracle.bmc.Region region) { + com.google.common.base.Optional endpoint = region.getEndpoint(SERVICE); + if (endpoint.isPresent()) { + setEndpoint(endpoint.get()); + } else { + throw new IllegalArgumentException( + "Endpoint for " + SERVICE + " is not known in region " + region); + } + } + + @Override + public void setRegion(String regionId) { + regionId = regionId.toLowerCase(Locale.ENGLISH); + try { + com.oracle.bmc.Region region = com.oracle.bmc.Region.fromRegionId(regionId); + setRegion(region); + } catch (IllegalArgumentException e) { + LOG.info("Unknown regionId '{}', falling back to default endpoint format", regionId); + String endpoint = com.oracle.bmc.Region.formatDefaultRegionEndpoint(SERVICE, regionId); + setEndpoint(endpoint); + } + } + + @Override + public void close() { + client.close(); + } + + @Override + public CancelVaultDeletionResponse cancelVaultDeletion(CancelVaultDeletionRequest request) { + LOG.trace("Called cancelVaultDeletion"); + request = CancelVaultDeletionConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + CancelVaultDeletionConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = CancelVaultDeletionConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.post(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public CreateVaultResponse createVault(CreateVaultRequest request) { + LOG.trace("Called createVault"); + request = CreateVaultConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + CreateVaultConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = CreateVaultConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.post(ib, request.getCreateVaultDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public GetVaultResponse getVault(GetVaultRequest request) { + LOG.trace("Called getVault"); + request = GetVaultConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + GetVaultConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + GetVaultConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.get(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public ListVaultsResponse listVaults(ListVaultsRequest request) { + LOG.trace("Called listVaults"); + request = ListVaultsConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + ListVaultsConverter.fromRequest(client, request); + com.google.common.base.Function transformer = + ListVaultsConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = client.get(ib, request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public ScheduleVaultDeletionResponse scheduleVaultDeletion( + ScheduleVaultDeletionRequest request) { + LOG.trace("Called scheduleVaultDeletion"); + request = ScheduleVaultDeletionConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + ScheduleVaultDeletionConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = ScheduleVaultDeletionConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.post(ib, request.getScheduleVaultDeletionDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + @Override + public UpdateVaultResponse updateVault(UpdateVaultRequest request) { + LOG.trace("Called updateVault"); + request = UpdateVaultConverter.interceptRequest(request); + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = + UpdateVaultConverter.fromRequest(client, request); + com.google.common.base.Function + transformer = UpdateVaultConverter.fromResponse(); + + int attempts = 0; + while (true) { + try { + javax.ws.rs.core.Response response = + client.put(ib, request.getUpdateVaultDetails(), request); + return transformer.apply(response); + } catch (com.oracle.bmc.model.BmcException e) { + if (++attempts < MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS + && canRetryRequestIfRefreshableAuthTokenUsed(e)) { + continue; + } else { + throw e; + } + } + } + } + + private boolean canRetryRequestIfRefreshableAuthTokenUsed(com.oracle.bmc.model.BmcException e) { + if (e.getStatusCode() == 401 + && this.authenticationDetailsProvider + instanceof com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) { + ((com.oracle.bmc.auth.RefreshableOnNotAuthenticatedProvider) + this.authenticationDetailsProvider) + .refresh(); + return true; + } + return false; + } + + @Override + public KmsVaultWaiters getWaiters() { + return waiters; + } + + @Override + public KmsVaultPaginators getPaginators() { + return paginators; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultPaginators.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultPaginators.java new file mode 100644 index 00000000000..d9dc99f4a34 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultPaginators.java @@ -0,0 +1,141 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +/** + * Collection of helper methods that can be used to provide an {@link java.lang.Iterable} interface + * to any list operations of KmsVault where multiple pages of data may be fetched. + * Two styles of iteration are supported: + * + *

    + *
  • Iterating over the Response objects returned by the list operation. These are referred to as ResponseIterators, and the methods are suffixed with ResponseIterator. For example: listUsersResponseIterator
  • + *
  • Iterating over the resources/records being listed. These are referred to as RecordIterators, and the methods are suffixed with RecordIterator. For example: listUsersRecordIterator
  • + *
+ * + * These iterables abstract away the need to write code to manually handle pagination via looping and using the page tokens. + * They will automatically fetch more data from the service when required. + * + * As an example, if we were using the ListUsers operation in IdentityService, then the {@link java.lang.Iterable} returned by calling a + * ResponseIterator method would iterate over the ListUsersResponse objects returned by each ListUsers call, whereas the {@link java.lang.Iterable} + * returned by calling a RecordIterator method would iterate over the User records and we don't have to deal with ListUsersResponse objects at all. + * In either case, pagination will be automatically handled so we can iterate until there are no more responses or no more resources/records available. + */ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.RequiredArgsConstructor +public class KmsVaultPaginators { + private final KmsVault client; + + /** + * Creates a new iterable which will iterate over the responses received from the listVaults operation. This iterable + * will fetch more data from the server as needed. + * + * @param request a request which can be sent to the service operation + * @return an {@link java.lang.Iterable} which can be used to iterate over the responses received from the service. + */ + public Iterable listVaultsResponseIterator( + final ListVaultsRequest request) { + return new com.oracle.bmc.paginator.internal.ResponseIterable< + ListVaultsRequest.Builder, ListVaultsRequest, ListVaultsResponse>( + new com.google.common.base.Supplier() { + @Override + public ListVaultsRequest.Builder get() { + return ListVaultsRequest.builder().copy(request); + } + }, + new com.google.common.base.Function() { + @Override + public String apply(ListVaultsResponse response) { + return response.getOpcNextPage(); + } + }, + new com.google.common.base.Function< + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListVaultsRequest.Builder>, + ListVaultsRequest>() { + @Override + public ListVaultsRequest apply( + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListVaultsRequest.Builder> + input) { + if (input.getToken() == null) { + return input.getRequestBuilder().build(); + } else { + return input.getRequestBuilder() + .page(input.getToken().orNull()) + .build(); + } + } + }, + new com.google.common.base.Function() { + @Override + public ListVaultsResponse apply(ListVaultsRequest request) { + return client.listVaults(request); + } + }); + } + + /** + * Creates a new iterable which will iterate over the {@link com.oracle.bmc.keymanagement.model.VaultSummary} objects + * contained in responses from the listVaults operation. This iterable will fetch more data from the + * server as needed. + * + * @param request a request which can be sent to the service operation + * @return an {@link java.lang.Iterable} which can be used to iterate over the {@link com.oracle.bmc.keymanagement.model.VaultSummary} objects + * contained in responses received from the service. + */ + public Iterable listVaultsRecordIterator( + final ListVaultsRequest request) { + return new com.oracle.bmc.paginator.internal.ResponseRecordIterable< + ListVaultsRequest.Builder, ListVaultsRequest, ListVaultsResponse, + com.oracle.bmc.keymanagement.model.VaultSummary>( + new com.google.common.base.Supplier() { + @Override + public ListVaultsRequest.Builder get() { + return ListVaultsRequest.builder().copy(request); + } + }, + new com.google.common.base.Function() { + @Override + public String apply(ListVaultsResponse response) { + return response.getOpcNextPage(); + } + }, + new com.google.common.base.Function< + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListVaultsRequest.Builder>, + ListVaultsRequest>() { + @Override + public ListVaultsRequest apply( + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListVaultsRequest.Builder> + input) { + if (input.getToken() == null) { + return input.getRequestBuilder().build(); + } else { + return input.getRequestBuilder() + .page(input.getToken().orNull()) + .build(); + } + } + }, + new com.google.common.base.Function() { + @Override + public ListVaultsResponse apply(ListVaultsRequest request) { + return client.listVaults(request); + } + }, + new com.google.common.base.Function< + ListVaultsResponse, + java.util.List>() { + @Override + public java.util.List apply( + ListVaultsResponse response) { + return response.getItems(); + } + }); + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultWaiters.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultWaiters.java new file mode 100644 index 00000000000..883a88227b0 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/KmsVaultWaiters.java @@ -0,0 +1,116 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement; + +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; + +/** + * Collection of helper methods to produce {@link Waiter}s for different + * resources of KmsVault. + *

+ * The default configuration used is defined by {@link Waiters#DEFAULT_POLLING_WAITER}. + */ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.RequiredArgsConstructor +public class KmsVaultWaiters { + private final java.util.concurrent.ExecutorService executorService; + private final KmsVault client; + + /** + * Creates a new {@link Waiter} using default configuration. + * + * @param request the request to send + * @param targetStates the desired states to wait for. If multiple states are provided then the waiter will return once the resource reaches any of the provided states + * @return a new {@code Waiter} instance + */ + public com.oracle.bmc.waiter.Waiter forVault( + GetVaultRequest request, + com.oracle.bmc.keymanagement.model.Vault.LifecycleState... targetStates) { + org.apache.commons.lang3.Validate.notEmpty( + targetStates, "At least one targetState must be provided"); + org.apache.commons.lang3.Validate.noNullElements( + targetStates, "Null targetState values are not permitted"); + + return forVault( + com.oracle.bmc.waiter.Waiters.DEFAULT_POLLING_WAITER, request, targetStates); + } + + /** + * Creates a new {@link Waiter} using the provided configuration. + * + * @param request the request to send + * @param targetState the desired state to wait for + * @param terminationStrategy the {@link TerminationStrategy} to use + * @param delayStrategy the {@link DelayStrategy} to use + * @return a new {@code Waiter} instance + */ + public com.oracle.bmc.waiter.Waiter forVault( + GetVaultRequest request, + com.oracle.bmc.keymanagement.model.Vault.LifecycleState targetState, + com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, + com.oracle.bmc.waiter.DelayStrategy delayStrategy) { + org.apache.commons.lang3.Validate.notNull(targetState, "The targetState cannot be null"); + + return forVault( + com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), + request, + targetState); + } + + /** + * Creates a new {@link Waiter} using the provided configuration. + * + * @param request the request to send + * @param terminationStrategy the {@link TerminationStrategy} to use + * @param delayStrategy the {@link DelayStrategy} to use + * @param targetStates the desired states to wait for. The waiter will return once the resource reaches any of the provided states + * @return a new {@code Waiter} instance + */ + public com.oracle.bmc.waiter.Waiter forVault( + GetVaultRequest request, + com.oracle.bmc.waiter.TerminationStrategy terminationStrategy, + com.oracle.bmc.waiter.DelayStrategy delayStrategy, + com.oracle.bmc.keymanagement.model.Vault.LifecycleState... targetStates) { + org.apache.commons.lang3.Validate.notEmpty( + targetStates, "At least one target state must be provided"); + org.apache.commons.lang3.Validate.noNullElements( + targetStates, "Null target states are not permitted"); + + return forVault( + com.oracle.bmc.waiter.Waiters.newWaiter(terminationStrategy, delayStrategy), + request, + targetStates); + } + + // Helper method to create a new Waiter for Vault. + private com.oracle.bmc.waiter.Waiter forVault( + com.oracle.bmc.waiter.BmcGenericWaiter waiter, + final GetVaultRequest request, + final com.oracle.bmc.keymanagement.model.Vault.LifecycleState... targetStates) { + final java.util.Set + targetStatesSet = new java.util.HashSet<>(java.util.Arrays.asList(targetStates)); + + return new com.oracle.bmc.waiter.internal.SimpleWaiterImpl<>( + executorService, + waiter.toCallable( + com.google.common.base.Suppliers.ofInstance(request), + new com.google.common.base.Function() { + @Override + public GetVaultResponse apply(GetVaultRequest request) { + return client.getVault(request); + } + }, + new com.google.common.base.Predicate() { + @Override + public boolean apply(GetVaultResponse response) { + return targetStatesSet.contains( + response.getVault().getLifecycleState()); + } + }, + targetStatesSet.contains( + com.oracle.bmc.keymanagement.model.Vault.LifecycleState.Deleted)), + request); + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CancelVaultDeletionConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CancelVaultDeletionConverter.java new file mode 100644 index 00000000000..ed2978416fa --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CancelVaultDeletionConverter.java @@ -0,0 +1,114 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class CancelVaultDeletionConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static CancelVaultDeletionRequest interceptRequest(CancelVaultDeletionRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, CancelVaultDeletionRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getVaultId(), "vaultId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("vaults") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getVaultId())) + .path("actions") + .path("cancelDeletion"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + if (request.getOpcRetryToken() != null) { + ib.header("opc-retry-token", request.getOpcRetryToken()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, CancelVaultDeletionResponse> + fromResponse() { + final com.google.common.base.Function< + javax.ws.rs.core.Response, CancelVaultDeletionResponse> + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, CancelVaultDeletionResponse>() { + @Override + public CancelVaultDeletionResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace( + "Transform function invoked for CancelVaultDeletionResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = + RESPONSE_CONVERSION_FACTORY.create(Vault.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + CancelVaultDeletionResponse.Builder builder = + CancelVaultDeletionResponse.builder(); + + builder.vault(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + CancelVaultDeletionResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CreateKeyConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CreateKeyConverter.java new file mode 100644 index 00000000000..cafe8d22ccb --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CreateKeyConverter.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class CreateKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static CreateKeyRequest interceptRequest(CreateKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, CreateKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notNull(request.getCreateKeyDetails(), "createKeyDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget().path("/20180608").path("keys"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + if (request.getOpcRetryToken() != null) { + ib.header("opc-retry-token", request.getOpcRetryToken()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, CreateKeyResponse>() { + @Override + public CreateKeyResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for CreateKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = RESPONSE_CONVERSION_FACTORY.create(Key.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + CreateKeyResponse.Builder builder = CreateKeyResponse.builder(); + + builder.key(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + CreateKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CreateKeyVersionConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CreateKeyVersionConverter.java new file mode 100644 index 00000000000..5770227a5db --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CreateKeyVersionConverter.java @@ -0,0 +1,110 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class CreateKeyVersionConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static CreateKeyVersionRequest interceptRequest(CreateKeyVersionRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, CreateKeyVersionRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getKeyId(), "keyId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("keys") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getKeyId())) + .path("keyVersions"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + if (request.getOpcRetryToken() != null) { + ib.header("opc-retry-token", request.getOpcRetryToken()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, CreateKeyVersionResponse> + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, CreateKeyVersionResponse>() { + @Override + public CreateKeyVersionResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace( + "Transform function invoked for CreateKeyVersionResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + KeyVersion>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + KeyVersion.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + CreateKeyVersionResponse.Builder builder = + CreateKeyVersionResponse.builder(); + + builder.keyVersion(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + CreateKeyVersionResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CreateVaultConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CreateVaultConverter.java new file mode 100644 index 00000000000..1a4f6d32a78 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/CreateVaultConverter.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class CreateVaultConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static CreateVaultRequest interceptRequest(CreateVaultRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, CreateVaultRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notNull(request.getCreateVaultDetails(), "createVaultDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget().path("/20180608").path("vaults"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + if (request.getOpcRetryToken() != null) { + ib.header("opc-retry-token", request.getOpcRetryToken()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, CreateVaultResponse>() { + @Override + public CreateVaultResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for CreateVaultResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = + RESPONSE_CONVERSION_FACTORY.create(Vault.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + CreateVaultResponse.Builder builder = CreateVaultResponse.builder(); + + builder.vault(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + CreateVaultResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/DecryptConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/DecryptConverter.java new file mode 100644 index 00000000000..7b7e1c3a169 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/DecryptConverter.java @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class DecryptConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static DecryptRequest interceptRequest(DecryptRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, DecryptRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notNull(request.getDecryptDataDetails(), "decryptDataDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget().path("/20180608").path("decrypt"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, DecryptResponse>() { + @Override + public DecryptResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for DecryptResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + DecryptedData>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + DecryptedData.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + DecryptResponse.Builder builder = DecryptResponse.builder(); + + builder.decryptedData(response.getItem()); + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + DecryptResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/DisableKeyConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/DisableKeyConverter.java new file mode 100644 index 00000000000..49241744a4a --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/DisableKeyConverter.java @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class DisableKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static DisableKeyRequest interceptRequest(DisableKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, DisableKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getKeyId(), "keyId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("keys") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getKeyId())) + .path("actions") + .path("disable"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + if (request.getOpcRetryToken() != null) { + ib.header("opc-retry-token", request.getOpcRetryToken()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, DisableKeyResponse>() { + @Override + public DisableKeyResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for DisableKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = RESPONSE_CONVERSION_FACTORY.create(Key.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + DisableKeyResponse.Builder builder = DisableKeyResponse.builder(); + + builder.key(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + DisableKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/EnableKeyConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/EnableKeyConverter.java new file mode 100644 index 00000000000..47c631bca84 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/EnableKeyConverter.java @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class EnableKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static EnableKeyRequest interceptRequest(EnableKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, EnableKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getKeyId(), "keyId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("keys") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getKeyId())) + .path("actions") + .path("enable"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + if (request.getOpcRetryToken() != null) { + ib.header("opc-retry-token", request.getOpcRetryToken()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, EnableKeyResponse>() { + @Override + public EnableKeyResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for EnableKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = RESPONSE_CONVERSION_FACTORY.create(Key.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + EnableKeyResponse.Builder builder = EnableKeyResponse.builder(); + + builder.key(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + EnableKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/EncryptConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/EncryptConverter.java new file mode 100644 index 00000000000..c75174cfc4e --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/EncryptConverter.java @@ -0,0 +1,87 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class EncryptConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static EncryptRequest interceptRequest(EncryptRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, EncryptRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notNull(request.getEncryptDataDetails(), "encryptDataDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget().path("/20180608").path("encrypt"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, EncryptResponse>() { + @Override + public EncryptResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for EncryptResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + EncryptedData>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + EncryptedData.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + EncryptResponse.Builder builder = EncryptResponse.builder(); + + builder.encryptedData(response.getItem()); + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + EncryptResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GenerateDataEncryptionKeyConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GenerateDataEncryptionKeyConverter.java new file mode 100644 index 00000000000..bc1340cad8c --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GenerateDataEncryptionKeyConverter.java @@ -0,0 +1,94 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class GenerateDataEncryptionKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static GenerateDataEncryptionKeyRequest interceptRequest( + GenerateDataEncryptionKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, + GenerateDataEncryptionKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notNull(request.getGenerateKeyDetails(), "generateKeyDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget().path("/20180608").path("generateDataEncryptionKey"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, GenerateDataEncryptionKeyResponse> + fromResponse() { + final com.google.common.base.Function< + javax.ws.rs.core.Response, GenerateDataEncryptionKeyResponse> + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, GenerateDataEncryptionKeyResponse>() { + @Override + public GenerateDataEncryptionKeyResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace( + "Transform function invoked for GenerateDataEncryptionKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + GeneratedKey>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + GeneratedKey.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + GenerateDataEncryptionKeyResponse.Builder builder = + GenerateDataEncryptionKeyResponse.builder(); + + builder.generatedKey(response.getItem()); + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + GenerateDataEncryptionKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GetKeyConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GetKeyConverter.java new file mode 100644 index 00000000000..fa693e78de7 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GetKeyConverter.java @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class GetKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static GetKeyRequest interceptRequest(GetKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, GetKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getKeyId(), "keyId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("keys") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getKeyId())); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, GetKeyResponse>() { + @Override + public GetKeyResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for GetKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = RESPONSE_CONVERSION_FACTORY.create(Key.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + GetKeyResponse.Builder builder = GetKeyResponse.builder(); + + builder.key(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + GetKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GetKeyVersionConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GetKeyVersionConverter.java new file mode 100644 index 00000000000..e4d0b604a32 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GetKeyVersionConverter.java @@ -0,0 +1,108 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class GetKeyVersionConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static GetKeyVersionRequest interceptRequest(GetKeyVersionRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, GetKeyVersionRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getKeyId(), "keyId must not be blank"); + Validate.notBlank(request.getKeyVersionId(), "keyVersionId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("keys") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getKeyId())) + .path("keyVersions") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getKeyVersionId())); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, GetKeyVersionResponse>() { + @Override + public GetKeyVersionResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for GetKeyVersionResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + KeyVersion>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + KeyVersion.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + GetKeyVersionResponse.Builder builder = + GetKeyVersionResponse.builder(); + + builder.keyVersion(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + GetKeyVersionResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GetVaultConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GetVaultConverter.java new file mode 100644 index 00000000000..aa7189dde5d --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/GetVaultConverter.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class GetVaultConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static GetVaultRequest interceptRequest(GetVaultRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, GetVaultRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getVaultId(), "vaultId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("vaults") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getVaultId())); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, GetVaultResponse>() { + @Override + public GetVaultResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for GetVaultResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = + RESPONSE_CONVERSION_FACTORY.create(Vault.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + GetVaultResponse.Builder builder = GetVaultResponse.builder(); + + builder.vault(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + GetVaultResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ListKeyVersionsConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ListKeyVersionsConverter.java new file mode 100644 index 00000000000..9fe179a50a6 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ListKeyVersionsConverter.java @@ -0,0 +1,143 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class ListKeyVersionsConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static ListKeyVersionsRequest interceptRequest(ListKeyVersionsRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, ListKeyVersionsRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getKeyId(), "keyId must not be blank"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("keys") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getKeyId())) + .path("keyVersions"); + + if (request.getLimit() != null) { + target = + target.queryParam( + "limit", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getLimit())); + } + + if (request.getPage() != null) { + target = + target.queryParam( + "page", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getPage())); + } + + if (request.getSortBy() != null) { + target = + target.queryParam( + "sortBy", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getSortBy().getValue())); + } + + if (request.getSortOrder() != null) { + target = + target.queryParam( + "sortOrder", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getSortOrder().getValue())); + } + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, ListKeyVersionsResponse> + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, ListKeyVersionsResponse>() { + @Override + public ListKeyVersionsResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for ListKeyVersionsResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + java.util.List>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + new javax.ws.rs.core.GenericType< + java.util.List< + KeyVersionSummary>>() {}); + + com.oracle.bmc.http.internal.WithHeaders< + java.util.List> + response = responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + ListKeyVersionsResponse.Builder builder = + ListKeyVersionsResponse.builder(); + + builder.items(response.getItem()); + + com.google.common.base.Optional> + opcNextPageHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-next-page"); + if (opcNextPageHeader.isPresent()) { + builder.opcNextPage( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-next-page", + opcNextPageHeader.get().get(0), + String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + ListKeyVersionsResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ListKeysConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ListKeysConverter.java new file mode 100644 index 00000000000..db3800720ef --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ListKeysConverter.java @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class ListKeysConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static ListKeysRequest interceptRequest(ListKeysRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, ListKeysRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notNull(request.getCompartmentId(), "compartmentId is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget().path("/20180608").path("keys"); + + target = + target.queryParam( + "compartmentId", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getCompartmentId())); + + if (request.getLimit() != null) { + target = + target.queryParam( + "limit", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getLimit())); + } + + if (request.getPage() != null) { + target = + target.queryParam( + "page", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getPage())); + } + + if (request.getSortBy() != null) { + target = + target.queryParam( + "sortBy", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getSortBy().getValue())); + } + + if (request.getSortOrder() != null) { + target = + target.queryParam( + "sortOrder", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getSortOrder().getValue())); + } + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, ListKeysResponse>() { + @Override + public ListKeysResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for ListKeysResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + java.util.List>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + new javax.ws.rs.core.GenericType< + java.util.List>() {}); + + com.oracle.bmc.http.internal.WithHeaders> + response = responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + ListKeysResponse.Builder builder = ListKeysResponse.builder(); + + builder.items(response.getItem()); + + com.google.common.base.Optional> + opcNextPageHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-next-page"); + if (opcNextPageHeader.isPresent()) { + builder.opcNextPage( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-next-page", + opcNextPageHeader.get().get(0), + String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + ListKeysResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ListVaultsConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ListVaultsConverter.java new file mode 100644 index 00000000000..ca454d6531d --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ListVaultsConverter.java @@ -0,0 +1,139 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class ListVaultsConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static ListVaultsRequest interceptRequest(ListVaultsRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, ListVaultsRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notNull(request.getCompartmentId(), "compartmentId is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget().path("/20180608").path("vaults"); + + target = + target.queryParam( + "compartmentId", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getCompartmentId())); + + if (request.getLimit() != null) { + target = + target.queryParam( + "limit", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getLimit())); + } + + if (request.getPage() != null) { + target = + target.queryParam( + "page", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getPage())); + } + + if (request.getSortBy() != null) { + target = + target.queryParam( + "sortBy", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getSortBy().getValue())); + } + + if (request.getSortOrder() != null) { + target = + target.queryParam( + "sortOrder", + com.oracle.bmc.util.internal.HttpUtils.attemptEncodeQueryParam( + request.getSortOrder().getValue())); + } + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, ListVaultsResponse>() { + @Override + public ListVaultsResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for ListVaultsResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders< + java.util.List>> + responseFn = + RESPONSE_CONVERSION_FACTORY.create( + new javax.ws.rs.core.GenericType< + java.util.List>() {}); + + com.oracle.bmc.http.internal.WithHeaders< + java.util.List> + response = responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + ListVaultsResponse.Builder builder = ListVaultsResponse.builder(); + + builder.items(response.getItem()); + + com.google.common.base.Optional> + opcNextPageHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-next-page"); + if (opcNextPageHeader.isPresent()) { + builder.opcNextPage( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-next-page", + opcNextPageHeader.get().get(0), + String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + ListVaultsResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ScheduleVaultDeletionConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ScheduleVaultDeletionConverter.java new file mode 100644 index 00000000000..8566b3aa681 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/ScheduleVaultDeletionConverter.java @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class ScheduleVaultDeletionConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static ScheduleVaultDeletionRequest interceptRequest( + ScheduleVaultDeletionRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, ScheduleVaultDeletionRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getVaultId(), "vaultId must not be blank"); + Validate.notNull( + request.getScheduleVaultDeletionDetails(), + "scheduleVaultDeletionDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("vaults") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getVaultId())) + .path("actions") + .path("scheduleDeletion"); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + if (request.getOpcRetryToken() != null) { + ib.header("opc-retry-token", request.getOpcRetryToken()); + } + + return ib; + } + + public static com.google.common.base.Function< + javax.ws.rs.core.Response, ScheduleVaultDeletionResponse> + fromResponse() { + final com.google.common.base.Function< + javax.ws.rs.core.Response, ScheduleVaultDeletionResponse> + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, ScheduleVaultDeletionResponse>() { + @Override + public ScheduleVaultDeletionResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace( + "Transform function invoked for ScheduleVaultDeletionResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = + RESPONSE_CONVERSION_FACTORY.create(Vault.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + ScheduleVaultDeletionResponse.Builder builder = + ScheduleVaultDeletionResponse.builder(); + + builder.vault(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + ScheduleVaultDeletionResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/UpdateKeyConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/UpdateKeyConverter.java new file mode 100644 index 00000000000..e13b54bfe82 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/UpdateKeyConverter.java @@ -0,0 +1,103 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class UpdateKeyConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static UpdateKeyRequest interceptRequest(UpdateKeyRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, UpdateKeyRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getKeyId(), "keyId must not be blank"); + Validate.notNull(request.getUpdateKeyDetails(), "updateKeyDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("keys") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getKeyId())); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, UpdateKeyResponse>() { + @Override + public UpdateKeyResponse apply(javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for UpdateKeyResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = RESPONSE_CONVERSION_FACTORY.create(Key.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + UpdateKeyResponse.Builder builder = UpdateKeyResponse.builder(); + + builder.key(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + UpdateKeyResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/UpdateVaultConverter.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/UpdateVaultConverter.java new file mode 100644 index 00000000000..37e1749d24e --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/internal/http/UpdateVaultConverter.java @@ -0,0 +1,105 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.internal.http; + +import com.oracle.bmc.keymanagement.model.*; +import com.oracle.bmc.keymanagement.requests.*; +import com.oracle.bmc.keymanagement.responses.*; +import org.apache.commons.lang3.Validate; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.extern.slf4j.Slf4j +public class UpdateVaultConverter { + private static final com.oracle.bmc.http.internal.ResponseConversionFunctionFactory + RESPONSE_CONVERSION_FACTORY = + new com.oracle.bmc.http.internal.ResponseConversionFunctionFactory(); + + public static UpdateVaultRequest interceptRequest(UpdateVaultRequest request) { + + return request; + } + + public static com.oracle.bmc.http.internal.WrappedInvocationBuilder fromRequest( + com.oracle.bmc.http.internal.RestClient client, UpdateVaultRequest request) { + Validate.notNull(request, "request instance is required"); + Validate.notBlank(request.getVaultId(), "vaultId must not be blank"); + Validate.notNull(request.getUpdateVaultDetails(), "updateVaultDetails is required"); + + com.oracle.bmc.http.internal.WrappedWebTarget target = + client.getBaseTarget() + .path("/20180608") + .path("vaults") + .path( + com.oracle.bmc.util.internal.HttpUtils.encodePathSegment( + request.getVaultId())); + + com.oracle.bmc.http.internal.WrappedInvocationBuilder ib = target.request(); + + ib.accept(javax.ws.rs.core.MediaType.APPLICATION_JSON); + + if (request.getIfMatch() != null) { + ib.header("if-match", request.getIfMatch()); + } + + if (request.getOpcRequestId() != null) { + ib.header("opc-request-id", request.getOpcRequestId()); + } + + return ib; + } + + public static com.google.common.base.Function + fromResponse() { + final com.google.common.base.Function + transformer = + new com.google.common.base.Function< + javax.ws.rs.core.Response, UpdateVaultResponse>() { + @Override + public UpdateVaultResponse apply( + javax.ws.rs.core.Response rawResponse) { + LOG.trace("Transform function invoked for UpdateVaultResponse"); + com.google.common.base.Function< + javax.ws.rs.core.Response, + com.oracle.bmc.http.internal.WithHeaders> + responseFn = + RESPONSE_CONVERSION_FACTORY.create(Vault.class); + + com.oracle.bmc.http.internal.WithHeaders response = + responseFn.apply(rawResponse); + javax.ws.rs.core.MultivaluedMap headers = + response.getHeaders(); + + UpdateVaultResponse.Builder builder = UpdateVaultResponse.builder(); + + builder.vault(response.getItem()); + + com.google.common.base.Optional> etagHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "etag"); + if (etagHeader.isPresent()) { + builder.etag( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "etag", etagHeader.get().get(0), String.class)); + } + + com.google.common.base.Optional> + opcRequestIdHeader = + com.oracle.bmc.http.internal.HeaderUtils.get( + headers, "opc-request-id"); + if (opcRequestIdHeader.isPresent()) { + builder.opcRequestId( + com.oracle.bmc.http.internal.HeaderUtils.toValue( + "opc-request-id", + opcRequestIdHeader.get().get(0), + String.class)); + } + + UpdateVaultResponse responseWrapper = builder.build(); + + return responseWrapper; + } + }; + return transformer; + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/CreateKeyDetails.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/CreateKeyDetails.java new file mode 100644 index 00000000000..9730d278d6e --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/CreateKeyDetails.java @@ -0,0 +1,100 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = CreateKeyDetails.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class CreateKeyDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + private String compartmentId; + + public Builder compartmentId(String compartmentId) { + this.compartmentId = compartmentId; + this.__explicitlySet__.add("compartmentId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + private String displayName; + + public Builder displayName(String displayName) { + this.displayName = displayName; + this.__explicitlySet__.add("displayName"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("keyShape") + private KeyShape keyShape; + + public Builder keyShape(KeyShape keyShape) { + this.keyShape = keyShape; + this.__explicitlySet__.add("keyShape"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public CreateKeyDetails build() { + CreateKeyDetails __instance__ = + new CreateKeyDetails(compartmentId, displayName, keyShape); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(CreateKeyDetails o) { + Builder copiedBuilder = + compartmentId(o.getCompartmentId()) + .displayName(o.getDisplayName()) + .keyShape(o.getKeyShape()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The OCID of the compartment that contains this key. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + String compartmentId; + + /** + * A user-friendly name for the key. It does not have to be unique, and it is changeable. + * Avoid entering confidential information. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + String displayName; + + @com.fasterxml.jackson.annotation.JsonProperty("keyShape") + KeyShape keyShape; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/CreateVaultDetails.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/CreateVaultDetails.java new file mode 100644 index 00000000000..59f2c5af163 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/CreateVaultDetails.java @@ -0,0 +1,140 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize( + builder = CreateVaultDetails.Builder.class +) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class CreateVaultDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + private String compartmentId; + + public Builder compartmentId(String compartmentId) { + this.compartmentId = compartmentId; + this.__explicitlySet__.add("compartmentId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + private String displayName; + + public Builder displayName(String displayName) { + this.displayName = displayName; + this.__explicitlySet__.add("displayName"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("vaultType") + private VaultType vaultType; + + public Builder vaultType(VaultType vaultType) { + this.vaultType = vaultType; + this.__explicitlySet__.add("vaultType"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public CreateVaultDetails build() { + CreateVaultDetails __instance__ = + new CreateVaultDetails(compartmentId, displayName, vaultType); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(CreateVaultDetails o) { + Builder copiedBuilder = + compartmentId(o.getCompartmentId()) + .displayName(o.getDisplayName()) + .vaultType(o.getVaultType()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The OCID of the compartment where you want to create this vault. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + String compartmentId; + + /** + * A user-friendly name for the vault. It does not have to be unique, and it is changeable. + * Avoid entering confidential information. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + String displayName; + /** + * The type of vault to create. Each type of vault stores the key with different degrees of isolation and has different options and pricing. + * + **/ + public enum VaultType { + VirtualPrivate("VIRTUAL_PRIVATE"), + ; + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (VaultType v : VaultType.values()) { + map.put(v.getValue(), v); + } + } + + VaultType(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static VaultType create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + throw new RuntimeException("Invalid VaultType: " + key); + } + }; + /** + * The type of vault to create. Each type of vault stores the key with different degrees of isolation and has different options and pricing. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("vaultType") + VaultType vaultType; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/DecryptDataDetails.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/DecryptDataDetails.java new file mode 100644 index 00000000000..3fce129b6c3 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/DecryptDataDetails.java @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize( + builder = DecryptDataDetails.Builder.class +) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class DecryptDataDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("associatedData") + private java.util.Map associatedData; + + public Builder associatedData(java.util.Map associatedData) { + this.associatedData = associatedData; + this.__explicitlySet__.add("associatedData"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("ciphertext") + private String ciphertext; + + public Builder ciphertext(String ciphertext) { + this.ciphertext = ciphertext; + this.__explicitlySet__.add("ciphertext"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + private String keyId; + + public Builder keyId(String keyId) { + this.keyId = keyId; + this.__explicitlySet__.add("keyId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public DecryptDataDetails build() { + DecryptDataDetails __instance__ = + new DecryptDataDetails(associatedData, ciphertext, keyId); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(DecryptDataDetails o) { + Builder copiedBuilder = + associatedData(o.getAssociatedData()) + .ciphertext(o.getCiphertext()) + .keyId(o.getKeyId()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Information that can be used to provide an encryption context for the + * encrypted data. The length of the string representation of the associatedData + * must be fewer than 4096 characters. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("associatedData") + java.util.Map associatedData; + + /** + * The encrypted data to decrypt. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("ciphertext") + String ciphertext; + + /** + * The OCID of the key used to encrypt the ciphertext. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + String keyId; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/DecryptedData.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/DecryptedData.java new file mode 100644 index 00000000000..ef033ee9964 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/DecryptedData.java @@ -0,0 +1,83 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = DecryptedData.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class DecryptedData { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("plaintext") + private String plaintext; + + public Builder plaintext(String plaintext) { + this.plaintext = plaintext; + this.__explicitlySet__.add("plaintext"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("plaintextChecksum") + private String plaintextChecksum; + + public Builder plaintextChecksum(String plaintextChecksum) { + this.plaintextChecksum = plaintextChecksum; + this.__explicitlySet__.add("plaintextChecksum"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public DecryptedData build() { + DecryptedData __instance__ = new DecryptedData(plaintext, plaintextChecksum); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(DecryptedData o) { + Builder copiedBuilder = + plaintext(o.getPlaintext()).plaintextChecksum(o.getPlaintextChecksum()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The decrypted data, in the form of a base64-encoded value. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("plaintext") + String plaintext; + + /** + * Checksum of the decrypted data. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("plaintextChecksum") + String plaintextChecksum; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/EncryptDataDetails.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/EncryptDataDetails.java new file mode 100644 index 00000000000..e9156dea656 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/EncryptDataDetails.java @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize( + builder = EncryptDataDetails.Builder.class +) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class EncryptDataDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("associatedData") + private java.util.Map associatedData; + + public Builder associatedData(java.util.Map associatedData) { + this.associatedData = associatedData; + this.__explicitlySet__.add("associatedData"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + private String keyId; + + public Builder keyId(String keyId) { + this.keyId = keyId; + this.__explicitlySet__.add("keyId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("plaintext") + private String plaintext; + + public Builder plaintext(String plaintext) { + this.plaintext = plaintext; + this.__explicitlySet__.add("plaintext"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public EncryptDataDetails build() { + EncryptDataDetails __instance__ = + new EncryptDataDetails(associatedData, keyId, plaintext); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(EncryptDataDetails o) { + Builder copiedBuilder = + associatedData(o.getAssociatedData()) + .keyId(o.getKeyId()) + .plaintext(o.getPlaintext()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Information that can be used to provide an encryption context for the + * encrypted data. The length of the string representation of the associatedData + * must be fewer than 4096 characters. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("associatedData") + java.util.Map associatedData; + + /** + * The OCID of the key to encrypt with. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + String keyId; + + /** + * The plaintext data to encrypt. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("plaintext") + String plaintext; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/EncryptedData.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/EncryptedData.java new file mode 100644 index 00000000000..46252915398 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/EncryptedData.java @@ -0,0 +1,67 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = EncryptedData.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class EncryptedData { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("ciphertext") + private String ciphertext; + + public Builder ciphertext(String ciphertext) { + this.ciphertext = ciphertext; + this.__explicitlySet__.add("ciphertext"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public EncryptedData build() { + EncryptedData __instance__ = new EncryptedData(ciphertext); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(EncryptedData o) { + Builder copiedBuilder = ciphertext(o.getCiphertext()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The encrypted data. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("ciphertext") + String ciphertext; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/GenerateKeyDetails.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/GenerateKeyDetails.java new file mode 100644 index 00000000000..149b99aedc2 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/GenerateKeyDetails.java @@ -0,0 +1,119 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize( + builder = GenerateKeyDetails.Builder.class +) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class GenerateKeyDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("associatedData") + private java.util.Map associatedData; + + public Builder associatedData(java.util.Map associatedData) { + this.associatedData = associatedData; + this.__explicitlySet__.add("associatedData"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("includePlaintextKey") + private Boolean includePlaintextKey; + + public Builder includePlaintextKey(Boolean includePlaintextKey) { + this.includePlaintextKey = includePlaintextKey; + this.__explicitlySet__.add("includePlaintextKey"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + private String keyId; + + public Builder keyId(String keyId) { + this.keyId = keyId; + this.__explicitlySet__.add("keyId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("keyShape") + private KeyShape keyShape; + + public Builder keyShape(KeyShape keyShape) { + this.keyShape = keyShape; + this.__explicitlySet__.add("keyShape"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public GenerateKeyDetails build() { + GenerateKeyDetails __instance__ = + new GenerateKeyDetails(associatedData, includePlaintextKey, keyId, keyShape); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(GenerateKeyDetails o) { + Builder copiedBuilder = + associatedData(o.getAssociatedData()) + .includePlaintextKey(o.getIncludePlaintextKey()) + .keyId(o.getKeyId()) + .keyShape(o.getKeyShape()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * Information that can be used to provide an encryption context for the + * encrypted data. The length of the string representation of the associatedData + * must be fewer than 4096 characters. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("associatedData") + java.util.Map associatedData; + + /** + * If true, the generated key is also returned unencrypted. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("includePlaintextKey") + Boolean includePlaintextKey; + + /** + * The OCID of the master encryption key to encrypt the generated data encryption key with. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + String keyId; + + @com.fasterxml.jackson.annotation.JsonProperty("keyShape") + KeyShape keyShape; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/GeneratedKey.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/GeneratedKey.java new file mode 100644 index 00000000000..be4d9afa3a2 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/GeneratedKey.java @@ -0,0 +1,107 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = GeneratedKey.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class GeneratedKey { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("ciphertext") + private String ciphertext; + + public Builder ciphertext(String ciphertext) { + this.ciphertext = ciphertext; + this.__explicitlySet__.add("ciphertext"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("plaintext") + private String plaintext; + + public Builder plaintext(String plaintext) { + this.plaintext = plaintext; + this.__explicitlySet__.add("plaintext"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("plaintextChecksum") + private String plaintextChecksum; + + public Builder plaintextChecksum(String plaintextChecksum) { + this.plaintextChecksum = plaintextChecksum; + this.__explicitlySet__.add("plaintextChecksum"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public GeneratedKey build() { + GeneratedKey __instance__ = new GeneratedKey(ciphertext, plaintext, plaintextChecksum); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(GeneratedKey o) { + Builder copiedBuilder = + ciphertext(o.getCiphertext()) + .plaintext(o.getPlaintext()) + .plaintextChecksum(o.getPlaintextChecksum()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The encrypted generated data encryption key. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("ciphertext") + String ciphertext; + + /** + * The plaintext generated data encryption key, a base64-encoded + * sequence of random bytes, which is included if the + * GenerateDataEncryptionKey request includes the \"includePlaintextKey\" + * parameter and sets its value to 'true'. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("plaintext") + String plaintext; + + /** + * The checksum of the plaintext generated data encryption key, which + * is included if the GenerateDataEncryptionKey request includes the + * \"includePlaintextKey parameter and sets its value to 'true'. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("plaintextChecksum") + String plaintextChecksum; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/Key.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/Key.java new file mode 100644 index 00000000000..da7bce2b5f0 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/Key.java @@ -0,0 +1,293 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = Key.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class Key { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + private String compartmentId; + + public Builder compartmentId(String compartmentId) { + this.compartmentId = compartmentId; + this.__explicitlySet__.add("compartmentId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("currentKeyVersion") + private String currentKeyVersion; + + public Builder currentKeyVersion(String currentKeyVersion) { + this.currentKeyVersion = currentKeyVersion; + this.__explicitlySet__.add("currentKeyVersion"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("definedTags") + private java.util.Map> definedTags; + + public Builder definedTags( + java.util.Map> definedTags) { + this.definedTags = definedTags; + this.__explicitlySet__.add("definedTags"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + private String displayName; + + public Builder displayName(String displayName) { + this.displayName = displayName; + this.__explicitlySet__.add("displayName"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") + private java.util.Map freeformTags; + + public Builder freeformTags(java.util.Map freeformTags) { + this.freeformTags = freeformTags; + this.__explicitlySet__.add("freeformTags"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("id") + private String id; + + public Builder id(String id) { + this.id = id; + this.__explicitlySet__.add("id"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("keyShape") + private KeyShape keyShape; + + public Builder keyShape(KeyShape keyShape) { + this.keyShape = keyShape; + this.__explicitlySet__.add("keyShape"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("lifecycleState") + private LifecycleState lifecycleState; + + public Builder lifecycleState(LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + this.__explicitlySet__.add("lifecycleState"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + private java.util.Date timeCreated; + + public Builder timeCreated(java.util.Date timeCreated) { + this.timeCreated = timeCreated; + this.__explicitlySet__.add("timeCreated"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("vaultId") + private String vaultId; + + public Builder vaultId(String vaultId) { + this.vaultId = vaultId; + this.__explicitlySet__.add("vaultId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public Key build() { + Key __instance__ = + new Key( + compartmentId, + currentKeyVersion, + definedTags, + displayName, + freeformTags, + id, + keyShape, + lifecycleState, + timeCreated, + vaultId); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(Key o) { + Builder copiedBuilder = + compartmentId(o.getCompartmentId()) + .currentKeyVersion(o.getCurrentKeyVersion()) + .definedTags(o.getDefinedTags()) + .displayName(o.getDisplayName()) + .freeformTags(o.getFreeformTags()) + .id(o.getId()) + .keyShape(o.getKeyShape()) + .lifecycleState(o.getLifecycleState()) + .timeCreated(o.getTimeCreated()) + .vaultId(o.getVaultId()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The OCID of the compartment that contains this key. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + String compartmentId; + + /** + * The OCID of the KeyVersion resource used in cryptographic operations. During key rotation, service may be in transitional state + * where this or a newer KeyVersion are used intermittently, and currentKeyVersion field is updated once service is guaranteed to + * use new KeyVersion for all consequent encrypt operations. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("currentKeyVersion") + String currentKeyVersion; + + /** + * Usage of predefined tag keys. These predefined keys are scoped to namespaces. + * Example: `{\"foo-namespace\": {\"bar-key\": \"foo-value\"}}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("definedTags") + java.util.Map> definedTags; + + /** + * A user-friendly name for the key. It does not have to be unique, and it is changeable. + * Avoid entering confidential information. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + String displayName; + + /** + * Simple key-value pair that is applied without any predefined name, type, or scope. + * Exists for cross-compatibility only. + * Example: `{\"bar-key\": \"value\"}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") + java.util.Map freeformTags; + + /** + * The OCID of the key. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("id") + String id; + + @com.fasterxml.jackson.annotation.JsonProperty("keyShape") + KeyShape keyShape; + /** + * The key's current state. + *

+ * Example: `ENABLED` + * + **/ + @lombok.extern.slf4j.Slf4j + public enum LifecycleState { + Creating("CREATING"), + Enabling("ENABLING"), + Enabled("ENABLED"), + Disabling("DISABLING"), + Disabled("DISABLED"), + Deleting("DELETING"), + Deleted("DELETED"), + PendingDeletion("PENDING_DELETION"), + SchedulingDeletion("SCHEDULING_DELETION"), + CancellingDeletion("CANCELLING_DELETION"), + + /** + * This value is used if a service returns a value for this enum that is not recognized by this + * version of the SDK. + */ + UnknownEnumValue(null); + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (LifecycleState v : LifecycleState.values()) { + if (v != UnknownEnumValue) { + map.put(v.getValue(), v); + } + } + } + + LifecycleState(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static LifecycleState create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + LOG.warn( + "Received unknown value '{}' for enum 'LifecycleState', returning UnknownEnumValue", + key); + return UnknownEnumValue; + } + }; + /** + * The key's current state. + *

+ * Example: `ENABLED` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("lifecycleState") + LifecycleState lifecycleState; + + /** + * The date and time the key was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. + *

+ * Example: `2018-04-03T21:10:29.600Z` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + java.util.Date timeCreated; + + /** + * The OCID of the vault that contains this key. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("vaultId") + String vaultId; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeyShape.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeyShape.java new file mode 100644 index 00000000000..68ed3c2dc3c --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeyShape.java @@ -0,0 +1,128 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * The cryptographic properties of a key. + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = KeyShape.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class KeyShape { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("algorithm") + private Algorithm algorithm; + + public Builder algorithm(Algorithm algorithm) { + this.algorithm = algorithm; + this.__explicitlySet__.add("algorithm"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("length") + private Integer length; + + public Builder length(Integer length) { + this.length = length; + this.__explicitlySet__.add("length"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public KeyShape build() { + KeyShape __instance__ = new KeyShape(algorithm, length); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(KeyShape o) { + Builder copiedBuilder = algorithm(o.getAlgorithm()).length(o.getLength()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The algorithm used by a key's KeyVersions to encrypt or decrypt. + **/ + @lombok.extern.slf4j.Slf4j + public enum Algorithm { + Aes("AES"), + + /** + * This value is used if a service returns a value for this enum that is not recognized by this + * version of the SDK. + */ + UnknownEnumValue(null); + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (Algorithm v : Algorithm.values()) { + if (v != UnknownEnumValue) { + map.put(v.getValue(), v); + } + } + } + + Algorithm(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static Algorithm create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + LOG.warn( + "Received unknown value '{}' for enum 'Algorithm', returning UnknownEnumValue", + key); + return UnknownEnumValue; + } + }; + /** + * The algorithm used by a key's KeyVersions to encrypt or decrypt. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("algorithm") + Algorithm algorithm; + + /** + * The length of the key, expressed as an integer. Values of 16, 24, or 32 are supported. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("length") + Integer length; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeySummary.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeySummary.java new file mode 100644 index 00000000000..af3f37d1dff --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeySummary.java @@ -0,0 +1,259 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = KeySummary.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class KeySummary { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + private String compartmentId; + + public Builder compartmentId(String compartmentId) { + this.compartmentId = compartmentId; + this.__explicitlySet__.add("compartmentId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("definedTags") + private java.util.Map> definedTags; + + public Builder definedTags( + java.util.Map> definedTags) { + this.definedTags = definedTags; + this.__explicitlySet__.add("definedTags"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + private String displayName; + + public Builder displayName(String displayName) { + this.displayName = displayName; + this.__explicitlySet__.add("displayName"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") + private java.util.Map freeformTags; + + public Builder freeformTags(java.util.Map freeformTags) { + this.freeformTags = freeformTags; + this.__explicitlySet__.add("freeformTags"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("id") + private String id; + + public Builder id(String id) { + this.id = id; + this.__explicitlySet__.add("id"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("lifecycleState") + private LifecycleState lifecycleState; + + public Builder lifecycleState(LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + this.__explicitlySet__.add("lifecycleState"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + private java.util.Date timeCreated; + + public Builder timeCreated(java.util.Date timeCreated) { + this.timeCreated = timeCreated; + this.__explicitlySet__.add("timeCreated"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("vaultId") + private String vaultId; + + public Builder vaultId(String vaultId) { + this.vaultId = vaultId; + this.__explicitlySet__.add("vaultId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public KeySummary build() { + KeySummary __instance__ = + new KeySummary( + compartmentId, + definedTags, + displayName, + freeformTags, + id, + lifecycleState, + timeCreated, + vaultId); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(KeySummary o) { + Builder copiedBuilder = + compartmentId(o.getCompartmentId()) + .definedTags(o.getDefinedTags()) + .displayName(o.getDisplayName()) + .freeformTags(o.getFreeformTags()) + .id(o.getId()) + .lifecycleState(o.getLifecycleState()) + .timeCreated(o.getTimeCreated()) + .vaultId(o.getVaultId()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The OCID of the compartment that contains the key. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + String compartmentId; + + /** + * Usage of predefined tag keys. These predefined keys are scoped to namespaces. + * Example: `{\"foo-namespace\": {\"bar-key\": \"foo-value\"}}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("definedTags") + java.util.Map> definedTags; + + /** + * A user-friendly name for the key. It does not have to be unique, and it is changeable. + * Avoid entering confidential information. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + String displayName; + + /** + * Simple key-value pair that is applied without any predefined name, type, or scope. + * Exists for cross-compatibility only. + * Example: `{\"bar-key\": \"value\"}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") + java.util.Map freeformTags; + + /** + * The OCID of the key. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("id") + String id; + /** + * The key's current state. + *

+ * Example: `ENABLED` + * + **/ + @lombok.extern.slf4j.Slf4j + public enum LifecycleState { + Creating("CREATING"), + Enabling("ENABLING"), + Enabled("ENABLED"), + Disabling("DISABLING"), + Disabled("DISABLED"), + Deleting("DELETING"), + Deleted("DELETED"), + PendingDeletion("PENDING_DELETION"), + SchedulingDeletion("SCHEDULING_DELETION"), + CancellingDeletion("CANCELLING_DELETION"), + + /** + * This value is used if a service returns a value for this enum that is not recognized by this + * version of the SDK. + */ + UnknownEnumValue(null); + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (LifecycleState v : LifecycleState.values()) { + if (v != UnknownEnumValue) { + map.put(v.getValue(), v); + } + } + } + + LifecycleState(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static LifecycleState create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + LOG.warn( + "Received unknown value '{}' for enum 'LifecycleState', returning UnknownEnumValue", + key); + return UnknownEnumValue; + } + }; + /** + * The key's current state. + *

+ * Example: `ENABLED` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("lifecycleState") + LifecycleState lifecycleState; + + /** + * The date and time the key was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. + *

+ * Example: `2018-04-03T21:10:29.600Z` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + java.util.Date timeCreated; + + /** + * The OCID of the vault that contains the key. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("vaultId") + String vaultId; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeyVersion.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeyVersion.java new file mode 100644 index 00000000000..5528834437d --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeyVersion.java @@ -0,0 +1,136 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = KeyVersion.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class KeyVersion { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + private String compartmentId; + + public Builder compartmentId(String compartmentId) { + this.compartmentId = compartmentId; + this.__explicitlySet__.add("compartmentId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("id") + private String id; + + public Builder id(String id) { + this.id = id; + this.__explicitlySet__.add("id"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + private String keyId; + + public Builder keyId(String keyId) { + this.keyId = keyId; + this.__explicitlySet__.add("keyId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + private java.util.Date timeCreated; + + public Builder timeCreated(java.util.Date timeCreated) { + this.timeCreated = timeCreated; + this.__explicitlySet__.add("timeCreated"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("vaultId") + private String vaultId; + + public Builder vaultId(String vaultId) { + this.vaultId = vaultId; + this.__explicitlySet__.add("vaultId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public KeyVersion build() { + KeyVersion __instance__ = + new KeyVersion(compartmentId, id, keyId, timeCreated, vaultId); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(KeyVersion o) { + Builder copiedBuilder = + compartmentId(o.getCompartmentId()) + .id(o.getId()) + .keyId(o.getKeyId()) + .timeCreated(o.getTimeCreated()) + .vaultId(o.getVaultId()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The OCID of the compartment that contains this key version. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + String compartmentId; + + /** + * The OCID of the key version. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("id") + String id; + + /** + * The OCID of the key associated with this key version. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + String keyId; + + /** + * The date and time this key version was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. + *

+ * Example: `2018-04-03T21:10:29.600Z` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + java.util.Date timeCreated; + + /** + * The OCID of the vault that contains this key version. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("vaultId") + String vaultId; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeyVersionSummary.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeyVersionSummary.java new file mode 100644 index 00000000000..e70214901a5 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/KeyVersionSummary.java @@ -0,0 +1,138 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize( + builder = KeyVersionSummary.Builder.class +) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class KeyVersionSummary { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + private String compartmentId; + + public Builder compartmentId(String compartmentId) { + this.compartmentId = compartmentId; + this.__explicitlySet__.add("compartmentId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("id") + private String id; + + public Builder id(String id) { + this.id = id; + this.__explicitlySet__.add("id"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + private String keyId; + + public Builder keyId(String keyId) { + this.keyId = keyId; + this.__explicitlySet__.add("keyId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + private java.util.Date timeCreated; + + public Builder timeCreated(java.util.Date timeCreated) { + this.timeCreated = timeCreated; + this.__explicitlySet__.add("timeCreated"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("vaultId") + private String vaultId; + + public Builder vaultId(String vaultId) { + this.vaultId = vaultId; + this.__explicitlySet__.add("vaultId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public KeyVersionSummary build() { + KeyVersionSummary __instance__ = + new KeyVersionSummary(compartmentId, id, keyId, timeCreated, vaultId); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(KeyVersionSummary o) { + Builder copiedBuilder = + compartmentId(o.getCompartmentId()) + .id(o.getId()) + .keyId(o.getKeyId()) + .timeCreated(o.getTimeCreated()) + .vaultId(o.getVaultId()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The OCID of the compartment that contains this key version. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + String compartmentId; + + /** + * The OCID of the key version. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("id") + String id; + + /** + * The OCID of the key associated with this key version. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("keyId") + String keyId; + + /** + * The date and time this key version was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. + *

+ * Example: `2018-04-03T21:10:29.600Z` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + java.util.Date timeCreated; + + /** + * The OCID of the vault that contains this key version. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("vaultId") + String vaultId; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/ScheduleVaultDeletionDetails.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/ScheduleVaultDeletionDetails.java new file mode 100644 index 00000000000..fdaf1f65aac --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/ScheduleVaultDeletionDetails.java @@ -0,0 +1,73 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * Details for scheduling Vault deletion + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize( + builder = ScheduleVaultDeletionDetails.Builder.class +) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class ScheduleVaultDeletionDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("timeOfDeletion") + private java.util.Date timeOfDeletion; + + public Builder timeOfDeletion(java.util.Date timeOfDeletion) { + this.timeOfDeletion = timeOfDeletion; + this.__explicitlySet__.add("timeOfDeletion"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public ScheduleVaultDeletionDetails build() { + ScheduleVaultDeletionDetails __instance__ = + new ScheduleVaultDeletionDetails(timeOfDeletion); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(ScheduleVaultDeletionDetails o) { + Builder copiedBuilder = timeOfDeletion(o.getTimeOfDeletion()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * An optional property to indicate the deletion time of the Vault. + * The time format should comply with RFC-3339 standards. This time must be between 7 to 30 days from the time + * when the request is received. If the property is missing, it will be set to 30 days from request time by default. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("timeOfDeletion") + java.util.Date timeOfDeletion; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/UpdateKeyDetails.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/UpdateKeyDetails.java new file mode 100644 index 00000000000..1ec0c4d5fe6 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/UpdateKeyDetails.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = UpdateKeyDetails.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class UpdateKeyDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + private String displayName; + + public Builder displayName(String displayName) { + this.displayName = displayName; + this.__explicitlySet__.add("displayName"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public UpdateKeyDetails build() { + UpdateKeyDetails __instance__ = new UpdateKeyDetails(displayName); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(UpdateKeyDetails o) { + Builder copiedBuilder = displayName(o.getDisplayName()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A user-friendly name for the key. It does not have to be unique, and it is changeable. + * Avoid entering confidential information. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + String displayName; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/UpdateVaultDetails.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/UpdateVaultDetails.java new file mode 100644 index 00000000000..c5764b96324 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/UpdateVaultDetails.java @@ -0,0 +1,71 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize( + builder = UpdateVaultDetails.Builder.class +) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class UpdateVaultDetails { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + private String displayName; + + public Builder displayName(String displayName) { + this.displayName = displayName; + this.__explicitlySet__.add("displayName"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public UpdateVaultDetails build() { + UpdateVaultDetails __instance__ = new UpdateVaultDetails(displayName); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(UpdateVaultDetails o) { + Builder copiedBuilder = displayName(o.getDisplayName()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * A user-friendly name for the vault. It does not have to be unique, and it is changeable. + * Avoid entering confidential information. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + String displayName; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/Vault.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/Vault.java new file mode 100644 index 00000000000..28721029e59 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/Vault.java @@ -0,0 +1,355 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = Vault.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class Vault { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + private String compartmentId; + + public Builder compartmentId(String compartmentId) { + this.compartmentId = compartmentId; + this.__explicitlySet__.add("compartmentId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("cryptoEndpoint") + private String cryptoEndpoint; + + public Builder cryptoEndpoint(String cryptoEndpoint) { + this.cryptoEndpoint = cryptoEndpoint; + this.__explicitlySet__.add("cryptoEndpoint"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("definedTags") + private java.util.Map> definedTags; + + public Builder definedTags( + java.util.Map> definedTags) { + this.definedTags = definedTags; + this.__explicitlySet__.add("definedTags"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + private String displayName; + + public Builder displayName(String displayName) { + this.displayName = displayName; + this.__explicitlySet__.add("displayName"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") + private java.util.Map freeformTags; + + public Builder freeformTags(java.util.Map freeformTags) { + this.freeformTags = freeformTags; + this.__explicitlySet__.add("freeformTags"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("id") + private String id; + + public Builder id(String id) { + this.id = id; + this.__explicitlySet__.add("id"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("lifecycleState") + private LifecycleState lifecycleState; + + public Builder lifecycleState(LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + this.__explicitlySet__.add("lifecycleState"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("managementEndpoint") + private String managementEndpoint; + + public Builder managementEndpoint(String managementEndpoint) { + this.managementEndpoint = managementEndpoint; + this.__explicitlySet__.add("managementEndpoint"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + private java.util.Date timeCreated; + + public Builder timeCreated(java.util.Date timeCreated) { + this.timeCreated = timeCreated; + this.__explicitlySet__.add("timeCreated"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("timeOfDeletion") + private java.util.Date timeOfDeletion; + + public Builder timeOfDeletion(java.util.Date timeOfDeletion) { + this.timeOfDeletion = timeOfDeletion; + this.__explicitlySet__.add("timeOfDeletion"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("vaultType") + private VaultType vaultType; + + public Builder vaultType(VaultType vaultType) { + this.vaultType = vaultType; + this.__explicitlySet__.add("vaultType"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public Vault build() { + Vault __instance__ = + new Vault( + compartmentId, + cryptoEndpoint, + definedTags, + displayName, + freeformTags, + id, + lifecycleState, + managementEndpoint, + timeCreated, + timeOfDeletion, + vaultType); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(Vault o) { + Builder copiedBuilder = + compartmentId(o.getCompartmentId()) + .cryptoEndpoint(o.getCryptoEndpoint()) + .definedTags(o.getDefinedTags()) + .displayName(o.getDisplayName()) + .freeformTags(o.getFreeformTags()) + .id(o.getId()) + .lifecycleState(o.getLifecycleState()) + .managementEndpoint(o.getManagementEndpoint()) + .timeCreated(o.getTimeCreated()) + .timeOfDeletion(o.getTimeOfDeletion()) + .vaultType(o.getVaultType()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The OCID of the compartment that contains this vault. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + String compartmentId; + + /** + * The service endpoint to perform cryptographic operations against. Cryptographic operations include 'Encrypt,' 'Decrypt,' and 'GenerateDataEncryptionKey' operations. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("cryptoEndpoint") + String cryptoEndpoint; + + /** + * Usage of predefined tag keys. These predefined keys are scoped to namespaces. + * Example: `{\"foo-namespace\": {\"bar-key\": \"foo-value\"}}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("definedTags") + java.util.Map> definedTags; + + /** + * A user-friendly name for the vault. It does not have to be unique, and it is changeable. + * Avoid entering confidential information. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + String displayName; + + /** + * Simple key-value pair that is applied without any predefined name, type, or scope. + * Exists for cross-compatibility only. + * Example: `{\"bar-key\": \"value\"}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") + java.util.Map freeformTags; + + /** + * The OCID of the vault. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("id") + String id; + /** + * The vault's current state. + *

+ * Example: `DELETED` + * + **/ + @lombok.extern.slf4j.Slf4j + public enum LifecycleState { + Creating("CREATING"), + Active("ACTIVE"), + Deleting("DELETING"), + Deleted("DELETED"), + PendingDeletion("PENDING_DELETION"), + SchedulingDeletion("SCHEDULING_DELETION"), + CancellingDeletion("CANCELLING_DELETION"), + + /** + * This value is used if a service returns a value for this enum that is not recognized by this + * version of the SDK. + */ + UnknownEnumValue(null); + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (LifecycleState v : LifecycleState.values()) { + if (v != UnknownEnumValue) { + map.put(v.getValue(), v); + } + } + } + + LifecycleState(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static LifecycleState create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + LOG.warn( + "Received unknown value '{}' for enum 'LifecycleState', returning UnknownEnumValue", + key); + return UnknownEnumValue; + } + }; + /** + * The vault's current state. + *

+ * Example: `DELETED` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("lifecycleState") + LifecycleState lifecycleState; + + /** + * The service endpoint to perform management operations against. Management operations include 'Create,' 'Update,' 'List,' 'Get,' and 'Delete' operations. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("managementEndpoint") + String managementEndpoint; + + /** + * The date and time this vault was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. + *

+ * Example: `2018-04-03T21:10:29.600Z` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + java.util.Date timeCreated; + + /** + * An optional property for the deletion time of the Vault expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. + * Example: `2018-04-03T21:10:29.600Z` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("timeOfDeletion") + java.util.Date timeOfDeletion; + /** + * The type of vault. Each type of vault stores the key with different degrees of isolation and has different options and pricing. + **/ + @lombok.extern.slf4j.Slf4j + public enum VaultType { + VirtualPrivate("VIRTUAL_PRIVATE"), + + /** + * This value is used if a service returns a value for this enum that is not recognized by this + * version of the SDK. + */ + UnknownEnumValue(null); + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (VaultType v : VaultType.values()) { + if (v != UnknownEnumValue) { + map.put(v.getValue(), v); + } + } + } + + VaultType(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static VaultType create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + LOG.warn( + "Received unknown value '{}' for enum 'VaultType', returning UnknownEnumValue", + key); + return UnknownEnumValue; + } + }; + /** + * The type of vault. Each type of vault stores the key with different degrees of isolation and has different options and pricing. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("vaultType") + VaultType vaultType; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/VaultSummary.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/VaultSummary.java new file mode 100644 index 00000000000..b867347d085 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/model/VaultSummary.java @@ -0,0 +1,336 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.model; + +/** + * + *
+ * Note: Objects should always be created or deserialized using the {@link Builder}. This model distinguishes fields + * that are {@code null} because they are unset from fields that are explicitly set to {@code null}. This is done in + * the setter methods of the {@link Builder}, which maintain a set of all explicitly set fields called + * {@link #__explicitlySet__}. The {@link #hashCode()} and {@link #equals(Object)} methods are implemented to take + * {@link #__explicitlySet__} into account. The constructor, on the other hand, does not set {@link #__explicitlySet__} + * (since the constructor cannot distinguish explicit {@code null} from unset {@code null}). + **/ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.AllArgsConstructor(onConstructor = @__({@Deprecated})) +@lombok.Value +@com.fasterxml.jackson.databind.annotation.JsonDeserialize(builder = VaultSummary.Builder.class) +@com.fasterxml.jackson.annotation.JsonFilter(com.oracle.bmc.http.internal.ExplicitlySetFilter.NAME) +public class VaultSummary { + @com.fasterxml.jackson.databind.annotation.JsonPOJOBuilder(withPrefix = "") + @lombok.experimental.Accessors(fluent = true) + public static class Builder { + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + private String compartmentId; + + public Builder compartmentId(String compartmentId) { + this.compartmentId = compartmentId; + this.__explicitlySet__.add("compartmentId"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("cryptoEndpoint") + private String cryptoEndpoint; + + public Builder cryptoEndpoint(String cryptoEndpoint) { + this.cryptoEndpoint = cryptoEndpoint; + this.__explicitlySet__.add("cryptoEndpoint"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("definedTags") + private java.util.Map> definedTags; + + public Builder definedTags( + java.util.Map> definedTags) { + this.definedTags = definedTags; + this.__explicitlySet__.add("definedTags"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + private String displayName; + + public Builder displayName(String displayName) { + this.displayName = displayName; + this.__explicitlySet__.add("displayName"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") + private java.util.Map freeformTags; + + public Builder freeformTags(java.util.Map freeformTags) { + this.freeformTags = freeformTags; + this.__explicitlySet__.add("freeformTags"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("id") + private String id; + + public Builder id(String id) { + this.id = id; + this.__explicitlySet__.add("id"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("lifecycleState") + private LifecycleState lifecycleState; + + public Builder lifecycleState(LifecycleState lifecycleState) { + this.lifecycleState = lifecycleState; + this.__explicitlySet__.add("lifecycleState"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("managementEndpoint") + private String managementEndpoint; + + public Builder managementEndpoint(String managementEndpoint) { + this.managementEndpoint = managementEndpoint; + this.__explicitlySet__.add("managementEndpoint"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + private java.util.Date timeCreated; + + public Builder timeCreated(java.util.Date timeCreated) { + this.timeCreated = timeCreated; + this.__explicitlySet__.add("timeCreated"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonProperty("vaultType") + private VaultType vaultType; + + public Builder vaultType(VaultType vaultType) { + this.vaultType = vaultType; + this.__explicitlySet__.add("vaultType"); + return this; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); + + public VaultSummary build() { + VaultSummary __instance__ = + new VaultSummary( + compartmentId, + cryptoEndpoint, + definedTags, + displayName, + freeformTags, + id, + lifecycleState, + managementEndpoint, + timeCreated, + vaultType); + __instance__.__explicitlySet__.addAll(__explicitlySet__); + return __instance__; + } + + @com.fasterxml.jackson.annotation.JsonIgnore + public Builder copy(VaultSummary o) { + Builder copiedBuilder = + compartmentId(o.getCompartmentId()) + .cryptoEndpoint(o.getCryptoEndpoint()) + .definedTags(o.getDefinedTags()) + .displayName(o.getDisplayName()) + .freeformTags(o.getFreeformTags()) + .id(o.getId()) + .lifecycleState(o.getLifecycleState()) + .managementEndpoint(o.getManagementEndpoint()) + .timeCreated(o.getTimeCreated()) + .vaultType(o.getVaultType()); + + copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); + return copiedBuilder; + } + } + + /** + * Create a new builder. + */ + public static Builder builder() { + return new Builder(); + } + + /** + * The OCID of the compartment that contains this vault. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("compartmentId") + String compartmentId; + + /** + * The service endpoint to perform cryptographic operations against. Cryptographic operations include 'Encrypt,' 'Decrypt,' and 'GenerateDataEncryptionKey' operations. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("cryptoEndpoint") + String cryptoEndpoint; + + /** + * Usage of predefined tag keys. These predefined keys are scoped to namespaces. + * Example: `{\"foo-namespace\": {\"bar-key\": \"foo-value\"}}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("definedTags") + java.util.Map> definedTags; + + /** + * A user-friendly name for a vault. It does not have to be unique, and it is changeable. + * Avoid entering confidential information. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("displayName") + String displayName; + + /** + * Simple key-value pair that is applied without any predefined name, type, or scope. + * Exists for cross-compatibility only. + * Example: `{\"bar-key\": \"value\"}` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("freeformTags") + java.util.Map freeformTags; + + /** + * The OCID of a vault. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("id") + String id; + /** + * A vault's current state. + *

+ * Example: `ACTIVE` + * + **/ + @lombok.extern.slf4j.Slf4j + public enum LifecycleState { + Creating("CREATING"), + Active("ACTIVE"), + Deleting("DELETING"), + Deleted("DELETED"), + PendingDeletion("PENDING_DELETION"), + SchedulingDeletion("SCHEDULING_DELETION"), + CancellingDeletion("CANCELLING_DELETION"), + + /** + * This value is used if a service returns a value for this enum that is not recognized by this + * version of the SDK. + */ + UnknownEnumValue(null); + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (LifecycleState v : LifecycleState.values()) { + if (v != UnknownEnumValue) { + map.put(v.getValue(), v); + } + } + } + + LifecycleState(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static LifecycleState create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + LOG.warn( + "Received unknown value '{}' for enum 'LifecycleState', returning UnknownEnumValue", + key); + return UnknownEnumValue; + } + }; + /** + * A vault's current state. + *

+ * Example: `ACTIVE` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("lifecycleState") + LifecycleState lifecycleState; + + /** + * The service endpoint to perform management operations against. Management operations include 'Create,' 'Update,' 'List,' 'Get,' and 'Delete' operations. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("managementEndpoint") + String managementEndpoint; + + /** + * The date and time a vault was created, expressed in [RFC 3339](https://tools.ietf.org/html/rfc3339) timestamp format. + *

+ * Example: `2018-04-03T21:10:29.600Z` + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("timeCreated") + java.util.Date timeCreated; + /** + * The type of vault. Each type of vault stores keys with different degrees of isolation and has different options and pricing. + **/ + @lombok.extern.slf4j.Slf4j + public enum VaultType { + VirtualPrivate("VIRTUAL_PRIVATE"), + + /** + * This value is used if a service returns a value for this enum that is not recognized by this + * version of the SDK. + */ + UnknownEnumValue(null); + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (VaultType v : VaultType.values()) { + if (v != UnknownEnumValue) { + map.put(v.getValue(), v); + } + } + } + + VaultType(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static VaultType create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + LOG.warn( + "Received unknown value '{}' for enum 'VaultType', returning UnknownEnumValue", + key); + return UnknownEnumValue; + } + }; + /** + * The type of vault. Each type of vault stores keys with different degrees of isolation and has different options and pricing. + **/ + @com.fasterxml.jackson.annotation.JsonProperty("vaultType") + VaultType vaultType; + + @com.fasterxml.jackson.annotation.JsonIgnore + private final java.util.Set __explicitlySet__ = new java.util.HashSet(); +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CancelVaultDeletionRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CancelVaultDeletionRequest.java new file mode 100644 index 00000000000..72d3c2984f9 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CancelVaultDeletionRequest.java @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class CancelVaultDeletionRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the vault. + */ + private String vaultId; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a + * resource, set the `if-match` parameter to the value of the etag from a + * previous GET or POST response for that resource. The resource will be + * updated or deleted only if the etag you provide matches the resource's + * current etag value. + * + */ + private String ifMatch; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * A token that uniquely identifies a request so it can be retried in case + * of a timeout or server error without risk of executing that same action + * again. Retry tokens expire after 24 hours, but can be invalidated + * before then due to conflicting operations (e.g., if a resource has been + * deleted and purged from the system, then a retry of the original + * creation request may be rejected). + * + */ + private String opcRetryToken; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(CancelVaultDeletionRequest o) { + vaultId(o.getVaultId()); + ifMatch(o.getIfMatch()); + opcRequestId(o.getOpcRequestId()); + opcRetryToken(o.getOpcRetryToken()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of CancelVaultDeletionRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of CancelVaultDeletionRequest + */ + public CancelVaultDeletionRequest build() { + CancelVaultDeletionRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CreateKeyRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CreateKeyRequest.java new file mode 100644 index 00000000000..6c1a17450aa --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CreateKeyRequest.java @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class CreateKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * CreateKeyDetails + */ + private CreateKeyDetails createKeyDetails; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * A token that uniquely identifies a request so it can be retried in case + * of a timeout or server error without risk of executing that same action + * again. Retry tokens expire after 24 hours, but can be invalidated + * before then due to conflicting operations (e.g., if a resource has been + * deleted and purged from the system, then a retry of the original + * creation request may be rejected). + * + */ + private String opcRetryToken; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(CreateKeyRequest o) { + createKeyDetails(o.getCreateKeyDetails()); + opcRequestId(o.getOpcRequestId()); + opcRetryToken(o.getOpcRetryToken()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of CreateKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of CreateKeyRequest + */ + public CreateKeyRequest build() { + CreateKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CreateKeyVersionRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CreateKeyVersionRequest.java new file mode 100644 index 00000000000..6f9176cda76 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CreateKeyVersionRequest.java @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class CreateKeyVersionRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the key. + */ + private String keyId; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * A token that uniquely identifies a request so it can be retried in case + * of a timeout or server error without risk of executing that same action + * again. Retry tokens expire after 24 hours, but can be invalidated + * before then due to conflicting operations (e.g., if a resource has been + * deleted and purged from the system, then a retry of the original + * creation request may be rejected). + * + */ + private String opcRetryToken; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(CreateKeyVersionRequest o) { + keyId(o.getKeyId()); + opcRequestId(o.getOpcRequestId()); + opcRetryToken(o.getOpcRetryToken()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of CreateKeyVersionRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of CreateKeyVersionRequest + */ + public CreateKeyVersionRequest build() { + CreateKeyVersionRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CreateVaultRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CreateVaultRequest.java new file mode 100644 index 00000000000..9f7e9b164b0 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/CreateVaultRequest.java @@ -0,0 +1,81 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class CreateVaultRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * CreateVaultDetails + */ + private CreateVaultDetails createVaultDetails; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * A token that uniquely identifies a request so it can be retried in case + * of a timeout or server error without risk of executing that same action + * again. Retry tokens expire after 24 hours, but can be invalidated + * before then due to conflicting operations (e.g., if a resource has been + * deleted and purged from the system, then a retry of the original + * creation request may be rejected). + * + */ + private String opcRetryToken; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(CreateVaultRequest o) { + createVaultDetails(o.getCreateVaultDetails()); + opcRequestId(o.getOpcRequestId()); + opcRetryToken(o.getOpcRetryToken()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of CreateVaultRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of CreateVaultRequest + */ + public CreateVaultRequest build() { + CreateVaultRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/DecryptRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/DecryptRequest.java new file mode 100644 index 00000000000..0849c502299 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/DecryptRequest.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class DecryptRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * DecryptDataDetails + */ + private DecryptDataDetails decryptDataDetails; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(DecryptRequest o) { + decryptDataDetails(o.getDecryptDataDetails()); + opcRequestId(o.getOpcRequestId()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of DecryptRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of DecryptRequest + */ + public DecryptRequest build() { + DecryptRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/DisableKeyRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/DisableKeyRequest.java new file mode 100644 index 00000000000..342231fc2d9 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/DisableKeyRequest.java @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class DisableKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the key. + */ + private String keyId; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a + * resource, set the `if-match` parameter to the value of the etag from a + * previous GET or POST response for that resource. The resource will be + * updated or deleted only if the etag you provide matches the resource's + * current etag value. + * + */ + private String ifMatch; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * A token that uniquely identifies a request so it can be retried in case + * of a timeout or server error without risk of executing that same action + * again. Retry tokens expire after 24 hours, but can be invalidated + * before then due to conflicting operations (e.g., if a resource has been + * deleted and purged from the system, then a retry of the original + * creation request may be rejected). + * + */ + private String opcRetryToken; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(DisableKeyRequest o) { + keyId(o.getKeyId()); + ifMatch(o.getIfMatch()); + opcRequestId(o.getOpcRequestId()); + opcRetryToken(o.getOpcRetryToken()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of DisableKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of DisableKeyRequest + */ + public DisableKeyRequest build() { + DisableKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/EnableKeyRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/EnableKeyRequest.java new file mode 100644 index 00000000000..9256740188f --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/EnableKeyRequest.java @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class EnableKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the key. + */ + private String keyId; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a + * resource, set the `if-match` parameter to the value of the etag from a + * previous GET or POST response for that resource. The resource will be + * updated or deleted only if the etag you provide matches the resource's + * current etag value. + * + */ + private String ifMatch; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * A token that uniquely identifies a request so it can be retried in case + * of a timeout or server error without risk of executing that same action + * again. Retry tokens expire after 24 hours, but can be invalidated + * before then due to conflicting operations (e.g., if a resource has been + * deleted and purged from the system, then a retry of the original + * creation request may be rejected). + * + */ + private String opcRetryToken; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(EnableKeyRequest o) { + keyId(o.getKeyId()); + ifMatch(o.getIfMatch()); + opcRequestId(o.getOpcRequestId()); + opcRetryToken(o.getOpcRetryToken()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of EnableKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of EnableKeyRequest + */ + public EnableKeyRequest build() { + EnableKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/EncryptRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/EncryptRequest.java new file mode 100644 index 00000000000..74dfaa16acc --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/EncryptRequest.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class EncryptRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * EncryptDataDetails + */ + private EncryptDataDetails encryptDataDetails; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(EncryptRequest o) { + encryptDataDetails(o.getEncryptDataDetails()); + opcRequestId(o.getOpcRequestId()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of EncryptRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of EncryptRequest + */ + public EncryptRequest build() { + EncryptRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GenerateDataEncryptionKeyRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GenerateDataEncryptionKeyRequest.java new file mode 100644 index 00000000000..530e24f0690 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GenerateDataEncryptionKeyRequest.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class GenerateDataEncryptionKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * GenerateKeyDetails + */ + private GenerateKeyDetails generateKeyDetails; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GenerateDataEncryptionKeyRequest o) { + generateKeyDetails(o.getGenerateKeyDetails()); + opcRequestId(o.getOpcRequestId()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of GenerateDataEncryptionKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of GenerateDataEncryptionKeyRequest + */ + public GenerateDataEncryptionKeyRequest build() { + GenerateDataEncryptionKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GetKeyRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GetKeyRequest.java new file mode 100644 index 00000000000..9a7dd22c8da --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GetKeyRequest.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class GetKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the key. + */ + private String keyId; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetKeyRequest o) { + keyId(o.getKeyId()); + opcRequestId(o.getOpcRequestId()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of GetKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of GetKeyRequest + */ + public GetKeyRequest build() { + GetKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GetKeyVersionRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GetKeyVersionRequest.java new file mode 100644 index 00000000000..119a28bfcd0 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GetKeyVersionRequest.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class GetKeyVersionRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the key. + */ + private String keyId; + + /** + * The OCID of the key version. + */ + private String keyVersionId; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetKeyVersionRequest o) { + keyId(o.getKeyId()); + keyVersionId(o.getKeyVersionId()); + opcRequestId(o.getOpcRequestId()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of GetKeyVersionRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of GetKeyVersionRequest + */ + public GetKeyVersionRequest build() { + GetKeyVersionRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GetVaultRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GetVaultRequest.java new file mode 100644 index 00000000000..df87236077a --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/GetVaultRequest.java @@ -0,0 +1,69 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class GetVaultRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the vault. + */ + private String vaultId; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetVaultRequest o) { + vaultId(o.getVaultId()); + opcRequestId(o.getOpcRequestId()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of GetVaultRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of GetVaultRequest + */ + public GetVaultRequest build() { + GetVaultRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ListKeyVersionsRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ListKeyVersionsRequest.java new file mode 100644 index 00000000000..050b4d181d9 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ListKeyVersionsRequest.java @@ -0,0 +1,176 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class ListKeyVersionsRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the key. + */ + private String keyId; + + /** + * The maximum number of items to return in a paginated \"List\" call. + * + */ + private Integer limit; + + /** + * The value of the `opc-next-page` response header + * from the previous \"List\" call. + * + */ + private String page; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * The field to sort by. You can specify only one sort order. The default + * order for TIMECREATED is descending. The default order for DISPLAYNAME + * is ascending. + * + */ + private SortBy sortBy; + + /** + * The field to sort by. You can specify only one sort order. The default + * order for TIMECREATED is descending. The default order for DISPLAYNAME + * is ascending. + * + **/ + public enum SortBy { + Timecreated("TIMECREATED"), + Displayname("DISPLAYNAME"), + ; + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (SortBy v : SortBy.values()) { + map.put(v.getValue(), v); + } + } + + SortBy(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static SortBy create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + throw new RuntimeException("Invalid SortBy: " + key); + } + }; + + /** + * The sort order to use, either ascending (`ASC`) or descending (`DESC`). + * + */ + private SortOrder sortOrder; + + /** + * The sort order to use, either ascending (`ASC`) or descending (`DESC`). + * + **/ + public enum SortOrder { + Asc("ASC"), + Desc("DESC"), + ; + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (SortOrder v : SortOrder.values()) { + map.put(v.getValue(), v); + } + } + + SortOrder(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static SortOrder create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + throw new RuntimeException("Invalid SortOrder: " + key); + } + }; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(ListKeyVersionsRequest o) { + keyId(o.getKeyId()); + limit(o.getLimit()); + page(o.getPage()); + opcRequestId(o.getOpcRequestId()); + sortBy(o.getSortBy()); + sortOrder(o.getSortOrder()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of ListKeyVersionsRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of ListKeyVersionsRequest + */ + public ListKeyVersionsRequest build() { + ListKeyVersionsRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ListKeysRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ListKeysRequest.java new file mode 100644 index 00000000000..cd394a3cfe5 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ListKeysRequest.java @@ -0,0 +1,176 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class ListKeysRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the compartment. + */ + private String compartmentId; + + /** + * The maximum number of items to return in a paginated \"List\" call. + * + */ + private Integer limit; + + /** + * The value of the `opc-next-page` response header + * from the previous \"List\" call. + * + */ + private String page; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * The field to sort by. You can specify only one sort order. The default + * order for TIMECREATED is descending. The default order for DISPLAYNAME + * is ascending. + * + */ + private SortBy sortBy; + + /** + * The field to sort by. You can specify only one sort order. The default + * order for TIMECREATED is descending. The default order for DISPLAYNAME + * is ascending. + * + **/ + public enum SortBy { + Timecreated("TIMECREATED"), + Displayname("DISPLAYNAME"), + ; + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (SortBy v : SortBy.values()) { + map.put(v.getValue(), v); + } + } + + SortBy(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static SortBy create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + throw new RuntimeException("Invalid SortBy: " + key); + } + }; + + /** + * The sort order to use, either ascending (`ASC`) or descending (`DESC`). + * + */ + private SortOrder sortOrder; + + /** + * The sort order to use, either ascending (`ASC`) or descending (`DESC`). + * + **/ + public enum SortOrder { + Asc("ASC"), + Desc("DESC"), + ; + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (SortOrder v : SortOrder.values()) { + map.put(v.getValue(), v); + } + } + + SortOrder(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static SortOrder create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + throw new RuntimeException("Invalid SortOrder: " + key); + } + }; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(ListKeysRequest o) { + compartmentId(o.getCompartmentId()); + limit(o.getLimit()); + page(o.getPage()); + opcRequestId(o.getOpcRequestId()); + sortBy(o.getSortBy()); + sortOrder(o.getSortOrder()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of ListKeysRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of ListKeysRequest + */ + public ListKeysRequest build() { + ListKeysRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ListVaultsRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ListVaultsRequest.java new file mode 100644 index 00000000000..c58c4889155 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ListVaultsRequest.java @@ -0,0 +1,176 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class ListVaultsRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the compartment. + */ + private String compartmentId; + + /** + * The maximum number of items to return in a paginated \"List\" call. + * + */ + private Integer limit; + + /** + * The value of the `opc-next-page` response header + * from the previous \"List\" call. + * + */ + private String page; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * The field to sort by. You can specify only one sort order. The default + * order for TIMECREATED is descending. The default order for DISPLAYNAME + * is ascending. + * + */ + private SortBy sortBy; + + /** + * The field to sort by. You can specify only one sort order. The default + * order for TIMECREATED is descending. The default order for DISPLAYNAME + * is ascending. + * + **/ + public enum SortBy { + Timecreated("TIMECREATED"), + Displayname("DISPLAYNAME"), + ; + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (SortBy v : SortBy.values()) { + map.put(v.getValue(), v); + } + } + + SortBy(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static SortBy create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + throw new RuntimeException("Invalid SortBy: " + key); + } + }; + + /** + * The sort order to use, either ascending (`ASC`) or descending (`DESC`). + * + */ + private SortOrder sortOrder; + + /** + * The sort order to use, either ascending (`ASC`) or descending (`DESC`). + * + **/ + public enum SortOrder { + Asc("ASC"), + Desc("DESC"), + ; + + private final String value; + private static java.util.Map map; + + static { + map = new java.util.HashMap<>(); + for (SortOrder v : SortOrder.values()) { + map.put(v.getValue(), v); + } + } + + SortOrder(String value) { + this.value = value; + } + + @com.fasterxml.jackson.annotation.JsonValue + public String getValue() { + return value; + } + + @com.fasterxml.jackson.annotation.JsonCreator + public static SortOrder create(String key) { + if (map.containsKey(key)) { + return map.get(key); + } + throw new RuntimeException("Invalid SortOrder: " + key); + } + }; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(ListVaultsRequest o) { + compartmentId(o.getCompartmentId()); + limit(o.getLimit()); + page(o.getPage()); + opcRequestId(o.getOpcRequestId()); + sortBy(o.getSortBy()); + sortOrder(o.getSortOrder()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of ListVaultsRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of ListVaultsRequest + */ + public ListVaultsRequest build() { + ListVaultsRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ScheduleVaultDeletionRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ScheduleVaultDeletionRequest.java new file mode 100644 index 00000000000..ffcc276cfb7 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/ScheduleVaultDeletionRequest.java @@ -0,0 +1,98 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class ScheduleVaultDeletionRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the vault. + */ + private String vaultId; + + /** + * ScheduleVaultDeletionDetails + */ + private ScheduleVaultDeletionDetails scheduleVaultDeletionDetails; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a + * resource, set the `if-match` parameter to the value of the etag from a + * previous GET or POST response for that resource. The resource will be + * updated or deleted only if the etag you provide matches the resource's + * current etag value. + * + */ + private String ifMatch; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + /** + * A token that uniquely identifies a request so it can be retried in case + * of a timeout or server error without risk of executing that same action + * again. Retry tokens expire after 24 hours, but can be invalidated + * before then due to conflicting operations (e.g., if a resource has been + * deleted and purged from the system, then a retry of the original + * creation request may be rejected). + * + */ + private String opcRetryToken; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(ScheduleVaultDeletionRequest o) { + vaultId(o.getVaultId()); + scheduleVaultDeletionDetails(o.getScheduleVaultDeletionDetails()); + ifMatch(o.getIfMatch()); + opcRequestId(o.getOpcRequestId()); + opcRetryToken(o.getOpcRetryToken()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of ScheduleVaultDeletionRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of ScheduleVaultDeletionRequest + */ + public ScheduleVaultDeletionRequest build() { + ScheduleVaultDeletionRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/UpdateKeyRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/UpdateKeyRequest.java new file mode 100644 index 00000000000..adecec10fc4 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/UpdateKeyRequest.java @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class UpdateKeyRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the key. + */ + private String keyId; + + /** + * UpdateKeyDetails + */ + private UpdateKeyDetails updateKeyDetails; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a + * resource, set the `if-match` parameter to the value of the etag from a + * previous GET or POST response for that resource. The resource will be + * updated or deleted only if the etag you provide matches the resource's + * current etag value. + * + */ + private String ifMatch; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(UpdateKeyRequest o) { + keyId(o.getKeyId()); + updateKeyDetails(o.getUpdateKeyDetails()); + ifMatch(o.getIfMatch()); + opcRequestId(o.getOpcRequestId()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of UpdateKeyRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of UpdateKeyRequest + */ + public UpdateKeyRequest build() { + UpdateKeyRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/UpdateVaultRequest.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/UpdateVaultRequest.java new file mode 100644 index 00000000000..0879f3b77be --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/requests/UpdateVaultRequest.java @@ -0,0 +1,86 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.requests; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder", buildMethodName = "buildWithoutInvocationCallback") +@lombok.Getter +public class UpdateVaultRequest extends com.oracle.bmc.requests.BmcRequest { + + /** + * The OCID of the vault. + */ + private String vaultId; + + /** + * UpdateVaultDetails + */ + private UpdateVaultDetails updateVaultDetails; + + /** + * For optimistic concurrency control. In the PUT or DELETE call for a + * resource, set the `if-match` parameter to the value of the etag from a + * previous GET or POST response for that resource. The resource will be + * updated or deleted only if the etag you provide matches the resource's + * current etag value. + * + */ + private String ifMatch; + + /** + * Unique identifier for the request. If provided, the returned request ID + * will include this value. Otherwise, a random request ID will be + * generated by the service. + * + */ + private String opcRequestId; + + public static class Builder { + private com.oracle.bmc.util.internal.Consumer + invocationCallback = null; + + /** + * Set the invocation callback for the request to be built. + * @param invocationCallback the invocation callback to be set for the request + * @return this builder instance + */ + public Builder invocationCallback( + com.oracle.bmc.util.internal.Consumer + invocationCallback) { + this.invocationCallback = invocationCallback; + return this; + } + + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(UpdateVaultRequest o) { + vaultId(o.getVaultId()); + updateVaultDetails(o.getUpdateVaultDetails()); + ifMatch(o.getIfMatch()); + opcRequestId(o.getOpcRequestId()); + invocationCallback(o.getInvocationCallback()); + return this; + } + + /** + * Build the instance of UpdateVaultRequest as configured by this builder + * + * Note that this method takes calls to {@link Builder#invocationCallback(com.oracle.bmc.util.internal.Consumer)} into account, + * while the method {@link Builder#buildWithoutInvocationCallback} does not. + * + * This is the preferred method to build an instance. + * + * @return instance of UpdateVaultRequest + */ + public UpdateVaultRequest build() { + UpdateVaultRequest request = buildWithoutInvocationCallback(); + request.setInvocationCallback(invocationCallback); + return request; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CancelVaultDeletionResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CancelVaultDeletionResponse.java new file mode 100644 index 00000000000..16927ae6530 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CancelVaultDeletionResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class CancelVaultDeletionResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Vault instance. + */ + private Vault vault; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(CancelVaultDeletionResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + vault(o.getVault()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CreateKeyResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CreateKeyResponse.java new file mode 100644 index 00000000000..5cb5e7f9791 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CreateKeyResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class CreateKeyResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Key instance. + */ + private Key key; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(CreateKeyResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + key(o.getKey()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CreateKeyVersionResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CreateKeyVersionResponse.java new file mode 100644 index 00000000000..f6e5b81e446 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CreateKeyVersionResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class CreateKeyVersionResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned KeyVersion instance. + */ + private KeyVersion keyVersion; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(CreateKeyVersionResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + keyVersion(o.getKeyVersion()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CreateVaultResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CreateVaultResponse.java new file mode 100644 index 00000000000..dcc962cc1af --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/CreateVaultResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class CreateVaultResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Vault instance. + */ + private Vault vault; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(CreateVaultResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + vault(o.getVault()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/DecryptResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/DecryptResponse.java new file mode 100644 index 00000000000..f75bbc4c23c --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/DecryptResponse.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class DecryptResponse { + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned DecryptedData instance. + */ + private DecryptedData decryptedData; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(DecryptResponse o) { + opcRequestId(o.getOpcRequestId()); + decryptedData(o.getDecryptedData()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/DisableKeyResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/DisableKeyResponse.java new file mode 100644 index 00000000000..27ec0b1ddb3 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/DisableKeyResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class DisableKeyResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Key instance. + */ + private Key key; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(DisableKeyResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + key(o.getKey()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/EnableKeyResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/EnableKeyResponse.java new file mode 100644 index 00000000000..fb06543ae30 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/EnableKeyResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class EnableKeyResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Key instance. + */ + private Key key; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(EnableKeyResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + key(o.getKey()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/EncryptResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/EncryptResponse.java new file mode 100644 index 00000000000..a0a5ddf2ee7 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/EncryptResponse.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class EncryptResponse { + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned EncryptedData instance. + */ + private EncryptedData encryptedData; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(EncryptResponse o) { + opcRequestId(o.getOpcRequestId()); + encryptedData(o.getEncryptedData()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GenerateDataEncryptionKeyResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GenerateDataEncryptionKeyResponse.java new file mode 100644 index 00000000000..9a114eab0b5 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GenerateDataEncryptionKeyResponse.java @@ -0,0 +1,37 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class GenerateDataEncryptionKeyResponse { + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned GeneratedKey instance. + */ + private GeneratedKey generatedKey; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GenerateDataEncryptionKeyResponse o) { + opcRequestId(o.getOpcRequestId()); + generatedKey(o.getGeneratedKey()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GetKeyResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GetKeyResponse.java new file mode 100644 index 00000000000..2534d787a45 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GetKeyResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class GetKeyResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Key instance. + */ + private Key key; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetKeyResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + key(o.getKey()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GetKeyVersionResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GetKeyVersionResponse.java new file mode 100644 index 00000000000..5c55ea8404b --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GetKeyVersionResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class GetKeyVersionResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned KeyVersion instance. + */ + private KeyVersion keyVersion; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetKeyVersionResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + keyVersion(o.getKeyVersion()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GetVaultResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GetVaultResponse.java new file mode 100644 index 00000000000..3113afce595 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/GetVaultResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class GetVaultResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Vault instance. + */ + private Vault vault; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(GetVaultResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + vault(o.getVault()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ListKeyVersionsResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ListKeyVersionsResponse.java new file mode 100644 index 00000000000..de7012f9e1b --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ListKeyVersionsResponse.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class ListKeyVersionsResponse { + + /** + * For pagination of a list of items. When paging through a list, if this header appears in the response, + * then there are additional items still to get. Include this value as the `page` parameter for the + * subsequent GET request. For information about pagination, see + * [List Pagination](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/usingapi.htm#List_Pagination). + * + */ + private String opcNextPage; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * A list of KeyVersionSummary instances. + */ + private java.util.List items; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(ListKeyVersionsResponse o) { + opcNextPage(o.getOpcNextPage()); + opcRequestId(o.getOpcRequestId()); + items(o.getItems()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ListKeysResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ListKeysResponse.java new file mode 100644 index 00000000000..6752628f655 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ListKeysResponse.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class ListKeysResponse { + + /** + * For pagination of a list of items. When paging through a list, if this header appears in the response, + * then there are additional items still to get. Include this value as the `page` parameter for the + * subsequent GET request. For information about pagination, see + * [List Pagination](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/usingapi.htm#List_Pagination). + * + */ + private String opcNextPage; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * A list of KeySummary instances. + */ + private java.util.List items; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(ListKeysResponse o) { + opcNextPage(o.getOpcNextPage()); + opcRequestId(o.getOpcRequestId()); + items(o.getItems()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ListVaultsResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ListVaultsResponse.java new file mode 100644 index 00000000000..1820733e8b2 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ListVaultsResponse.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class ListVaultsResponse { + + /** + * For pagination of a list of items. When paging through a list, if this header appears in the response, + * then there are additional items still to get. Include this value as the `page` parameter for the + * subsequent GET request. For information about pagination, see + * [List Pagination](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/usingapi.htm#List_Pagination). + * + */ + private String opcNextPage; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * A list of VaultSummary instances. + */ + private java.util.List items; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(ListVaultsResponse o) { + opcNextPage(o.getOpcNextPage()); + opcRequestId(o.getOpcRequestId()); + items(o.getItems()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ScheduleVaultDeletionResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ScheduleVaultDeletionResponse.java new file mode 100644 index 00000000000..eb4dc4eba3f --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/ScheduleVaultDeletionResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class ScheduleVaultDeletionResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Vault instance. + */ + private Vault vault; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(ScheduleVaultDeletionResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + vault(o.getVault()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/UpdateKeyResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/UpdateKeyResponse.java new file mode 100644 index 00000000000..d47b5da70ed --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/UpdateKeyResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class UpdateKeyResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Key instance. + */ + private Key key; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(UpdateKeyResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + key(o.getKey()); + + return this; + } + } +} diff --git a/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/UpdateVaultResponse.java b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/UpdateVaultResponse.java new file mode 100644 index 00000000000..217b8350902 --- /dev/null +++ b/bmc-keymanagement/src/main/java/com/oracle/bmc/keymanagement/responses/UpdateVaultResponse.java @@ -0,0 +1,43 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.keymanagement.responses; + +import com.oracle.bmc.keymanagement.model.*; + +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 20180608") +@lombok.Builder(builderClassName = "Builder") +@lombok.Getter +public class UpdateVaultResponse { + + /** + * For optimistic concurrency control. See `if-match`. + */ + private String etag; + + /** + * Unique Oracle-assigned identifier for the request. If you need to contact Oracle about + * a particular request, please provide the request ID. + * + */ + private String opcRequestId; + + /** + * The returned Vault instance. + */ + private Vault vault; + + public static class Builder { + /** + * Copy method to populate the builder with values from the given instance. + * @return this builder instance + */ + public Builder copy(UpdateVaultResponse o) { + etag(o.getEtag()); + opcRequestId(o.getOpcRequestId()); + vault(o.getVault()); + + return this; + } + } +} diff --git a/bmc-loadbalancer/pom.xml b/bmc-loadbalancer/pom.xml index e0050985861..ac899f6ad27 100644 --- a/bmc-loadbalancer/pom.xml +++ b/bmc-loadbalancer/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-loadbalancer/src/main/java/com/oracle/bmc/loadbalancer/LoadBalancerAsyncClient.java b/bmc-loadbalancer/src/main/java/com/oracle/bmc/loadbalancer/LoadBalancerAsyncClient.java index d50601d7359..dcd24999d05 100644 --- a/bmc-loadbalancer/src/main/java/com/oracle/bmc/loadbalancer/LoadBalancerAsyncClient.java +++ b/bmc-loadbalancer/src/main/java/com/oracle/bmc/loadbalancer/LoadBalancerAsyncClient.java @@ -15,7 +15,10 @@ public class LoadBalancerAsyncClient implements LoadBalancerAsync { * Service instance for LoadBalancer. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("LOADBALANCER", "iaas"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("LOADBALANCER") + .serviceEndpointPrefix("iaas") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-loadbalancer/src/main/java/com/oracle/bmc/loadbalancer/LoadBalancerClient.java b/bmc-loadbalancer/src/main/java/com/oracle/bmc/loadbalancer/LoadBalancerClient.java index f999391ae58..68adff5f287 100644 --- a/bmc-loadbalancer/src/main/java/com/oracle/bmc/loadbalancer/LoadBalancerClient.java +++ b/bmc-loadbalancer/src/main/java/com/oracle/bmc/loadbalancer/LoadBalancerClient.java @@ -15,7 +15,10 @@ public class LoadBalancerClient implements LoadBalancer { * Service instance for LoadBalancer. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("LOADBALANCER", "iaas"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("LOADBALANCER") + .serviceEndpointPrefix("iaas") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-objectstorage/bmc-objectstorage-combined/pom.xml b/bmc-objectstorage/bmc-objectstorage-combined/pom.xml new file mode 100644 index 00000000000..bba5a1cbd1f --- /dev/null +++ b/bmc-objectstorage/bmc-objectstorage-combined/pom.xml @@ -0,0 +1,30 @@ + + 4.0.0 + + + com.oracle.oci.sdk + oci-java-sdk-objectstorage-parent + 1.2.47 + ../pom.xml + + + oci-java-sdk-objectstorage + Oracle Cloud Infrastructure SDK - Object Storage + This project contains add-on modules for Oracle Cloud Infrastructure + https://docs.us-phoenix-1.oraclecloud.com/Content/API/SDKDocs/javasdk.htm + + + + com.oracle.oci.sdk + oci-java-sdk-objectstorage-generated + 1.2.47 + + + com.oracle.oci.sdk + oci-java-sdk-objectstorage-extensions + 1.2.47 + + + + diff --git a/bmc-objectstorage/bmc-objectstorage-combined/src/main/java/.empty b/bmc-objectstorage/bmc-objectstorage-combined/src/main/java/.empty new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bmc-objectstorage/bmc-objectstorage-combined/src/test/java/.empty b/bmc-objectstorage/bmc-objectstorage-combined/src/test/java/.empty new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bmc-objectstorage/bmc-objectstorage-extensions/pom.xml b/bmc-objectstorage/bmc-objectstorage-extensions/pom.xml index 110b7bf4f12..7e470755557 100644 --- a/bmc-objectstorage/bmc-objectstorage-extensions/pom.xml +++ b/bmc-objectstorage/bmc-objectstorage-extensions/pom.xml @@ -4,9 +4,9 @@ com.oracle.oci.sdk - oci-java-sdk - 1.2.46 - ../../pom.xml + oci-java-sdk-objectstorage-parent + 1.2.47 + ../pom.xml oci-java-sdk-objectstorage-extensions @@ -18,12 +18,12 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 com.oracle.oci.sdk oci-java-sdk-objectstorage-generated - 1.2.46 + 1.2.47 diff --git a/bmc-objectstorage/bmc-objectstorage-generated/pom.xml b/bmc-objectstorage/bmc-objectstorage-generated/pom.xml index 1d7fa0a7b64..699b51be957 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/pom.xml +++ b/bmc-objectstorage/bmc-objectstorage-generated/pom.xml @@ -4,9 +4,9 @@ com.oracle.oci.sdk - oci-java-sdk - 1.2.46 - ../../pom.xml + oci-java-sdk-objectstorage-parent + 1.2.47 + ../pom.xml oci-java-sdk-objectstorage-generated @@ -18,7 +18,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorage.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorage.java index 8ebca770aee..13be4b6b069 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorage.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorage.java @@ -55,7 +55,8 @@ public interface ObjectStorage extends AutoCloseable { CommitMultipartUploadResponse commitMultipartUpload(CommitMultipartUploadRequest request); /** - * Creates a bucket in the given namespace with a bucket name and optional user-defined metadata. + * Creates a bucket in the given namespace with a bucket name and optional user-defined metadata. Avoid entering confidential + * information in bucket names. * * @param request The request object containing the details to send * @return A response object containing details about the completed operation @@ -233,7 +234,7 @@ ListPreauthenticatedRequestsResponse listPreauthenticatedRequests( ListPreauthenticatedRequestsRequest request); /** - * Creates a new object or overwrites an existing one. + * Creates a new object or overwrites an existing one. See [Special Instructions for Object Storage PUT](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/signingrequests.htm#ObjectStoragePut) for request signature requirements. * * @param request The request object containing the details to send * @return A response object containing details about the completed operation @@ -282,7 +283,7 @@ ListPreauthenticatedRequestsResponse listPreauthenticatedRequests( UpdateNamespaceMetadataResponse updateNamespaceMetadata(UpdateNamespaceMetadataRequest request); /** - * Uploads a single part of a multipart upload. + * Uploads a single part of a multipart upload. See [Special Instructions for Object Storage PUT](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/signingrequests.htm#ObjectStoragePut) for request signature requirements. * * @param request The request object containing the details to send * @return A response object containing details about the completed operation diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageAsync.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageAsync.java index 7072cf8b7c5..9f1883d1180 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageAsync.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageAsync.java @@ -71,7 +71,8 @@ java.util.concurrent.Future commitMultipartUpload handler); /** - * Creates a bucket in the given namespace with a bucket name and optional user-defined metadata. + * Creates a bucket in the given namespace with a bucket name and optional user-defined metadata. Avoid entering confidential + * information in bucket names. * * * @param request The request object containing the details to send @@ -377,7 +378,7 @@ java.util.concurrent.Future listPreauthent handler); /** - * Creates a new object or overwrites an existing one. + * Creates a new object or overwrites an existing one. See [Special Instructions for Object Storage PUT](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/signingrequests.htm#ObjectStoragePut) for request signature requirements. * * * @param request The request object containing the details to send @@ -461,7 +462,7 @@ java.util.concurrent.Future updateNamespaceMeta handler); /** - * Uploads a single part of a multipart upload. + * Uploads a single part of a multipart upload. See [Special Instructions for Object Storage PUT](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/signingrequests.htm#ObjectStoragePut) for request signature requirements. * * * @param request The request object containing the details to send diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageAsyncClient.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageAsyncClient.java index 84593052155..65c4bbfee09 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageAsyncClient.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageAsyncClient.java @@ -15,7 +15,10 @@ public class ObjectStorageAsyncClient implements ObjectStorageAsync { * Service instance for ObjectStorage. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("OBJECTSTORAGE", "objectstorage"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("OBJECTSTORAGE") + .serviceEndpointPrefix("objectstorage") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageClient.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageClient.java index b4865a1906d..97c70fb077d 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageClient.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/ObjectStorageClient.java @@ -15,7 +15,10 @@ public class ObjectStorageClient implements ObjectStorage { * Service instance for ObjectStorage. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("OBJECTSTORAGE", "objectstorage"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("OBJECTSTORAGE") + .serviceEndpointPrefix("objectstorage") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/Bucket.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/Bucket.java index 451d2e487a2..7304c9ba7b0 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/Bucket.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/Bucket.java @@ -129,6 +129,15 @@ public Builder definedTags( return this; } + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); @@ -145,7 +154,8 @@ public Bucket build() { publicAccessType, storageTier, freeformTags, - definedTags); + definedTags, + kmsKeyId); __instance__.__explicitlySet__.addAll(__explicitlySet__); return __instance__; } @@ -163,7 +173,8 @@ public Builder copy(Bucket o) { .publicAccessType(o.getPublicAccessType()) .storageTier(o.getStorageTier()) .freeformTags(o.getFreeformTags()) - .definedTags(o.getDefinedTags()); + .definedTags(o.getDefinedTags()) + .kmsKeyId(o.getKmsKeyId()); copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); return copiedBuilder; @@ -360,6 +371,12 @@ public static StorageTier create(String key) { @com.fasterxml.jackson.annotation.JsonProperty("definedTags") java.util.Map> definedTags; + /** + * The OCID of a KMS key id used to call KMS to generate data key, decrypt the encrypted data key + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); } diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/CreateBucketDetails.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/CreateBucketDetails.java index 40c44fe0c81..7868225bcbd 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/CreateBucketDetails.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/CreateBucketDetails.java @@ -91,6 +91,15 @@ public Builder definedTags( return this; } + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); @@ -103,7 +112,8 @@ public CreateBucketDetails build() { publicAccessType, storageTier, freeformTags, - definedTags); + definedTags, + kmsKeyId); __instance__.__explicitlySet__.addAll(__explicitlySet__); return __instance__; } @@ -117,7 +127,8 @@ public Builder copy(CreateBucketDetails o) { .publicAccessType(o.getPublicAccessType()) .storageTier(o.getStorageTier()) .freeformTags(o.getFreeformTags()) - .definedTags(o.getDefinedTags()); + .definedTags(o.getDefinedTags()) + .kmsKeyId(o.getKmsKeyId()); copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); return copiedBuilder; @@ -269,6 +280,12 @@ public static StorageTier create(String key) { @com.fasterxml.jackson.annotation.JsonProperty("definedTags") java.util.Map> definedTags; + /** + * The OCID of a KMS key id used to call KMS to generate data key, decrypt the encrypted data key + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); } diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/MultipartUpload.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/MultipartUpload.java index 886174243b6..2eff2495922 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/MultipartUpload.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/MultipartUpload.java @@ -8,7 +8,7 @@ * objects that are too large for a single upload operation. With multipart uploads, individual parts of an object can be * uploaded in parallel to reduce the amount of time you spend uploading. Multipart uploads can also minimize the impact * of network failures by letting you retry a failed part upload instead of requiring you to retry an entire object upload. - * See [Managing Multipart Uploads](https://docs.us-phoenix-1.oraclecloud.com/Content/Object/Tasks/managingmultipartuploads.htm). + * See [Using Multipart Uploads](https://docs.us-phoenix-1.oraclecloud.com/Content/Object/Tasks/usingmultipartuploads.htm). *

* To use any of the API operations, you must be authorized in an IAM policy. If you're not authorized, * talk to an administrator. If you're an administrator who needs to write policies to give users access, see diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/PreauthenticatedRequest.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/PreauthenticatedRequest.java index 8716b81b122..37da385088f 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/PreauthenticatedRequest.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/PreauthenticatedRequest.java @@ -6,7 +6,7 @@ /** * Pre-authenticated requests provide a way to let users access a bucket or an object without having their own credentials. * When you create a pre-authenticated request, a unique URL is generated. Users in your organization, partners, or third - * parties can use this URL to access the targets identified in the pre-authenticated request. See [Managing Access to Buckets and Objects](https://docs.us-phoenix-1.oraclecloud.com/Content/Object/Tasks/managingaccess.htm). + * parties can use this URL to access the targets identified in the pre-authenticated request. See [Using Pre-Authenticated Requests](https://docs.us-phoenix-1.oraclecloud.com/Content/Object/Tasks/usingpreauthenticatedrequests.htm). *

* To use any of the API operations, you must be authorized in an IAM policy. If you're not authorized, talk to an administrator. * If you're an administrator who needs to write policies to give users access, see [Getting Started with Policies](https://docs.us-phoenix-1.oraclecloud.com/Content/Identity/Concepts/policygetstarted.htm). diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/UpdateBucketDetails.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/UpdateBucketDetails.java index 7e9b43f6132..fc40d3d0a05 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/UpdateBucketDetails.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/model/UpdateBucketDetails.java @@ -91,6 +91,15 @@ public Builder definedTags( return this; } + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + private String kmsKeyId; + + public Builder kmsKeyId(String kmsKeyId) { + this.kmsKeyId = kmsKeyId; + this.__explicitlySet__.add("kmsKeyId"); + return this; + } + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); @@ -103,7 +112,8 @@ public UpdateBucketDetails build() { metadata, publicAccessType, freeformTags, - definedTags); + definedTags, + kmsKeyId); __instance__.__explicitlySet__.addAll(__explicitlySet__); return __instance__; } @@ -117,7 +127,8 @@ public Builder copy(UpdateBucketDetails o) { .metadata(o.getMetadata()) .publicAccessType(o.getPublicAccessType()) .freeformTags(o.getFreeformTags()) - .definedTags(o.getDefinedTags()); + .definedTags(o.getDefinedTags()) + .kmsKeyId(o.getKmsKeyId()); copiedBuilder.__explicitlySet__.retainAll(o.__explicitlySet__); return copiedBuilder; @@ -224,6 +235,16 @@ public static PublicAccessType create(String key) { @com.fasterxml.jackson.annotation.JsonProperty("definedTags") java.util.Map> definedTags; + /** + * A KMS key OCID that will be associated with the given bucket. If it is empty the Update operation will + * actually remove the KMS key, if there is one, from the given bucket. Please note, the old kms key should + * still be enbaled in KMS otherwise all the objects in the bucket encrypted with the old KMS key will no + * longer accessible. + * + **/ + @com.fasterxml.jackson.annotation.JsonProperty("kmsKeyId") + String kmsKeyId; + @com.fasterxml.jackson.annotation.JsonIgnore private final java.util.Set __explicitlySet__ = new java.util.HashSet(); } diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListBucketsResponse.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListBucketsResponse.java index dd68a0d5bf7..e3069336d7f 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListBucketsResponse.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListBucketsResponse.java @@ -23,10 +23,12 @@ public class ListBucketsResponse { private String opcRequestId; /** - * For pagination of a list of `Bucket`s. If this header appears in the response, then this - * is a partial list of buckets. Include this value as the `page` parameter in a subsequent - * GET request to get the next batch of buckets. For information about pagination, see - * [List Pagination](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/usingapi.htm#nine). + * Paginating a list of items. + * In the GET request, set the limit to the number of buckets items that you want returned in the response. + * If the opc-next-page header appears in the response, then this is a partial list and there are additional + * buckets to get. Include the header's value as the `page` parameter in the subsequent GET request to get the + * next batch of buckets. Repeat this process to retrieve the entire list of buckets. + * By default, the page limit is set to 25 buckets per page, but you can specify a value from 1 to 1000. * */ private String opcNextPage; diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListMultipartUploadPartsResponse.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListMultipartUploadPartsResponse.java index ff74bbdf496..cd733238f05 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListMultipartUploadPartsResponse.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListMultipartUploadPartsResponse.java @@ -23,10 +23,11 @@ public class ListMultipartUploadPartsResponse { private String opcRequestId; /** - * For pagination of a list of `MultipartUploadPartSummary`s. If this header appears in the response, - * then this is a partial list of object parts. Include this value as the `page` parameter in a subsequent - * GET request to get the next batch of object parts. For information about pagination, see - * [List Pagination](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/usingapi.htm). + * Paginating a list of items. + * In the GET request, set the limit to the number of object parts that you want returned in the response. If + * the opc-next-page header appears in the response, then this is a partial list and there are additional object + * parts to get. Include the header's value as the `page` parameter in the subsequent GET request to get the next + * batch of object parts. Repeat this process to retrieve the entire list of object parts. * */ private String opcNextPage; diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListMultipartUploadsResponse.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListMultipartUploadsResponse.java index cabfff2b92d..1debf29336c 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListMultipartUploadsResponse.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListMultipartUploadsResponse.java @@ -23,9 +23,12 @@ public class ListMultipartUploadsResponse { private String opcRequestId; /** - * For pagination of a list of `MultipartUpload`s. If this header appears in the response, then - * this is a partial list of multipart uploads. Include this value as the `page` parameter in a subsequent - * GET request. For information about pagination, see [List Pagination](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/usingapi.htm). + * Paginating a list of items. + * In the GET request, set the limit to the number of objects that you want returned in the response. + * If the opc-next-page header appears in the response, then this is a partial list and there + * are additional objects to get. Include the header's value as the `page` parameter in the subsequent + * GET request to get the next batch of objects. Repeat this process to retrieve the entire list of + * objects. * */ private String opcNextPage; diff --git a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListPreauthenticatedRequestsResponse.java b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListPreauthenticatedRequestsResponse.java index 16398d632de..d28f99a01d1 100644 --- a/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListPreauthenticatedRequestsResponse.java +++ b/bmc-objectstorage/bmc-objectstorage-generated/src/main/java/com/oracle/bmc/objectstorage/responses/ListPreauthenticatedRequestsResponse.java @@ -23,10 +23,12 @@ public class ListPreauthenticatedRequestsResponse { private String opcRequestId; /** - * For pagination of a list of pre-authenticated requests, if this header appears in the response, - * then this is a partial list. Include this value as the `page` parameter in a subsequent - * GET request to get the next batch of pre-authenticated requests. - * For information about pagination, see [List Pagination](https://docs.us-phoenix-1.oraclecloud.com/Content/API/Concepts/usingapi.htm#nine). + * Paginating a list of items. + * In the GET request, set the limit to the number of pre-authenticated requests that you want returned in + * the response. If the opc-next-page header appears in the response, then this is a partial list and there + * are additional pre-authenticated requests to get. Include the header's value as the `page` parameter in + * the subsequent GET request to get the next batch of pre-authenticated requests. Repeat this process to + * retrieve the entire list of pre-authenticated requests. * */ private String opcNextPage; diff --git a/bmc-objectstorage/pom.xml b/bmc-objectstorage/pom.xml index e6add320ac5..cdd458853b2 100644 --- a/bmc-objectstorage/pom.xml +++ b/bmc-objectstorage/pom.xml @@ -5,32 +5,20 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml - oci-java-sdk-objectstorage + oci-java-sdk-objectstorage-parent pom - Oracle Cloud Infrastructure SDK - Object Storage + Oracle Cloud Infrastructure SDK - Object Storage Parent This project contains add-on modules for Oracle Cloud Infrastructure https://docs.us-phoenix-1.oraclecloud.com/Content/API/SDKDocs/javasdk.htm - - - com.oracle.oci.sdk - oci-java-sdk-common - 1.2.46 - - - com.oracle.oci.sdk - oci-java-sdk-objectstorage-generated - 1.2.46 - - - com.oracle.oci.sdk - oci-java-sdk-objectstorage-extensions - 1.2.46 - - + + bmc-objectstorage-combined + bmc-objectstorage-extensions + bmc-objectstorage-generated + diff --git a/bmc-objectstorage/src/main/java/.empty b/bmc-objectstorage/src/main/java/.empty new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bmc-objectstorage/src/test/java/.empty b/bmc-objectstorage/src/test/java/.empty new file mode 100644 index 00000000000..e69de29bb2d diff --git a/bmc-resourcesearch/pom.xml b/bmc-resourcesearch/pom.xml index b16c3a47181..0988709fd49 100644 --- a/bmc-resourcesearch/pom.xml +++ b/bmc-resourcesearch/pom.xml @@ -4,7 +4,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml oci-java-sdk-resourcesearch @@ -15,7 +15,7 @@ com.oracle.oci.sdk oci-java-sdk-common - 1.2.46 + 1.2.47 \ No newline at end of file diff --git a/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearch.java b/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearch.java index ea6e1e9378a..ea13ab7fdc5 100644 --- a/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearch.java +++ b/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearch.java @@ -64,4 +64,13 @@ public interface ResourceSearch extends AutoCloseable { * @throws BmcException when an error occurs. */ SearchResourcesResponse searchResources(SearchResourcesRequest request); + + /** + * Gets the pre-configured paginators available for list operations in this service which may return multiple + * pages of data. These paginators provide an {@link java.lang.Iterable} interface so that service responses, or + * resources/records, can be iterated through without having to manually deal with pagination and page tokens. + * + * @return The service paginators. + */ + ResourceSearchPaginators getPaginators(); } diff --git a/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchAsyncClient.java b/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchAsyncClient.java index 68f5e33a656..0a057303250 100644 --- a/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchAsyncClient.java +++ b/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchAsyncClient.java @@ -15,7 +15,10 @@ public class ResourceSearchAsyncClient implements ResourceSearchAsync { * Service instance for ResourceSearch. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("RESOURCESEARCH", "query"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("RESOURCESEARCH") + .serviceEndpointPrefix("query") + .build(); @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; diff --git a/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchClient.java b/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchClient.java index 0f00486b4ef..2f41410f511 100644 --- a/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchClient.java +++ b/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchClient.java @@ -15,10 +15,15 @@ public class ResourceSearchClient implements ResourceSearch { * Service instance for ResourceSearch. */ public static final com.oracle.bmc.Service SERVICE = - com.oracle.bmc.Services.create("RESOURCESEARCH", "query"); + com.oracle.bmc.Services.serviceBuilder() + .serviceName("RESOURCESEARCH") + .serviceEndpointPrefix("query") + .build(); // attempt twice if it's instance principals, immediately failures will try to refresh the token private static final int MAX_IMMEDIATE_RETRIES_IF_USING_INSTANCE_PRINCIPALS = 2; + private final ResourceSearchPaginators paginators; + @lombok.Getter(value = lombok.AccessLevel.PACKAGE) private final com.oracle.bmc.http.internal.RestClient client; @@ -193,6 +198,8 @@ public ResourceSearchClient( } this.client = restClientFactory.create(defaultRequestSigner, requestSigners, configuration); + this.paginators = new ResourceSearchPaginators(this); + if (this.authenticationDetailsProvider instanceof com.oracle.bmc.auth.RegionProvider) { com.oracle.bmc.auth.RegionProvider provider = (com.oracle.bmc.auth.RegionProvider) this.authenticationDetailsProvider; @@ -375,4 +382,9 @@ private boolean canRetryRequestIfRefreshableAuthTokenUsed(com.oracle.bmc.model.B } return false; } + + @Override + public ResourceSearchPaginators getPaginators() { + return paginators; + } } diff --git a/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchPaginators.java b/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchPaginators.java new file mode 100644 index 00000000000..61cc9a59aa6 --- /dev/null +++ b/bmc-resourcesearch/src/main/java/com/oracle/bmc/resourcesearch/ResourceSearchPaginators.java @@ -0,0 +1,144 @@ +/** + * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. + */ +package com.oracle.bmc.resourcesearch; + +import com.oracle.bmc.resourcesearch.requests.*; +import com.oracle.bmc.resourcesearch.responses.*; + +/** + * Collection of helper methods that can be used to provide an {@link java.lang.Iterable} interface + * to any list operations of ResourceSearch where multiple pages of data may be fetched. + * Two styles of iteration are supported: + * + *

    + *
  • Iterating over the Response objects returned by the list operation. These are referred to as ResponseIterators, and the methods are suffixed with ResponseIterator. For example: listUsersResponseIterator
  • + *
  • Iterating over the resources/records being listed. These are referred to as RecordIterators, and the methods are suffixed with RecordIterator. For example: listUsersRecordIterator
  • + *
+ * + * These iterables abstract away the need to write code to manually handle pagination via looping and using the page tokens. + * They will automatically fetch more data from the service when required. + * + * As an example, if we were using the ListUsers operation in IdentityService, then the {@link java.lang.Iterable} returned by calling a + * ResponseIterator method would iterate over the ListUsersResponse objects returned by each ListUsers call, whereas the {@link java.lang.Iterable} + * returned by calling a RecordIterator method would iterate over the User records and we don't have to deal with ListUsersResponse objects at all. + * In either case, pagination will be automatically handled so we can iterate until there are no more responses or no more resources/records available. + */ +@javax.annotation.Generated(value = "OracleSDKGenerator", comments = "API Version: 0.0.4") +@lombok.RequiredArgsConstructor +public class ResourceSearchPaginators { + private final ResourceSearch client; + + /** + * Creates a new iterable which will iterate over the responses received from the listResourceTypes operation. This iterable + * will fetch more data from the server as needed. + * + * @param request a request which can be sent to the service operation + * @return an {@link java.lang.Iterable} which can be used to iterate over the responses received from the service. + */ + public Iterable listResourceTypesResponseIterator( + final ListResourceTypesRequest request) { + return new com.oracle.bmc.paginator.internal.ResponseIterable< + ListResourceTypesRequest.Builder, ListResourceTypesRequest, + ListResourceTypesResponse>( + new com.google.common.base.Supplier() { + @Override + public ListResourceTypesRequest.Builder get() { + return ListResourceTypesRequest.builder().copy(request); + } + }, + new com.google.common.base.Function() { + @Override + public String apply(ListResourceTypesResponse response) { + return response.getOpcNextPage(); + } + }, + new com.google.common.base.Function< + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListResourceTypesRequest.Builder>, + ListResourceTypesRequest>() { + @Override + public ListResourceTypesRequest apply( + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListResourceTypesRequest.Builder> + input) { + if (input.getToken() == null) { + return input.getRequestBuilder().build(); + } else { + return input.getRequestBuilder() + .page(input.getToken().orNull()) + .build(); + } + } + }, + new com.google.common.base.Function< + ListResourceTypesRequest, ListResourceTypesResponse>() { + @Override + public ListResourceTypesResponse apply(ListResourceTypesRequest request) { + return client.listResourceTypes(request); + } + }); + } + + /** + * Creates a new iterable which will iterate over the {@link com.oracle.bmc.resourcesearch.model.ResourceType} objects + * contained in responses from the listResourceTypes operation. This iterable will fetch more data from the + * server as needed. + * + * @param request a request which can be sent to the service operation + * @return an {@link java.lang.Iterable} which can be used to iterate over the {@link com.oracle.bmc.resourcesearch.model.ResourceType} objects + * contained in responses received from the service. + */ + public Iterable + listResourceTypesRecordIterator(final ListResourceTypesRequest request) { + return new com.oracle.bmc.paginator.internal.ResponseRecordIterable< + ListResourceTypesRequest.Builder, ListResourceTypesRequest, + ListResourceTypesResponse, com.oracle.bmc.resourcesearch.model.ResourceType>( + new com.google.common.base.Supplier() { + @Override + public ListResourceTypesRequest.Builder get() { + return ListResourceTypesRequest.builder().copy(request); + } + }, + new com.google.common.base.Function() { + @Override + public String apply(ListResourceTypesResponse response) { + return response.getOpcNextPage(); + } + }, + new com.google.common.base.Function< + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListResourceTypesRequest.Builder>, + ListResourceTypesRequest>() { + @Override + public ListResourceTypesRequest apply( + com.oracle.bmc.paginator.internal.RequestBuilderAndToken< + ListResourceTypesRequest.Builder> + input) { + if (input.getToken() == null) { + return input.getRequestBuilder().build(); + } else { + return input.getRequestBuilder() + .page(input.getToken().orNull()) + .build(); + } + } + }, + new com.google.common.base.Function< + ListResourceTypesRequest, ListResourceTypesResponse>() { + @Override + public ListResourceTypesResponse apply(ListResourceTypesRequest request) { + return client.listResourceTypes(request); + } + }, + new com.google.common.base.Function< + ListResourceTypesResponse, + java.util.List>() { + @Override + public java.util.List apply( + ListResourceTypesResponse response) { + return response.getItems(); + } + }); + } +} diff --git a/bmc-shaded/bmc-shaded-full/pom.xml b/bmc-shaded/bmc-shaded-full/pom.xml index d9eae2950dc..386b6db7491 100644 --- a/bmc-shaded/bmc-shaded-full/pom.xml +++ b/bmc-shaded/bmc-shaded-full/pom.xml @@ -4,7 +4,7 @@ com.oracle.oci.sdk oci-java-sdk-shaded - 1.2.46 + 1.2.47 ../pom.xml oci-java-sdk-shaded-full diff --git a/bmc-shaded/pom.xml b/bmc-shaded/pom.xml index 37ed1784e2f..60b654a35e1 100644 --- a/bmc-shaded/pom.xml +++ b/bmc-shaded/pom.xml @@ -5,7 +5,7 @@ com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 ../pom.xml diff --git a/pom.xml b/pom.xml index f6081696b8c..e9c67cd967f 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.oracle.oci.sdk oci-java-sdk - 1.2.46 + 1.2.47 pom Oracle Cloud Infrastructure SDK This project contains the SDK used for Oracle Cloud Infrastructure @@ -556,12 +556,11 @@ bmc-filestorage bmc-identity bmc-loadbalancer - bmc-objectstorage/bmc-objectstorage-generated - bmc-objectstorage/bmc-objectstorage-extensions bmc-objectstorage bmc-containerengine bmc-resourcesearch bmc-addons + bmc-keymanagement bmc-full bmc-shaded