示例#1
0
        /// <summary>
        /// Updates the attributes associated with a specified secret.
        /// </summary>
        /// <remarks>
        /// The update operation changes specified attributes of an existing stored
        /// secret. Attributes that are not specified in the request are left
        /// unchanged. The value of a secret itself cannot be changed. This operation
        /// requires the secrets/set permission.
        /// </remarks>
        /// <param name="properties">The secret object with updated properties.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        public virtual Response <SecretProperties> UpdateSecretProperties(SecretProperties properties, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(properties, nameof(properties));
            Argument.AssertNotNull(properties.Version, nameof(properties.Version));

            using DiagnosticScope scope = _pipeline.CreateScope("Azure.Security.KeyVault.Secrets.SecretClient.UpdateSecretProperties");
            scope.AddAttribute("secret", properties.Name);
            scope.Start();

            try
            {
                return(_pipeline.SendRequest(RequestMethod.Patch, properties, () => new SecretProperties(), cancellationToken, SecretsPath, properties.Name, "/", properties.Version));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#2
0
 /// <summary>
 /// Initializes a new instance of the Secret class.
 /// </summary>
 /// <param name="name">The name of the secret.</param>
 /// <param name="value">The value of the secret.</param>
 /// <exception cref="ArgumentException"><paramref name="name"/> is an empty string.</exception>
 /// <exception cref="ArgumentNullException"><paramref name="name"/> or <paramref name="value"/> is null.</exception>
 public Secret(string name, string value)
 {
     Properties = new SecretProperties(name);
     Value      = value ?? throw new ArgumentNullException(nameof(value));
 }
示例#3
0
 internal Secret()
 {
     Properties = new SecretProperties();
 }
        /// <summary>
        /// Updates the attributes associated with a specified secret.
        /// </summary>
        /// <remarks>
        /// The update operation changes specified attributes of an existing stored
        /// secret. Attributes that are not specified in the request are left
        /// unchanged. The value of a secret itself cannot be changed. This operation
        /// requires the secrets/set permission.
        /// </remarks>
        /// <param name="properties">The secret object with updated properties.</param>
        /// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
        /// <exception cref="ArgumentNullException"><paramref name="properties"/> or <see cref="SecretProperties.Version"/> is null.</exception>
        /// <exception cref="RequestFailedException">The server returned an error. See <see cref="Exception.Message"/> for details returned from the server.</exception>
        public virtual async Task <Response <SecretProperties> > UpdateSecretPropertiesAsync(SecretProperties properties, CancellationToken cancellationToken = default)
        {
            Argument.AssertNotNull(properties, nameof(properties));
            Argument.AssertNotNull(properties.Version, nameof(properties.Version));

            using DiagnosticScope scope = _pipeline.CreateScope($"{nameof(SecretClient)}.{nameof(UpdateSecretProperties)}");
            scope.AddAttribute("secret", properties.Name);
            scope.Start();

            try
            {
                return(await _pipeline.SendRequestAsync(RequestMethod.Patch, properties, () => new SecretProperties(), cancellationToken, SecretsPath, properties.Name, "/", properties.Version).ConfigureAwait(false));
            }
            catch (Exception e)
            {
                scope.Failed(e);
                throw;
            }
        }
示例#5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Secrets.KeyVaultSecret"/> for mocking purposes.
 /// </summary>
 /// <param name="properties">Sets the <see cref="Secrets.KeyVaultSecret.Properties"/> property, which provides the <see cref="Secrets.KeyVaultSecret.Id"/> and <see cref="Secrets.KeyVaultSecret.Name"/> properties.</param>
 /// <param name="value">Sets the <see cref="Secrets.KeyVaultSecret.Value"/> property.</param>
 /// <returns>A new instance of the <see cref="Secrets.KeyVaultSecret"/> for mocking purposes.</returns>
 public static KeyVaultSecret KeyVaultSecret(SecretProperties properties, string value = default) => new KeyVaultSecret(properties)
 {
     Value = value,
 };
 internal KeyVaultSecret(SecretProperties properties = null)
 {
     Properties = properties ?? new SecretProperties();
 }
 internal DeletedSecret(SecretProperties properties = null) : base(properties)
 {
 }