Selecione suas preferências de cookies

Usamos cookies essenciais e ferramentas semelhantes que são necessárias para fornecer nosso site e serviços. Usamos cookies de desempenho para coletar estatísticas anônimas, para que possamos entender como os clientes usam nosso site e fazer as devidas melhorias. Cookies essenciais não podem ser desativados, mas você pode clicar em “Personalizar” ou “Recusar” para recusar cookies de desempenho.

Se você concordar, a AWS e terceiros aprovados também usarão cookies para fornecer recursos úteis do site, lembrar suas preferências e exibir conteúdo relevante, incluindo publicidade relevante. Para aceitar ou recusar todos os cookies não essenciais, clique em “Aceitar” ou “Recusar”. Para fazer escolhas mais detalhadas, clique em “Personalizar”.

Use ModifyDBClusterParameterGroup com um AWS SDK - AWS Exemplos de código do SDK

Há mais exemplos de AWS SDK disponíveis no repositório AWS Doc SDK Examples GitHub .

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

Há mais exemplos de AWS SDK disponíveis no repositório AWS Doc SDK Examples GitHub .

As traduções são geradas por tradução automática. Em caso de conflito entre o conteúdo da tradução e da versão original em inglês, a versão em inglês prevalecerá.

Use ModifyDBClusterParameterGroup com um AWS SDK

Os exemplos de código a seguir mostram como usar o ModifyDBClusterParameterGroup.

Exemplos de ações são trechos de código de programas maiores e devem ser executados em contexto. É possível ver essa ação em contexto no seguinte exemplo de código:

.NET
AWS SDK for .NET
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

/// <summary> /// Modify the specified integer parameters with new values from user input. /// </summary> /// <param name="groupName">The group name for the parameters.</param> /// <param name="parameters">The list of integer parameters to modify.</param> /// <param name="newValue">Optional int value to set for parameters.</param> /// <returns>The name of the group that was modified.</returns> public async Task<string> ModifyIntegerParametersInGroupAsync(string groupName, List<Parameter> parameters, int newValue = 0) { foreach (var p in parameters) { if (p.IsModifiable && p.DataType == "integer") { while (newValue == 0) { Console.WriteLine( $"Enter a new value for {p.ParameterName} from the allowed values {p.AllowedValues} "); var choice = Console.ReadLine(); int.TryParse(choice, out newValue); } p.ParameterValue = newValue.ToString(); } } var request = new ModifyDBClusterParameterGroupRequest { Parameters = parameters, DBClusterParameterGroupName = groupName, }; var result = await _amazonRDS.ModifyDBClusterParameterGroupAsync(request); return result.DBClusterParameterGroupName; }
C++
SDK para C++
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

Aws::Client::ClientConfiguration clientConfig; // Optional: Set to the AWS Region (overrides config file). // clientConfig.region = "us-east-1"; Aws::RDS::RDSClient client(clientConfig); Aws::RDS::Model::ModifyDBClusterParameterGroupRequest request; request.SetDBClusterParameterGroupName(CLUSTER_PARAMETER_GROUP_NAME); request.SetParameters(updateParameters); Aws::RDS::Model::ModifyDBClusterParameterGroupOutcome outcome = client.ModifyDBClusterParameterGroup(request); if (outcome.IsSuccess()) { std::cout << "The DB cluster parameter group was successfully modified." << std::endl; } else { std::cerr << "Error with Aurora::ModifyDBClusterParameterGroup. " << outcome.GetError().GetMessage() << std::endl; }
Go
SDK para Go V2
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

import ( "context" "errors" "log" "github.com/aws/aws-sdk-go-v2/aws" "github.com/aws/aws-sdk-go-v2/service/rds" "github.com/aws/aws-sdk-go-v2/service/rds/types" ) type DbClusters struct { AuroraClient *rds.Client } // UpdateParameters updates parameters in a named DB cluster parameter group. func (clusters *DbClusters) UpdateParameters(ctx context.Context, parameterGroupName string, params []types.Parameter) error { _, err := clusters.AuroraClient.ModifyDBClusterParameterGroup(ctx, &rds.ModifyDBClusterParameterGroupInput{ DBClusterParameterGroupName: aws.String(parameterGroupName), Parameters: params, }) if err != nil { log.Printf("Couldn't update parameters in %v: %v\n", parameterGroupName, err) return err } else { return nil } }
Java
SDK para Java 2.x
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

public static void describeDbClusterParameterGroups(RdsClient rdsClient, String dbClusterGroupName) { try { DescribeDbClusterParameterGroupsRequest groupsRequest = DescribeDbClusterParameterGroupsRequest.builder() .dbClusterParameterGroupName(dbClusterGroupName) .maxRecords(20) .build(); List<DBClusterParameterGroup> groups = rdsClient.describeDBClusterParameterGroups(groupsRequest) .dbClusterParameterGroups(); for (DBClusterParameterGroup group : groups) { System.out.println("The group name is " + group.dbClusterParameterGroupName()); System.out.println("The group ARN is " + group.dbClusterParameterGroupArn()); } } catch (RdsException e) { System.out.println(e.getLocalizedMessage()); System.exit(1); } }
Kotlin
SDK para Kotlin
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

// Modify the auto_increment_offset parameter. suspend fun modifyDBClusterParas(dClusterGroupName: String?) { val parameter1 = Parameter { parameterName = "auto_increment_offset" applyMethod = ApplyMethod.fromValue("immediate") parameterValue = "5" } val paraList = ArrayList<Parameter>() paraList.add(parameter1) val groupRequest = ModifyDbClusterParameterGroupRequest { dbClusterParameterGroupName = dClusterGroupName parameters = paraList } RdsClient { region = "us-west-2" }.use { rdsClient -> val response = rdsClient.modifyDbClusterParameterGroup(groupRequest) println("The parameter group ${response.dbClusterParameterGroupName} was successfully modified") } }
Python
SDK para Python (Boto3)
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

