コード例 #1
0
        internal virtual UpdateSecretResponse UpdateSecret(UpdateSecretRequest request)
        {
            var marshaller   = UpdateSecretRequestMarshaller.Instance;
            var unmarshaller = UpdateSecretResponseUnmarshaller.Instance;

            return(Invoke <UpdateSecretRequest, UpdateSecretResponse>(request, marshaller, unmarshaller));
        }
コード例 #2
0
        /// <summary>
        /// Updates the properties of a secret. Specifically, you can update the version number of the secret to make
        /// that version number the current version. You can also update a secret&#39;s description, its free-form or defined tags, rules
        /// and the secret contents. Updating the secret content automatically creates a new secret version. You cannot, however, update the current secret version number and the secret contents and the rules at the
        /// same time. Furthermore, the secret must in an &#x60;ACTIVE&#x60; lifecycle state to be updated.
        /// &lt;br/&gt;
        /// This operation is not supported by the Oracle Cloud Infrastructure Terraform Provider.
        ///
        /// </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/vault/UpdateSecret.cs.html">here</a> to see an example of how to use UpdateSecret API.</example>
        public async Task <UpdateSecretResponse> UpdateSecret(UpdateSecretRequest request, RetryConfiguration retryConfiguration = null, CancellationToken cancellationToken = default)
        {
            logger.Trace("Called updateSecret");
            Uri                uri            = new Uri(this.restClient.GetEndpoint(), System.IO.Path.Combine(basePathWithoutHost, "/secrets/{secretId}".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 <UpdateSecretResponse>(responseMessage));
            }
            catch (Exception e)
            {
                logger.Error($"UpdateSecret failed with error: {e.Message}");
                throw;
            }
        }
コード例 #3
0
        private async Task <string> Set(string key, string value)
        {
            var request = new CreateSecretRequest
            {
                Name         = key,
                SecretString = value
            };

            try
            {
                var createResponse = await _amazonSecretsManager.CreateSecretAsync(request);

                return(createResponse.VersionId);
            }
            catch (ResourceExistsException)
            {
                var updateRequest = new UpdateSecretRequest
                {
                    SecretId     = key,
                    SecretString = value
                };

                var response = await _amazonSecretsManager.UpdateSecretAsync(updateRequest);

                return(response.VersionId);
            }
        }
コード例 #4
0
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateSecret operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the UpdateSecret operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/secretsmanager-2017-10-17/UpdateSecret">REST API Reference for UpdateSecret Operation</seealso>
        public virtual Task <UpdateSecretResponse> UpdateSecretAsync(UpdateSecretRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var marshaller   = UpdateSecretRequestMarshaller.Instance;
            var unmarshaller = UpdateSecretResponseUnmarshaller.Instance;

            return(InvokeAsync <UpdateSecretRequest, UpdateSecretResponse>(request, marshaller,
                                                                           unmarshaller, cancellationToken));
        }
コード例 #5
0
        /// <summary>
        /// Initiates the asynchronous execution of the UpdateSecret operation.
        /// </summary>
        ///
        /// <param name="request">Container for the necessary parameters to execute the UpdateSecret operation.</param>
        /// <param name="cancellationToken">
        ///     A cancellation token that can be used by other objects or threads to receive notice of cancellation.
        /// </param>
        /// <returns>The task object representing the asynchronous operation.</returns>
        /// <seealso href="http://docs.aws.amazon.com/goto/WebAPI/secretsmanager-2017-10-17/UpdateSecret">REST API Reference for UpdateSecret Operation</seealso>
        public virtual Task <UpdateSecretResponse> UpdateSecretAsync(UpdateSecretRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken))
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateSecretRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateSecretResponseUnmarshaller.Instance;

            return(InvokeAsync <UpdateSecretResponse>(request, options, cancellationToken));
        }
コード例 #6
0
        internal virtual UpdateSecretResponse UpdateSecret(UpdateSecretRequest request)
        {
            var options = new InvokeOptions();

            options.RequestMarshaller    = UpdateSecretRequestMarshaller.Instance;
            options.ResponseUnmarshaller = UpdateSecretResponseUnmarshaller.Instance;

            return(Invoke <UpdateSecretResponse>(request, options));
        }
