예제 #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,
 };
예제 #6
0
 internal KeyVaultSecret(SecretProperties properties = null)
 {
     Properties = properties ?? new SecretProperties();
 }
예제 #7
0
 internal DeletedSecret(SecretProperties properties = null) : base(properties)
 {
 }