class AuroraWrapper: """Encapsulates Aurora DB cluster actions.""" def __init__(self, rds_client): """ :param rds_client: A Boto3 Amazon Relational Database Service (Amazon RDS) client. """ self.rds_client = rds_client @classmethod def from_client(cls): """ Instantiates this class from a Boto3 client. """ rds_client = boto3.client("rds") return cls(rds_client) def update_parameters(self, parameter_group_name, update_parameters): """ Updates parameters in a custom DB cluster parameter group. :param parameter_group_name: The name of the parameter group to update. :param update_parameters: The parameters to update in the group. :return: Data about the modified parameter group. """ try: response = self.rds_client.modify_db_cluster_parameter_group( DBClusterParameterGroupName=parameter_group_name, Parameters=update_parameters, ) except ClientError as err: logger.error( "Couldn't update parameters in %s. Here's why: %s: %s", parameter_group_name, err.response["Error"]["Code"], err.response["Error"]["Message"], ) raise else: return response
Rust
SDK para Rust
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

// Modify both the auto_increment_offset and auto_increment_increment parameters in one call in the custom parameter group. Set their ParameterValue fields to a new allowable value. rds.ModifyDbClusterParameterGroup. pub async fn update_auto_increment( &self, offset: u8, increment: u8, ) -> Result<(), ScenarioError> { let modify_db_cluster_parameter_group = self .rds .modify_db_cluster_parameter_group( DB_CLUSTER_PARAMETER_GROUP_NAME, vec![ Parameter::builder() .parameter_name("auto_increment_offset") .parameter_value(format!("{offset}")) .apply_method(aws_sdk_rds::types::ApplyMethod::Immediate) .build(), Parameter::builder() .parameter_name("auto_increment_increment") .parameter_value(format!("{increment}")) .apply_method(aws_sdk_rds::types::ApplyMethod::Immediate) .build(), ], ) .await; if let Err(error) = modify_db_cluster_parameter_group { return Err(ScenarioError::new( "Failed to modify cluster parameter group", &error, )); } Ok(()) } pub async fn modify_db_cluster_parameter_group( &self, name: &str, parameters: Vec<Parameter>, ) -> Result<ModifyDbClusterParameterGroupOutput, SdkError<ModifyDBClusterParameterGroupError>> { self.inner .modify_db_cluster_parameter_group() .db_cluster_parameter_group_name(name) .set_parameters(Some(parameters)) .send() .await } #[tokio::test] async fn test_scenario_update_auto_increment() { let mut mock_rds = MockRdsImpl::default(); mock_rds .expect_modify_db_cluster_parameter_group() .withf(|name, params| { assert_eq!(name, "RustSDKCodeExamplesDBParameterGroup"); assert_eq!( params, &vec![ Parameter::builder() .parameter_name("auto_increment_offset") .parameter_value("10") .apply_method(aws_sdk_rds::types::ApplyMethod::Immediate) .build(), Parameter::builder() .parameter_name("auto_increment_increment") .parameter_value("20") .apply_method(aws_sdk_rds::types::ApplyMethod::Immediate) .build(), ] ); true }) .return_once(|_, _| Ok(ModifyDbClusterParameterGroupOutput::builder().build())); let scenario = AuroraScenario::new(mock_rds); scenario .update_auto_increment(10, 20) .await .expect("update auto increment"); } #[tokio::test] async fn test_scenario_update_auto_increment_error() { let mut mock_rds = MockRdsImpl::default(); mock_rds .expect_modify_db_cluster_parameter_group() .return_once(|_, _| { Err(SdkError::service_error( ModifyDBClusterParameterGroupError::unhandled(Box::new(Error::new( ErrorKind::Other, "modify_db_cluster_parameter_group_error", ))), Response::new(StatusCode::try_from(400).unwrap(), SdkBody::empty()), )) }); let scenario = AuroraScenario::new(mock_rds); let update = scenario.update_auto_increment(10, 20).await; assert_matches!(update, Err(ScenarioError { message, context: _}) if message == "Failed to modify cluster parameter group"); }
AWS SDK for .NET
nota

Tem mais sobre GitHub. Encontre o exemplo completo e saiba como configurar e executar no Repositório de exemplos de código da AWS.

/// <summary> /// Modify the specified integer parameters with new values from user input. /// </summary> /// <param name="groupName">The group name for the parameters.</param> /// <param name="parameters">The list of integer parameters to modify.</param> /// <param name="newValue">Optional int value to set for parameters.</param> /// <returns>The name of the group that was modified.</returns> public async Task<string> ModifyIntegerParametersInGroupAsync(string groupName, List<Parameter> parameters, int newValue = 0) { foreach (var p in parameters) { if (p.IsModifiable && p.DataType == "integer") { while (newValue == 0) { Console.WriteLine( $"Enter a new value for {p.ParameterName} from the allowed values {p.AllowedValues} "); var choice = Console.ReadLine(); int.TryParse(choice, out newValue); } p.ParameterValue = newValue.ToString(); } } var request = new ModifyDBClusterParameterGroupRequest { Parameters = parameters, DBClusterParameterGroupName = groupName, }; var result = await _amazonRDS.ModifyDBClusterParameterGroupAsync(request); return result.DBClusterParameterGroupName; }
PrivacidadeTermos do sitePreferências de cookies
© 2025, Amazon Web Services, Inc. ou suas afiliadas. Todos os direitos reservados.