Edit scenario

Prev Next

Available in Classic and VPC

Change the settings of a deployment scenario.

Request

This section describes the request format. The method and URI are as follows:

Method URI
PATCH /api/v1/project/{projectId}/stage/{stageId}/scenario/{scenarioId}

Request headers

For information about the headers common to all SourceDeploy APIs, see SourceDeploy request headers.

Request path parameters

You can use the following path parameters with your request:

Field Type Required Description
projectId String Required Project ID
stageId String Required Deployment stage ID
scenarioId String Required Deployment scenario ID

Request body

You can include the following data in the body of your request:

Field Type Required Description
description String Optional Deployment scenario description
config Object Optional Deployment target settings

TScenarioServer

The following describes TScenarioServer.

Field Type Required Description
strategy String Required Deployment strategy
  • normal: default (valid value)
sequence Boolean Optional Sequential deployment
  • true (default) | false
    • true: sequential deployment
    • false: simultaneous deployment
file Object Required Deployment file information
file.type String Required Deployment file location
  • ObjectStorage | SourceBuild | later
    • ObjectStorage: Object Storage
    • SourceBuild: SourceBuild
    • later: Set up later.
file.ObjectStorage Object Conditional Object Storage information
  • If file.type is ObjectStorage, it must be entered including sub-information.
file.ObjectStorage.bucket String Conditional Bucket name
file.ObjectStorage.object String Conditional File name
file.SourceBuild Object Conditional SourceBuild information
  • If file.type is SourceBuild, it must be entered including sub-information.
file.SourceBuild.id Number Conditional Build project ID
rollback Boolean Required Whether to use rollback upon deployment failure
  • true | false
    • true: use
    • false: not use
cmd.pre Array Optional List of pre-deployment execution commands
cmd.deploy Array Optional List of file deployment paths
cmd.post Array Optional List of post-deployment execution commands

pre

The following describes pre.

Field Type Required Description
user String Optional Account
cmd String Optional Execution command

deploy

The following describes deploy.

Field Type Required Description
sourcePath String Optional Source file path
deployPath String Optional Deployment path

post

The following describes post.

Field Type Required Description
user String Optional Account
cmd String Optional Execution command

TScenarioAutoScalingGroup

The following describes TScenarioAutoScalingGroup.

Field Type Required Description
strategy String Required Deployment strategy
  • normal | blueGreen
    • normal: default
    • blueGreen: blue/green
sequence Boolean Optional Sequential deployment
  • true (default) | false
    • true: sequential deployment
    • false: simultaneous deployment
file Object Required Deployment file information
file.type String Required Deployment file location
  • ObjectStorage | SourceBuild | later
    • ObjectStorage: Object Storage
    • SourceBuild: SourceBuild
    • later: Set up later.
file.ObjectStorage Object Conditional Object Storage information
  • If file.type is ObjectStorage, it must be entered including sub-information.
file.ObjectStorage.bucket String Conditional Bucket name
file.ObjectStorage.object String Conditional File name
file.SourceBuild Object Conditional SourceBuild information
  • If file.type is SourceBuild, it must be entered including sub-information.
file.SourceBuild.id Number Conditional Build project ID
rollback Boolean Required Whether to use rollback upon deployment failure
  • true | false
    • true: use
    • false: not use
cmd.pre Array Optional List of pre-deployment execution commands
cmd.deploy Array Optional List of file deployment paths
cmd.post Array Optional List of post-deployment execution commands
loadBalancer Object Conditional Load balancer information
  • If strategy is blueGreen, it must be entered including sub-information.
loadBalancer.loadBalancerTargetGroupNo Number Conditional Load balancer target group ID
loadBalancer.deleteAsg Boolean Conditional Whether to delete existing Auto Scaling group
  • true | false
    • true: delete and terminate
    • false: maintain
loadBalancer.deleteServer Boolean Conditional Whether to terminate servers in Auto Scaling group
  • true | false
    • true: terminate
    • false: maintain
  • If loadBalancer.deleteAsg is true, enter true.

pre

The following describes pre.

Field Type Required Description
user String Optional Account
cmd String Optional Execution command

deploy

The following describes deploy.

Field Type Required Description
sourcePath String Optional Source file path
deployPath String Optional Deployment path

post

The following describes post.

Field Type Required Description
user String Optional Account
cmd String Optional Execution command

TScenarioKubernetesService

The following describes TScenarioKubernetesService.

Field Type Required Description
strategy String Required Deployment strategy
  • rolling | blueGreen | canary
    • rolling: rolling
    • blueGreen: blue/green
    • canary: canary
manifest Object Required Manifest information
manifest.type String Required Manifest file repository
  • SourceCommit (valid value)
manifest.repository String Required Repository name
manifest.branch String Required Branch name
manifest.path Array Required File location list
canaryConfig Object Conditional Canary analysis settings
  • If strategy is canary, it must be entered including sub-information.
