# This is an automatically generated code sample.
# To make this code sample work in your Oracle Cloud tenancy,
# please replace the values for any parameters whose current values do not fit
# your use case (such as resource IDs, strings containing ‘EXAMPLE’ or ‘unique_id’, and
# boolean, number, and enum parameters with values not fitting your use case).

require 'oci'

# Create a default config using DEFAULT profile in default location
# Refer to https://docs.cloud.oracle.com/en-us/iaas/Content/API/Concepts/sdkconfig.htm#SDK_and_CLI_Configuration_File for more info
config = OCI::ConfigFileLoader.load_config

# Initialize service client with default config file
devops_client = OCI::Devops::DevopsClient.new(config: config)

# Send the request to service, some parameters are not required, see API doc for more info
create_deploy_stage_response =
  devops_client.create_deploy_stage(
    OCI::Devops::Models::CreateComputeInstanceGroupDeployStageDetails.new(
      deploy_stage_type: 'COMPUTE_INSTANCE_GROUP_ROLLING_DEPLOYMENT',
      deploy_pipeline_id:
        'ocid1.test.oc1..<unique_ID>EXAMPLE-deployPipelineId-Value',
      deploy_stage_predecessor_collection:
        OCI::Devops::Models::DeployStagePredecessorCollection.new(
          items: [
            OCI::Devops::Models::DeployStagePredecessor.new(
              id: 'ocid1.test.oc1..<unique_ID>EXAMPLE-id-Value'
            )
          ]
        ),
      compute_instance_group_deploy_environment_id:
        'ocid1.test.oc1..<unique_ID>EXAMPLE-computeInstanceGroupDeployEnvironmentId-Value',
      deployment_spec_deploy_artifact_id:
        'ocid1.test.oc1..<unique_ID>EXAMPLE-deploymentSpecDeployArtifactId-Value',
      rollout_policy:
        OCI::Devops::Models::ComputeInstanceGroupLinearRolloutPolicyByPercentage
          .new(
          policy_type:
            'COMPUTE_INSTANCE_GROUP_LINEAR_ROLLOUT_POLICY_BY_PERCENTAGE',
          batch_percentage: 747,
          batch_delay_in_seconds: 1876
        ),
      description: 'EXAMPLE-description-Value',
      display_name: 'EXAMPLE-displayName-Value',
      freeform_tags: {
        'EXAMPLE_KEY_eUgd2' => 'EXAMPLE_VALUE_BIfFAiAzxnVAQbsF5Wa3'
      },
      defined_tags: {
        'EXAMPLE_KEY_hzfR3' => { 'EXAMPLE_KEY_Hiok4' => 'EXAMPLE--Value' }
      },
      deploy_artifact_ids: %w[EXAMPLE--Value],
      rollback_policy:
        OCI::Devops::Models::AutomatedDeployStageRollbackPolicy.new(
          policy_type: 'AUTOMATED_STAGE_ROLLBACK_POLICY'
        ),
      failure_policy:
        OCI::Devops::Models::ComputeInstanceGroupFailurePolicyByCount.new(
          policy_type: 'COMPUTE_INSTANCE_GROUP_FAILURE_POLICY_BY_COUNT',
          failure_count: 944
        ),
      load_balancer_config:
        OCI::Devops::Models::LoadBalancerConfig.new(
          load_balancer_id:
            'ocid1.test.oc1..<unique_ID>EXAMPLE-loadBalancerId-Value',
          listener_name: 'EXAMPLE-listenerName-Value',
          backend_port: 42_778
        )
    )
  )

# Get the data from response
puts "#{create_deploy_stage_response.data}"