pydo.apps.update()

Description

Update an existing app by submitting a new app specification. For documentation on app specifications (AppSpec objects), please refer to the product documentation.

Parameters

Name Type Required Description Default Value
id string True The ID of the app
body JSON or IO[bytes] True

Request Sample

import os
from pydo import Client

client = Client(token=os.environ.get("DIGITALOCEAN_TOKEN"))
req = {
"spec": {
    "name": "web-app-01",
    "region": "nyc",
    "domains": [
        {
            "domain": "app.example.com",
            "type": "DEFAULT",
            "wildcard": True,
            "zone": "example.com",
            "minimum_tls_version": "1.3",
        }
    ],
    "services": [],
    "static_sites": [
        {
            "cors": {
                "allow_origins": [
                    {"exact": "https://www.example.com"},
                    {"regex": "^.*example.com"},
                ],
                "allow_methods": [
                    "GET",
                    "OPTIONS",
                    "POST",
                    "PUT",
                    "PATCH",
                    "DELETE",
                ],
                "allow_headers": ["Content-Type", "X-Custom-Header"],
                "expose_headers": ["Content-Encoding", "X-Custom-Header"],
                "max_age": "5h30m",
                "allow_credentials": False,
            },
            "routes": [{"path": "/api", "preserve_path_prefix": True}],
        }
    ],
    "jobs": [
        {
            "name": "api",
            "gitlab": {
                "branch": "main",
                "deploy_on_push": True,
                "repo": "digitalocean/sample-golang",
            },
            "image": {
                "registry": "registry.hub.docker.com",
                "registry_type": "DOCR",
                "repository": "origin/master",
                "tag": "latest",
            },
            "dockerfile_path": "path/to/Dockerfile",
            "build_command": "npm run build",
            "run_command": "bin/api",
            "source_dir": "path/to/dir",
            "envs": [
                {
                    "key": "BASE_URL",
                    "scope": "BUILD_TIME",
                    "type": "GENERAL",
                    "value": "http://example.com",
                }
            ],
            "environment_slug": "node-js",
            "log_destinations": {
                "name": "my_log_destination",
                "papertrail": {
                    "endpoint": "https://mypapertrailendpoint.com"
                },
                "datadog": {
                    "endpoint": "https://mydatadogendpoint.com",
                    "api_key": "abcdefghijklmnopqrstuvwxyz0123456789",
                },
                "logtail": {
                    "token": "abcdefghijklmnopqrstuvwxyz0123456789"
                },
               "open_search": {
                    "endpoint": "https://myopensearchendpoint.com:9300"
                    "index_name": "logs"
                    "basic_auth": {
                        "user": "doadmin",
                        "password": "password"
                    }
                },
            },
            "instance_count": 2,
            "instance_size_slug": "apps-s-1vcpu-0.5gb",
            "kind": "PRE_DEPLOY",
        }
    ],
    "workers": [
        {
            "name": "api",
            "gitlab": {
                "branch": "main",
                "deploy_on_push": True,
                "repo": "digitalocean/sample-golang",
            },
            "image": {
                "registry": "registry.hub.docker.com",
                "registry_type": "DOCR",
                "repository": "origin/master",
                "tag": "latest",
            },
            "dockerfile_path": "path/to/Dockerfile",
            "build_command": "npm run build",
            "run_command": "bin/api",
            "source_dir": "path/to/dir",
            "envs": [
                {
                    "key": "BASE_URL",
                    "scope": "BUILD_TIME",
                    "type": "GENERAL",
                    "value": "http://example.com",
                }
            ],
            "environment_slug": "node-js",
            "log_destinations": {
                "name": "my_log_destination",
                "papertrail": {
                    "endpoint": "https://mypapertrailendpoint.com"
                },
                "datadog": {
                    "endpoint": "https://mydatadogendpoint.com",
                    "api_key": "abcdefghijklmnopqrstuvwxyz0123456789",
                },
                "logtail": {
                    "token": "abcdefghijklmnopqrstuvwxyz0123456789"
                },
               "open_search": {
                    "endpoint": "https://myopensearchendpoint.com:9300"
                    "index_name": "logs"
                    "basic_auth": {
                        "user": "doadmin",
                        "password": "password"
                    }
                },
            },
            "instance_count": 2,
            "instance_size_slug": "apps-s-1vcpu-0.5gb",
        }
    ],
    "functions": [
        {
            "cors": {
                "allow_origins": [
                    {"exact": "https://www.example.com"},
                    {"regex": "^.*example.com"},
                ],
                "allow_methods": [
                    "GET",
                    "OPTIONS",
                    "POST",
                    "PUT",
                    "PATCH",
                    "DELETE",
                ],
                "allow_headers": ["Content-Type", "X-Custom-Header"],
                "expose_headers": ["Content-Encoding", "X-Custom-Header"],
                "max_age": "5h30m",
                "allow_credentials": False,
            },
            "routes": [{"path": "/api", "preserve_path_prefix": True}],
            "name": "api",
            "source_dir": "path/to/dir",
            "alerts": [
                {
                    "rule": "CPU_UTILIZATION",
                    "disabled": False,
                    "operator": "GREATER_THAN",
                    "value": 2.32,
                    "window": "FIVE_MINUTES",
                }
            ],
            "envs": [
                {
                    "key": "BASE_URL",
                    "scope": "BUILD_TIME",
                    "type": "GENERAL",
                    "value": "http://example.com",
                }
            ],
            "gitlab": {
                "branch": "main",
                "deploy_on_push": True,
                "repo": "digitalocean/sample-golang",
            },
            "log_destinations": {
                "name": "my_log_destination",
                "papertrail": {
                    "endpoint": "https://mypapertrailendpoint.com"
                },
                "datadog": {
                    "endpoint": "https://mydatadogendpoint.com",
                    "api_key": "abcdefghijklmnopqrstuvwxyz0123456789",
                },
                "logtail": {
                    "token": "abcdefghijklmnopqrstuvwxyz0123456789"
                },
               "open_search": {
                    "endpoint": "https://myopensearchendpoint.com:9300"
                    "index_name": "logs"
                    "basic_auth": {
                        "user": "doadmin",
                        "password": "password"
                    }
                },
            },
        }
    ],
    "databases": [
        {
            "cluster_name": "cluster_name",
            "db_name": "my_db",
            "db_user": "superuser",
            "engine": "PG",
            "name": "prod-db",
            "production": True,
            "version": "12",
        }
    ],
}
}
update_resp = client.apps.update(id="bb245ba", body=req)