コード例 #7
0
        /// <summary>
        /// 更新凭据
        /// </summary>
        public async Task <UpdateSecretResponse> UpdateSecretAsync(UpdateSecretRequest updateSecretRequest)
        {
            Dictionary <string, string> urlParam = new Dictionary <string, string>();

            urlParam.Add("secret_id", updateSecretRequest.SecretId.ToString());
            string              urlPath  = HttpUtils.AddUrlPath("/v1/{project_id}/secrets/{secret_id}", urlParam);
            SdkRequest          request  = HttpUtils.InitSdkRequest(urlPath, "application/json;charset=UTF-8", updateSecretRequest);
            HttpResponseMessage response = await DoHttpRequestAsync("PUT", request);

            return(JsonUtils.DeSerialize <UpdateSecretResponse>(response));
        }
コード例 #8
0
        /// <summary>
        /// UpdateSecret接口的同步版本,该接口用于更新指定凭据名称和版本号的内容,调用该接口会对新的凭据内容加密后覆盖旧的内容。仅允许更新Enabled 和 Disabled 状态的凭据。
        /// </summary>
        /// <param name="req">参考<see cref="UpdateSecretRequest"/></param>
        /// <returns>参考<see cref="UpdateSecretResponse"/>实例</returns>
        public UpdateSecretResponse UpdateSecretSync(UpdateSecretRequest req)
        {
            JsonResponseModel <UpdateSecretResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "UpdateSecret");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <UpdateSecretResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
コード例 #9
0
        protected override void ProcessRecord()
        {
            base.ProcessRecord();
            UpdateSecretRequest request;

            try
            {
                request = new UpdateSecretRequest
                {
                    SecretId            = SecretId,
                    UpdateSecretDetails = UpdateSecretDetails,
                    IfMatch             = IfMatch,
                    OpcRequestId        = OpcRequestId
                };

                response = client.UpdateSecret(request).GetAwaiter().GetResult();
                WriteOutput(response, response.Secret);
                FinishProcessing(response);
            }
            catch (Exception ex)
            {
                TerminatingErrorDuringExecution(ex);
            }
        }
コード例 #10
0
        // [END secretmanager_list_secrets]

        // [START secretmanager_update_secret]
        /// <summary>
        /// Update an existing secret.
        /// </summary>
        /// <param name="projectId">ID of the project where the secret resides.</param>
        /// <param name="secretId">ID of the secret.</param>
        /// <example>
        /// Update an existing secret.
        /// <code>UpdateSecret("my-project", "my-secret")</code>
        /// </example>
        public static void UpdateSecret(string projectId, string secretId)
        {
            SecretManagerServiceClient client = SecretManagerServiceClient.Create();

            // Create the secret to update.
            var secret = new Secret
            {
                SecretName = new SecretName(projectId, secretId),
            };

            secret.Labels["secretmanager"] = "rocks";

            // Create the request.
            var request = new UpdateSecretRequest
            {
                Secret     = secret,
                UpdateMask = FieldMask.FromString("labels"),
            };

            // Update the secret
            var updatedSecret = client.UpdateSecret(request);

            Console.WriteLine($"Updated secret {updatedSecret.Name}");
        }
コード例 #11
0
 /// <summary>
 ///  修改机密描述
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public async Task <UpdateSecretResponse> UpdateSecret(UpdateSecretRequest request)
 {
     return(await new UpdateSecretExecutor().Client(this).Execute <UpdateSecretResponse, UpdateSecretResult, UpdateSecretRequest>(request).ConfigureAwait(false));
 }
コード例 #12
0
 /// <summary>
 ///  修改机密描述
 /// </summary>
 /// <param name="request">请求参数信息</param>
 /// <returns>请求结果信息</returns>
 public UpdateSecretResponse UpdateSecret(UpdateSecretRequest request)
 {
     return(new UpdateSecretExecutor().Client(this).Execute <UpdateSecretResponse, UpdateSecretResult, UpdateSecretRequest>(request));
 }