Webapps resource

Note: Only generic (EKS-based) webapps are supported when using SDK.

Import the webapps resource module and instantiate a webapps-service client

[ ]:
from peak.resources import webapps

webapp_client = webapps.get_client()

List all existing webapps(s) and iterate over them

[ ]:
webapps_list_iterator = webapp_client.list_webapps(
    status=["CREATING"],
    name="test",
)
webapps_list_iterated = next(webapps_list_iterator)

Prepare the payload and submit a new Webapp resource for creation

[ ]:
body = {
    "name": "webapp101",
    "title": "Hello from SDK",
    "description": "Hi there",
    "imageDetails": {"imageId": 123, "versionId": 100},
}

created_webapp = webapp_client.create_webapp(body)

## If versionId is not passed, webapp will be created using latest ready version of the image
body_with_latest_version = {
    "name": "webapp102",
    "title": "Hello from SDK",
    "description": "Hi there",
    "imageDetails": {"imageId": 123},
}

created_webapp_with_latest_version = webapp_client.create_webapp(body=body_with_latest_version)

Modify the payload and update the existing Webapp resource

[ ]:
updated_body = {
    "title": "Updated title",
    "description": "Updated Description",
    "imageDetails": {"imageId": 123, "versionId": 101},
}

updated_webapp = webapp_client.update_webapp(webapp_id="84a41de7-d67f-4aa0-aebe-83c1474f0eaf", body=updated_body)

## If versionId is not passed, webapp will be updated using latest ready version of the image
updated_body_with_latest_version = {
    "title": "Updated title",
    "description": "Updated Description",
    "imageDetails": {"imageId": 123},
}

updated_webapp_with_latest_version = webapp_client.update_webapp(body=updated_body_with_latest_version)

Create or update a Webapp resource

[ ]:
body = {
    "name": "webapp101",
    "title": "Hello from SDK",
    "description": "Hi there",
    "imageDetails": {"imageId": 123, "versionId": 100},
}

created_webapp = webapp_client.create_or_update_webapp(body)

## If webapp exists, it will be updated
body = {
    "name": "webapp101",
    "title": "Hello from SDK",
    "description": "Hi there",
    "imageDetails": {"imageId": 123},
}

updated_webapp = webapp_client.create_or_update_webapp(body=body)

Delete an existing Webapp resource

[ ]:
webapp_client.delete_webapp(webapp_id="some-id")

Describe an existing Webapp resource

[ ]:
webapp_client.describe_webapp(webapp_id="84a41de7-d67f-4aa0-aebe-83c1474f0eaf")