Responses

See the API spec for this endpoint to view additional detail on responses, headers, parameters, and more.

A JSON object of the updated app

Click to expand an example response for app.
{
  "value": {
    "app": {
      "id": "c2a93513-8d9b-4223-9d61-5e7272c81cf5",
      "owner_uuid": "a4e16f25-cdd1-4483-b246-d77f283c9209",
      "spec": {
        "name": "sample-golang",
        "services": [
          {
            "name": "web",
            "github": {
              "repo": "ChiefMateStarbuck/sample-golang",
              "branch": "main"
            },
            "run_command": "bin/sample-golang",
            "environment_slug": "go",
            "instance_size_slug": "apps-s-1vcpu-0.5gb",
            "instance_count": 1,
            "http_port": 8080,
            "routes": [
              {
                "path": "/"
              }
            ]
          }
        ],
        "region": "ams",
        "domains": [
          {
            "domain": "sample-golang.example.com",
            "zone": "example.com",
            "minimum_tls_version": "1.3"
          }
        ]
      },
      "default_ingress": "https://sample-golang-zyhgn.ondigitalocean.app",
      "created_at": "2021-02-10T16:45:14Z",
      "updated_at": "2021-02-10T17:06:56Z",
      "active_deployment": {
        "id": "991dfa59-6a23-459f-86d6-67dfa2c6f1e3",
        "spec": {
          "name": "sample-golang",
          "services": [
            {
              "name": "web",
              "github": {
                "repo": "ChiefMateStarbuck/sample-golang",
                "branch": "main"
              },
              "run_command": "bin/sample-golang",
              "environment_slug": "go",
              "instance_size_slug": "apps-s-1vcpu-0.5gb",
              "instance_count": 1,
              "http_port": 8080,
              "routes": [
                {
                  "path": "/"
                }
              ]
            }
          ],
          "region": "ams",
          "domains": [
            {
              "domain": "sample-golang.example.com",
              "zone": "example.com",
              "minimum_tls_version": "1.3"
            }
          ]
        },
        "services": [
          {
            "name": "web",
            "source_commit_hash": "db6936cb46047c576962962eed81ad52c21f35d7"
          }
        ],
        "phase_last_updated_at": "2021-02-10T17:06:53Z",
        "created_at": "2021-02-10T17:05:30Z",
        "updated_at": "2021-02-10T17:06:53Z",
        "cause": "manual",
        "progress": {
          "success_steps": 6,
          "total_steps": 6,
          "steps": [
            {
              "name": "build",
              "status": "SUCCESS",
              "steps": [
                {
                  "name": "initialize",
                  "status": "SUCCESS",
                  "started_at": "2021-02-10T17:05:35.572347485Z",
                  "ended_at": "2021-02-10T17:05:36.093995229Z"
                },
                {
                  "name": "components",
                  "status": "SUCCESS",
                  "steps": [
                    {
                      "name": "web",
                      "status": "SUCCESS",
                      "component_name": "web",
                      "message_base": "Building service"
                    }
                  ],
                  "started_at": "2021-02-10T17:05:36.094015928Z",
                  "ended_at": "2021-02-10T17:06:19.461737040Z"
                }
              ],
              "started_at": "2021-02-10T17:05:35.572287990Z",
              "ended_at": "2021-02-10T17:06:19.807834070Z"
            },
            {
              "name": "deploy",
              "status": "SUCCESS",
              "steps": [
                {
                  "name": "initialize",
                  "status": "SUCCESS",
                  "started_at": "2021-02-10T17:06:25.143957508Z",
                  "ended_at": "2021-02-10T17:06:26.120343872Z"
                },
                {
                  "name": "components",
                  "status": "SUCCESS",
                  "steps": [
                    {
                      "name": "web",
                      "status": "SUCCESS",
                      "steps": [
                        {
                          "name": "deploy",
                          "status": "SUCCESS",
                          "component_name": "web",
                          "message_base": "Deploying service"
                        },
                        {
                          "name": "wait",
                          "status": "SUCCESS",
                          "component_name": "web",
                          "message_base": "Waiting for service"
                        }
                      ],
                      "component_name": "web"
                    }
                  ],
                  "started_at": "2021-02-10T17:06:26.120385561Z",
                  "ended_at": "2021-02-10T17:06:50.029695913Z"
                },
                {
                  "name": "finalize",
                  "status": "SUCCESS",
                  "started_at": "2021-02-10T17:06:50.348459495Z",
                  "ended_at": "2021-02-10T17:06:53.404065961Z"
                }
              ],
              "started_at": "2021-02-10T17:06:25.143932418Z",
              "ended_at": "2021-02-10T17:06:53.404104185Z"
            }
          ]
        },
        "phase": "ACTIVE",
        "tier_slug": "basic"
      },
      "last_deployment_created_at": "2021-02-10T17:05:30Z",
      "live_url": "https://sample-golang-zyhgn.ondigitalocean.app",
      "pending_deployment": {
        "id": "3aa4d20e-5527-4c00-b496-601fbd22520a",
        "spec": {
          "name": "sample-php",
          "services": [
            {
              "name": "sample-php",
              "git": {
                "repo_clone_url": "https://github.com/digitalocean/sample-php.git",
                "branch": "main"
              },
              "run_command": "heroku-php-apache2",
              "environment_slug": "php",
              "instance_size_slug": "apps-s-1vcpu-0.5gb",
              "instance_count": 1,
              "http_port": 8080,
              "routes": [
                {
                  "path": "/"
                }
              ]
            }
          ],
          "region": "fra",
          "domains": [
            {
              "domain": "sample-php.example.com",
              "type": "PRIMARY",
              "zone": "example.com",
              "minimum_tls_version": "1.3"
            }
          ]
        }
      },
      "region": {
        "slug": "ams",
        "label": "Amsterdam",
        "flag": "netherlands",
        "continent": "Europe",
        "data_centers": [
          "ams3"
        ]
      },
      "tier_slug": "basic",
      "live_url_base": "https://sample-golang-zyhgn.ondigitalocean.app",
      "live_domain": "sample-golang-zyhgn.ondigitalocean.app",
      "project_id": "88b72d1a-b78a-4d9f-9090-b53c4399073f",
      "domains": [
        {
          "id": "e206c64e-a1a3-11ed-9e6e-9b7b6dc9a52b",
          "phase": "CONFIGURING",
          "spec": {
            "domain": "sample-golang.example.com",
            "type": "PRIMARY",
            "zone": "example.com",
            "minimum_tls_version": "1.3"
          },
          "rotate_validation_records": false,
          "certificate_expires_at": "2024-01-29T23:59:59Z",
          "progress": {
            "steps": [
              {
                "ended_at": "0001-01-01T00:00:00Z",
                "name": "default-ingress-ready",
                "started_at": "2023-01-30T22:15:45.021896292Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "0001-01-01T00:00:00Z",
                "name": "ensure-zone",
                "started_at": "2023-01-30T22:15:45.022017004Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "2023-01-30T15:42:28.50752065Z",
                "name": "ensure-ns-records",
                "started_at": "2023-01-30T22:15:45.025567874Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "0001-01-01T00:00:00Z",
                "name": "verify-nameservers",
                "started_at": "2023-01-30T22:15:45.033591906Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "0001-01-01T00:00:00Z",
                "name": "ensure-record",
                "started_at": "2023-01-30T22:15:45.156750604Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "2023-01-30T15:43:30.258626422Z",
                "name": "ensure-alias-record",
                "started_at": "2023-01-30T22:15:45.165933869Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "2023-01-30T15:43:30.258808279Z",
                "name": "ensure-wildcard-record",
                "started_at": "2023-01-30T22:15:45.166093422Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "0001-01-01T00:00:00Z",
                "name": "verify-cname",
                "started_at": "2023-01-30T22:15:45.166205559Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "2023-01-30T15:43:30.475903785Z",
                "name": "ensure-ssl-txt-record-saved",
                "started_at": "2023-01-30T22:15:45.295237186Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "2023-01-30T15:43:30.476017236Z",
                "name": "ensure-ssl-txt-record",
                "started_at": "2023-01-30T22:15:45.295315291Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "2023-01-30T15:43:30.476094058Z",
                "name": "ensure-renewal-email",
                "started_at": "2023-01-30T22:15:45.295374087Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "0001-01-01T00:00:00Z",
                "name": "ensure-CA-authorization",
                "started_at": "2023-01-30T22:15:45.295428101Z",
                "status": "SUCCESS"
              },
              {
                "ended_at": "0001-01-01T00:00:00Z",
                "name": "ensure-certificate",
                "started_at": "2023-01-30T22:15:45.978756406Z",
                "status": "RUNNING"
              },
              {
                "ended_at": "0001-01-01T00:00:00",
                "name": "create-deployment",
                "started_at": "0001-01-01T00:00:00Z",
                "status": "PENDING"
              },
              {
                "ended_at": "0001-01-01T00:00:00",
                "name": "configuration-alert",
                "started_at": "0001-01-01T00:00:00",
                "status": "PENDING"
              }
            ]
          }
        }
      ],
      "dedicated_ips": [
        {
          "ip": "192.168.1.1",
          "id": "c24d8f48-3bc4-49f5-8ca0-58e8164427ac",
          "status": "ASSIGNED"
        },
        {
          "ip": "192.168.1.2",
          "id": "4768fb15-2837-4dda-9be5-3951df4bc3d0",
          "status": "ASSIGNED"
        }
      ]
    }
  }
}

Unauthorized

Click to expand an example response.
{
  "id": "unauthorized",
  "message": "Unable to authenticate you."
}

The resource was not found.

Click to expand an example response.
{
  "id": "not_found",
  "message": "The resource you requested could not be found."
}

API Rate limit exceeded

Click to expand an example response.
{
  "id": "too_many_requests",
  "message": "API Rate limit exceeded."
}

Server error.

Click to expand an example response.
{
  "id": "server_error",
  "message": "Unexpected server-side error"
}

Unexpected error

Click to expand an example response.
{
  "id": "example_error",
  "message": "some error message"
}