public static PutSecretValueResponse Unmarshall(UnmarshallerContext _ctx) { PutSecretValueResponse putSecretValueResponse = new PutSecretValueResponse(); putSecretValueResponse.HttpResponse = _ctx.HttpResponse; putSecretValueResponse.RequestId = _ctx.StringValue("PutSecretValue.RequestId"); putSecretValueResponse.SecretName = _ctx.StringValue("PutSecretValue.SecretName"); putSecretValueResponse.VersionId = _ctx.StringValue("PutSecretValue.VersionId"); List <string> putSecretValueResponse_versionStages = new List <string>(); for (int i = 0; i < _ctx.Length("PutSecretValue.VersionStages.Length"); i++) { putSecretValueResponse_versionStages.Add(_ctx.StringValue("PutSecretValue.VersionStages[" + i + "]")); } putSecretValueResponse.VersionStages = putSecretValueResponse_versionStages; return(putSecretValueResponse); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { PutSecretValueResponse response = new PutSecretValueResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("ARN", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ARN = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("Name", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Name = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("VersionId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.VersionId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("VersionStages", targetDepth)) { var unmarshaller = new ListUnmarshaller <string, StringUnmarshaller>(StringUnmarshaller.Instance); response.VersionStages = unmarshaller.Unmarshall(context); continue; } } return(response); }
/// <summary> /// Writes the text value of a particular key, to a given secret ARN /// </summary> /// <param name="key">The field within the secret to update</param> /// <param name="value">The value to update for the given key</param> /// <param name="secretVaultIdentifier">The full secret ARN</param> /// <returns>A status code with the result of the request</returns> public override async Task <HttpStatusCode> WriteValuesToSecretAsync(IDictionary <string, string> fieldsToInsertOrUpdate, string secretVaultIdentifier) { string originalSecretJson = await GetJsonFromSecretAsync(secretVaultIdentifier); // for each value in the dictionary, try to update the JSON string sbUpdatedSecretJson = originalSecretJson; foreach (var field in fieldsToInsertOrUpdate) { sbUpdatedSecretJson = UpdateJsonForSecret(secretVaultIdentifier, sbUpdatedSecretJson, field.Key, field.Value); } PutSecretValueResponse response = null; // Now update the secret if (!string.IsNullOrEmpty(sbUpdatedSecretJson)) { PutSecretValueRequest request = new PutSecretValueRequest(); request.SecretId = secretVaultIdentifier; request.SecretString = sbUpdatedSecretJson; try { response = await SecretClient.PutSecretValueAsync(request); } catch (EncryptionFailureException e) { // Secrets Manager can't encrypt the protected secret text using the provided KMS key.\ _logger.Error(string.Format(DeploySoftware_LaunchPad_AWS_Resources.Logger_Error_WriteValueToSecret_Exception, secretVaultIdentifier, e.Message)); throw; } catch (InternalServiceErrorException e) { // An error occurred on the server side. _logger.Error(string.Format(DeploySoftware_LaunchPad_AWS_Resources.Logger_Error_WriteValueToSecret_Exception, secretVaultIdentifier, e.Message)); throw; } catch (InvalidParameterException e) { // You provided an invalid value for a parameter. _logger.Error(string.Format(DeploySoftware_LaunchPad_AWS_Resources.Logger_Error_WriteValueToSecret_Exception, secretVaultIdentifier, e.Message)); throw; } catch (InvalidRequestException e) { // You provided a parameter value that is not valid for the current state of the resource. _logger.Error(string.Format(DeploySoftware_LaunchPad_AWS_Resources.Logger_Error_WriteValueToSecret_Exception, secretVaultIdentifier, e.Message)); throw; } catch (ResourceNotFoundException e) { // We can't find the resource that you asked for. _logger.Error(string.Format(DeploySoftware_LaunchPad_AWS_Resources.Logger_Error_WriteValueToSecret_Exception, secretVaultIdentifier, e.Message)); throw; } catch (ResourceExistsException e) { // A resource with the ID you requested already exists. _logger.Error(string.Format(DeploySoftware_LaunchPad_AWS_Resources.Logger_Error_WriteValueToSecret_Exception, secretVaultIdentifier, e.Message)); throw; } catch (AggregateException e) { // More than one of the above exceptions were triggered. _logger.Error(string.Format(DeploySoftware_LaunchPad_AWS_Resources.Logger_Error_WriteValueToSecret_Exception, secretVaultIdentifier, e.Message)); throw; } } return(response.HttpStatusCode); }