canaryConfig.analysisType String Conditional Canary analysis method
  • manual | auto
    • manual: manual
    • auto: automatic
canaryConfig.canaryCount Number Conditional Number of baseline and canary pods
  • 1-10
canaryConfig.timeout Number Conditional Timeout (minute)
  • 1-360
  • Maximum decision time for canary deployment/cancellation
  • Required if canaryConfig.analysisType is manual
canaryConfig.prometheus String Conditional Prometheus URL
  • Required if canaryConfig.analysisType is auto
canaryConfig.env Object Conditional Analysis environment variable
  • If canaryConfig.analysisType is auto, it must be entered including sub-information.
canaryConfig.env.baseline String Conditional Analysis environment variable: baseline name
  • Enter up to 62 characters by combining English letters, numbers, and special characters "-" and "_".
canaryConfig.env.canary String Conditional Analysis environment variable: canary name
  • Enter up to 62 characters by combining English letters, numbers, and special characters "-" and "_".
canaryConfig.metrics Array Conditional Metric settings list
  • If canaryConfig.analysisType is auto, it must be entered including sub-information.
canaryConfig.analysisConfig Object Conditional Analysis settings
  • If canaryConfig.analysisType is auto, it must be entered including sub-information.
canaryConfig.analysisConfig.duration Number Conditional Analysis time (minute)
  • 10-360
canaryConfig.analysisConfig.delay Number Conditional Analysis delay time (minute)
  • 0-60
canaryConfig.analysisConfig.interval Number Conditional Analysis cycle (minute)
  • 1-360
  • Must be less than the analysis time.
canaryConfig.analysisConfig.step Number Conditional Metric collection cycle (second)
  • 10-360
canaryConfig.passScore Number Conditional Analysis success score
  • 1-100
  • Required if canaryConfig.analysisType is auto

metrics

The following describes metrics.

Field Type Required Description
name String Conditional Metric name
  • Enter 1-100 characters by combining English letters, numbers, and special characters "-" and "_".
successCriteria String Conditional Success criteria
  • base | canary
    • base: baseline > canary
    • canary: baseline < canary
queryType String Conditional Query type
  • default | promQL
weight Number Conditional Metric weight
  • 1-100
  • The weighted sum of the entered metrics must total 100.
metric String Conditional Metric value
  • Enter the metric set up in Prometheus.
  • Required if queryType is default
filter String Conditional Filter value
  • Enter label conditions.
  • Required if queryType is default
query String Conditional Query
  • Required if queryType is promQL

TScenarioObjectStorage

The following describes TScenarioObjectStorage.

Field Type Required Description
file Object Required Deployment file information
file.type String Required Deployment file location
  • ObjectStorage | SourceBuild | later
    • ObjectStorage: Object Storage
    • SourceBuild: SourceBuild
    • later: Set up later.
file.ObjectStorage Object Conditional Object Storage information
  • If file.type is ObjectStorage, it must be entered including sub-information.
file.ObjectStorage.bucket String Conditional Bucket name
file.ObjectStorage.object String Conditional File name
file.SourceBuild Object Conditional SourceBuild information
  • If file.type is SourceBuild, it must be entered including sub-information.
file.SourceBuild.id Number Conditional Build project ID
path Array Optional List of file deployment paths

path

The following describes path.

Field Type Required Description
sourcePath String Optional Source file path
deployPath String Optional Deployment path

Request example

The request example is as follows:

curl --location --request PATCH 'https://vpcsourcedeploy.apigw.ntruss.com/api/v1/project/2***/stage/3***/scenario/2***' \
--header 'x-ncp-apigw-timestamp: {Timestamp}' \
--header 'x-ncp-iam-access-key: {Access Key}' \
--header 'x-ncp-apigw-signature-v2: {API Gateway Signature}' \
--header 'Content-Type: application/json' \
--data '{
    "description": "test Scenario 2",
    "config": {
        "strategy": "normal",
        "sequence": true,
        "file": {
            "type": "SourceBuild",
            "SourceBuild": {
                "id": "20***"
            }
        },
        "rollback": true,
        "cmd": {
            "pre": [
                {
                    "user": "root",
                    "cmd": "mv logs/app.log logs/app_$(date +%s).log"
                }
            ],
            "deploy": [
                {
                    "sourcePath": "/main.py",
                    "deployPath": "/home/root/"
                }
            ],
            "post": [
                {
                    "user": "root",
                    "cmd": "nohup python3 main.py > logs/app.log 2>&1 &"
                }
            ]
        }
    }
}'

Response

This section describes the response format.

Response body

The response body includes the following data:

Field Type Required Description
result Object - Response result
result.id Number - Deployment scenario ID
result.name String - Deployment scenario name

Response status codes

For information about the HTTP status codes common to all SourceDeploy APIs, see SourceDeploy response status codes.

Response example

The response example is as follows:

{
    "result": {
        "id": 2***,
        "name": "testScenario2"
    }
}