linode / linode_api4-python

Official Python bindings for the Linode API
https://linode-api4.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
135 stars 75 forks source link

new: Support Image Gen2 functionalities #428

Closed yec-akamai closed 2 months ago

yec-akamai commented 2 months ago

📝 Description

Support the new image fields, including tags, total_size, regions. Support image replication.

✔️ How to Test

Unite test:

make testunit

Before running the integration test, you'll need to set up these environment variables:

export LINODE_API_URL=https://.../v4
export LINODE_API_CA=$PWD/cacert.pem
export LINODE_TOKEN=...

Integration test:

make testint TEST_SUITE=linode_client
make testint TEST_SUITE=image TEST_CASE=test_image_create_upload
make testint TEST_SUITE=image TEST_CASE=test_get_image

# replication is not functional yet
# make testint TEST_SUITE=image TEST_CASE=test_image_replication

Manual Test

  1. In a sandbox environment, run the following to create an image with tags:
    
    import os
    from linode_api4 import LinodeClient

client = LinodeClient( os.getenv("LINODE_TOKEN"), base_url="https://.../v4", ca_path=".../CA.pem", )

linode, _ = client.linode.instance_create( "g6-nanode-1", "us-east", label="test-image-gen2", image="linode/alpine3.19", )

image = client.image_create( disk=linode.disks[0].id, label="image-gen-2", description="Test", tags=["test", "image-gen2"] )

print(image.tags) print(image.total_size)

regions is expected to be empty here since it's not properly functional yet

print(image.regions)

linode.delete() image.delete()


2. Observe that new fields tags, total_size, and regions are populated.