Managing existing resources

How can I manage existing resources such as workflows or block-specs?

To manage any existing resource, like a workflow or block-spec, you would require the resource ID. If you are updating or creating a new version of the resource, you would also need the updated payload or configuration.

How do I obtain the ID and Configuration of the resource?

  1. To get the ID of an existing resource, you can use the list functions.

    1. Run the list function to get a complete list of all the resources.

    2. You can pass in any required filters to the function to get only limited resources in the list. For example, let’s say you want to get the ID for an image with the name - test, you can run the following command

      peak images list --name "test"
      
    3. Once you have the list, you can filter it out based on any required value to get the specific resource that you need.

  2. After getting the resource ID from the list, use the describe function to get the full details of the specific resource you wish to update.

  3. Once you have obtained the existing details of the resource and created an updated payload, you can use the update or similar function and provide it with the resource ID and the path to the payload file.

Now, let’s take an example of updating a webapp:

  • List available webapps:

    peak webapps list --page-number 1 --page-size 50 --name "example-webapp"
    
    {
        "pageCount": 1,
        "pageNumber": 1,
        "pageSize": 25,
        "webapps": [
            {
                "id": "12a34de5-d67f-4aa0-aebe-83c1474f0eaf",
                "name": "example-webapp",
                "status": "AVAILABLE",
                "createdAt": "2020-01-01T18:00:00.000Z",
                "createdBy": "someone@example.com",
                "updatedAt": "2020-01-01T18:00:00.000Z",
                "updatedBy": "someone@example.com",
                "tags": []
            }
        ],
        "webappsCount": 1
    }
    
  • Get details of the webapp you wish to update:

    peak webapps describe 12a34de5-d67f-4aa0-aebe-83c1474f0eaf
    

    This will return the details of the existing webapp, including its current configuration.

    {
        "id": "12a34de5-d67f-4aa0-aebe-83c1474f0eaf",
        "name": "example-webapp",
        "status": "AVAILABLE",
        "imageDetails": {
            "imageId": 1,
            "versionId": 1
        },
        "createdAt": "2020-01-01T18:00:00.000Z",
        "createdBy": "someone@example.com",
        "updatedAt": "2020-01-01T18:00:00.000Z",
        "updatedBy": "someone@example.com",
        "tags": []
    }
    
  • Create an updated payload in the desired format with the desired changes. For example, create a YAML file named webapp.yaml with the following content if you want to update the webapp via CLI.

    # webapp.yaml
    
    title: updated-webapp
    description: Updating the webapp
    imageDetails:
        imageId: 2
        versionId: 2
    
  • Update the existing webapp with the new configuration:

    peak webapps update 12a34de5-d67f-4aa0-aebe-83c1474f0eaf -v path/to/webapp.yaml