@@ -213,7 +213,8 @@ Mono<Response<KeyVaultKey>> createKeyWithResponse(CreateKeyOptions createKeyOpti
213213 KeyRequestParameters parameters = new KeyRequestParameters ()
214214 .setKty (createKeyOptions .getKeyType ())
215215 .setKeyOps (createKeyOptions .getKeyOperations ())
216- .setKeyAttributes (new KeyRequestAttributes (createKeyOptions ));
216+ .setKeyAttributes (new KeyRequestAttributes (createKeyOptions ))
217+ .setReleasePolicy (createKeyOptions .getReleasePolicy ());
217218 return service .createKey (vaultUrl , createKeyOptions .getName (), apiVersion , ACCEPT_LANGUAGE , parameters ,
218219 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
219220 .doOnRequest (ignored -> logger .info ("Creating key - {}" , createKeyOptions .getName ()))
@@ -293,7 +294,9 @@ Mono<Response<KeyVaultKey>> createRsaKeyWithResponse(CreateRsaKeyOptions createR
293294 .setKty (createRsaKeyOptions .getKeyType ())
294295 .setKeySize (createRsaKeyOptions .getKeySize ())
295296 .setKeyOps (createRsaKeyOptions .getKeyOperations ())
296- .setKeyAttributes (new KeyRequestAttributes (createRsaKeyOptions ));
297+ .setKeyAttributes (new KeyRequestAttributes (createRsaKeyOptions ))
298+ .setReleasePolicy (createRsaKeyOptions .getReleasePolicy ())
299+ .setPublicExponent (createRsaKeyOptions .getPublicExponent ());
297300 return service .createKey (vaultUrl , createRsaKeyOptions .getName (), apiVersion , ACCEPT_LANGUAGE , parameters ,
298301 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
299302 .doOnRequest (ignored -> logger .info ("Creating Rsa key - {}" , createRsaKeyOptions .getName ()))
@@ -379,7 +382,8 @@ Mono<Response<KeyVaultKey>> createEcKeyWithResponse(CreateEcKeyOptions createEcK
379382 .setKty (createEcKeyOptions .getKeyType ())
380383 .setCurve (createEcKeyOptions .getCurveName ())
381384 .setKeyOps (createEcKeyOptions .getKeyOperations ())
382- .setKeyAttributes (new KeyRequestAttributes (createEcKeyOptions ));
385+ .setKeyAttributes (new KeyRequestAttributes (createEcKeyOptions ))
386+ .setReleasePolicy (createEcKeyOptions .getReleasePolicy ());
383387 return service .createKey (vaultUrl , createEcKeyOptions .getName (), apiVersion , ACCEPT_LANGUAGE , parameters ,
384388 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
385389 .doOnRequest (ignored -> logger .info ("Creating Ec key - {}" , createEcKeyOptions .getName ()))
@@ -492,14 +496,108 @@ Mono<Response<KeyVaultKey>> importKeyWithResponse(ImportKeyOptions importKeyOpti
492496 KeyImportRequestParameters parameters = new KeyImportRequestParameters ()
493497 .setKey (importKeyOptions .getKey ())
494498 .setHsm (importKeyOptions .isHardwareProtected ())
495- .setKeyAttributes (new KeyRequestAttributes (importKeyOptions ));
499+ .setKeyAttributes (new KeyRequestAttributes (importKeyOptions ))
500+ .setReleasePolicy (importKeyOptions .getReleasePolicy ());
496501 return service .importKey (vaultUrl , importKeyOptions .getName (), apiVersion , ACCEPT_LANGUAGE , parameters ,
497502 CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
498503 .doOnRequest (ignored -> logger .info ("Importing key - {}" , importKeyOptions .getName ()))
499504 .doOnSuccess (response -> logger .info ("Imported key - {}" , response .getValue ().getName ()))
500505 .doOnError (error -> logger .warning ("Failed to import key - {}" , importKeyOptions .getName (), error ));
501506 }
502507
508+ /**
509+ * Exports the latest version of a key from the key vault. The export key operation may be used to import any key
510+ * from the Azure Key Vault as long as it is marked as exportable and its release policy is satisfied.
511+ *
512+ * <p><strong>Code Samples</strong></p>
513+ * <p>Exports a key from a key vault. Subscribes to the call asynchronously and prints out the newly exported key
514+ * details when a response has been received.</p>
515+ *
516+ * {@codesnippet com.azure.security.keyvault.keys.keyasyncclient.exportKey#String-String}
517+ *
518+ * @param name The name of the key to be exported.
519+ * @param environment The target environment assertion.
520+ * @return A {@link Mono} containing the {@link KeyVaultKey exported key}.
521+ * @throws NullPointerException If the specified {@code name} or {@code environment} are {@code null}.
522+ */
523+ @ ServiceMethod (returns = ReturnType .SINGLE )
524+ public Mono <KeyVaultKey > exportKey (String name , String environment ) {
525+ try {
526+ return exportKeyWithResponse (name , "" , environment ).flatMap (FluxUtil ::toMono );
527+ } catch (RuntimeException ex ) {
528+ return monoError (logger , ex );
529+ }
530+ }
531+
532+ /**
533+ * Exports a key from the key vault. The export key operation may be used to import any key from the Azure Key Vault
534+ * as long as it is marked as exportable and its release policy is satisfied.
535+ *
536+ * <p><strong>Code Samples</strong></p>
537+ * <p>Exports a key from a key vault. Subscribes to the call asynchronously and prints out the newly exported key
538+ * details when a response has been received.</p>
539+ *
540+ * {@codesnippet com.azure.security.keyvault.keys.keyasyncclient.exportKey#String-String-String}
541+ *
542+ * @param name The name of the key to be exported.
543+ * @param version The key version.
544+ * @param environment The target environment assertion.
545+ * @return A {@link Mono} containing the {@link KeyVaultKey exported key}.
546+ * @throws NullPointerException If the specified {@code name}, {@code version} or {@code environment} are
547+ * {@code null}.
548+ */
549+ @ ServiceMethod (returns = ReturnType .SINGLE )
550+ public Mono <KeyVaultKey > exportKey (String name , String version , String environment ) {
551+ try {
552+ return exportKeyWithResponse (name , version , environment ).flatMap (FluxUtil ::toMono );
553+ } catch (RuntimeException ex ) {
554+ return monoError (logger , ex );
555+ }
556+ }
557+
558+ /**
559+ * Exports a key from the key vault. The export key operation may be used to import any key from the Azure Key Vault
560+ * as long as it is marked as exportable and its release policy is satisfied.
561+ *
562+ * <p><strong>Code Samples</strong></p>
563+ * <p>Exports a key from a key vault. Subscribes to the call asynchronously and prints out the newly exported key
564+ * details when a response has been received.</p>
565+ *
566+ * {@codesnippet com.azure.security.keyvault.keys.keyasyncclient.exportKeyWithResponse#String-String-String}
567+ *
568+ * @param name The name of the key to be exported.
569+ * @param version The key version.
570+ * @param environment The target environment assertion.
571+ * @return A {@link Mono} containing a {@link Response} whose {@link Response#getValue() value} contains the
572+ * {@link KeyVaultKey exported key}.
573+ * @throws NullPointerException If the specified {@code name}, {@code version} or {@code environment} are
574+ * {@code null}.
575+ */
576+ @ ServiceMethod (returns = ReturnType .SINGLE )
577+ public Mono <Response <KeyVaultKey >> exportKeyWithResponse (String name , String version , String environment ) {
578+ try {
579+ return withContext (context -> exportKeyWithResponse (name , version , environment , context ));
580+ } catch (RuntimeException ex ) {
581+ return monoError (logger , ex );
582+ }
583+ }
584+
585+ Mono <Response <KeyVaultKey >> exportKeyWithResponse (String name , String version , String environment ,
586+ Context context ) {
587+ Objects .requireNonNull (name , "The key name cannot be null." );
588+ Objects .requireNonNull (version , "The key version cannot be null." );
589+ Objects .requireNonNull (environment , "The environment parameter cannot be null." );
590+
591+ context = context == null ? Context .NONE : context ;
592+ KeyExportRequestParameters parameters = new KeyExportRequestParameters ().setEnvironment (environment );
593+
594+ return service .exportKey (vaultUrl , name , version , apiVersion , ACCEPT_LANGUAGE , parameters ,
595+ CONTENT_TYPE_HEADER_VALUE , context .addData (AZ_TRACING_NAMESPACE_KEY , KEYVAULT_TRACING_NAMESPACE_VALUE ))
596+ .doOnRequest (ignored -> logger .info ("Exporting key - {}" , name ))
597+ .doOnSuccess (response -> logger .info ("Exported key - {}" , response .getValue ().getName ()))
598+ .doOnError (error -> logger .warning ("Failed to export key - {}" , name , error ));
599+ }
600+
503601 /**
504602 * Gets the public part of the specified key and key version. The get key operation is applicable to all key types
505603 * and it requires the {@code keys/get} permission.
@@ -659,7 +757,8 @@ Mono<Response<KeyVaultKey>> updateKeyPropertiesWithResponse(KeyProperties keyPro
659757 context = context == null ? Context .NONE : context ;
660758 KeyRequestParameters parameters = new KeyRequestParameters ()
661759 .setTags (keyProperties .getTags ())
662- .setKeyAttributes (new KeyRequestAttributes (keyProperties ));
760+ .setKeyAttributes (new KeyRequestAttributes (keyProperties ))
761+ .setReleasePolicy (keyProperties .getReleasePolicy ());
663762 if (keyOperations .length > 0 ) {
664763 parameters .setKeyOps (Arrays .asList (keyOperations ));
665764 }
0 commit comments