Exemplo n.º 1
0
        /// <summary>
        /// Updates the properties of a vault. Specifically, you can update the
        /// &#x60;displayName&#x60;, &#x60;freeformTags&#x60;, and &#x60;definedTags&#x60; properties. Furthermore,
        /// the vault must be in an ACTIVE or CREATING state to be updated.
        /// &lt;br/&gt;
        /// As a provisioning operation, this call is subject to a Key Management limit that applies to
        /// the total number of requests across all provisioning write operations. Key Management might
        /// throttle this call to reject an otherwise valid request when the total rate of provisioning
        /// write operations exceeds 10 requests per second for a given tenancy.
        ///
        /// </summary>
        /// <param name="request">The request object containing the details to send. Required.</param>
        /// <param name="retryConfiguration">The retry configuration that will be used by to send this request. Optional.</param>
        /// <param name="cancellationToken">The cancellation token to cancel this operation. Optional.</param>
        /// <returns>A response object containing details about the completed operation</returns>
        /// <example>Click <a href="https://docs.cloud.oracle.com/en-us/iaas/tools/dot-net-examples/latest/keymanagement/UpdateVault.cs.html">here</a> to see an example of how to use UpdateVault API.</example>
        public async Task <UpdateVaultResponse> UpdateVault(UpdateVaultRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called updateVault");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/20180608/vaults/{vaultId}".Trim('/')));
            HttpMethod         method         = new HttpMethod("PUT");
            HttpRequestMessage requestMessage = Converter.ToHttpRequestMessage(uri, method, request);

            requestMessage.Headers.Add("Accept", "application/json");
            GenericRetrier      retryingClient = Retrier.GetPreferredRetrier(retryConfiguration, this.retryConfiguration);
            HttpResponseMessage responseMessage;

            try
            {
                if (retryingClient != null)
                {
                    responseMessage = await retryingClient.MakeRetryingCall(this.restClient.HttpSend, requestMessage, cancellationToken).ConfigureAwait(false);
                }
                else
                {
                    responseMessage = await this.restClient.HttpSend(requestMessage).ConfigureAwait(false);
                }
                this.restClient.CheckHttpResponseMessage(requestMessage, responseMessage);

                return(Converter.FromHttpResponseMessage <UpdateVaultResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"UpdateVault failed with error: {e.Message}");
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 修改存储库
        /// </summary>
        public async Task <UpdateVaultResponse> UpdateVaultAsync(UpdateVaultRequest updateVaultRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("vault_id", updateVaultRequest.VaultId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v3/{project_id}/vaults/{vault_id}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", updateVaultRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("PUT", request);

            return(JsonUtils.DeSerialize <UpdateVaultResponse>(response));
        }
Exemplo n.º 3
0
        private static async Task UpdateVaultResetTags(KmsVaultClient kmsVaultClient, string vaultId)
        {
            logger.Info($"Updating vault");

            Dictionary <string, string> freeformTags       = new Dictionary <string, string>();
            UpdateVaultDetails          updateVaultDetails = new UpdateVaultDetails
            {
                FreeformTags = freeformTags
            };
            UpdateVaultRequest updateVaultRequest = new UpdateVaultRequest
            {
                UpdateVaultDetails = updateVaultDetails,
                VaultId            = vaultId
            };
            UpdateVaultResponse updateVaultResponse = await kmsVaultClient.UpdateVault(updateVaultRequest);

            logger.Info($"cleared tags for the Vault: {updateVaultResponse.Vault.ToString()}");
        }
Exemplo n.º 4
0
        private static async Task UpdateVault(KmsVaultClient kmsVaultClient, string vaultId)
        {
            logger.Info($"Updating vault");

            Dictionary <string, string> freeformTags = new Dictionary <string, string>()
            {
                { "freeformkey1", "freeformvalue1" },
                { "freeformkey2", "freeformvalue2" }
            };
            UpdateVaultDetails updateVaultDetails = new UpdateVaultDetails
            {
                FreeformTags = freeformTags,
                DisplayName  = "updated-vault-display-name"
            };
            UpdateVaultRequest updateVaultRequest = new UpdateVaultRequest
            {
                UpdateVaultDetails = updateVaultDetails,
                VaultId            = vaultId
            };
            UpdateVaultResponse updateVaultResponse = await kmsVaultClient.UpdateVault(updateVaultRequest);

            logger.Info($"added tags for the vault: {updateVaultResponse.Vault.ToString()}");
        }
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateVaultRequest request;

            try
            {
                request = new UpdateVaultRequest
                {
                    VaultId            = VaultId,
                    UpdateVaultDetails = UpdateVaultDetails,
                    IfMatch            = IfMatch,
                    OpcRequestId       = OpcRequestId
                };

                response = client.UpdateVault(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Vault);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }