Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout repo
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: setup python 3
uses: actions/setup-python@v6
Expand All @@ -33,7 +33,7 @@ jobs:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12', '3.13']
steps:
- uses: actions/checkout@v5
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ jobs:
build-mode: none
steps:
- name: Checkout repository
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
build-mode: ${{ matrix.build-mode }}
queries: security-and-quality

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .github/workflows/dependency-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: 'Checkout repository'
uses: actions/checkout@v5
uses: actions/checkout@v6
- name: 'Dependency Review'
uses: actions/dependency-review-action@v4
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

# Check out merge commit
- name: Checkout PR
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
ref: ${{ inputs.sha }}
fetch-depth: 0
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: 'recursive'
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,15 @@ jobs:
steps:
- name: Clone Repository with SHA
if: ${{ inputs.sha != '' }}
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: 'recursive'
ref: ${{ inputs.sha }}

- name: Clone Repository without SHA
if: ${{ inputs.sha == '' }}
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: 'recursive'
Expand Down Expand Up @@ -97,7 +97,7 @@ jobs:

- name: Upload Test Report as Artifact
if: always()
uses: actions/upload-artifact@v4
uses: actions/upload-artifact@v6
with:
name: test-report-file
if-no-files-found: ignore
Expand All @@ -111,7 +111,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: 'recursive'
Expand Down Expand Up @@ -178,13 +178,13 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: 'recursive'

- name: Download test report
uses: actions/download-artifact@v5
uses: actions/download-artifact@v7
with:
name: test-report-file

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
steps:
-
name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6
-
name: Run Labeler
uses: crazy-max/ghaction-github-labeler@24d110aa46a59976b8a7f35518cb7f14f434c916
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/nightly-smoke-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
ref: dev

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
environment: pypi-release
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Setup Python
uses: actions/setup-python@v6
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release-cross-repo-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout linode_api4 repository
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: 'recursive'
Expand All @@ -30,7 +30,7 @@ jobs:
python-version: '3.10'

- name: Checkout ansible repo
uses: actions/checkout@v5
uses: actions/checkout@v6
with:
repository: linode/ansible_linode
path: .ansible/collections/ansible_collections/linode/cloud
Expand Down
5 changes: 4 additions & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Include all files under test/ directory in source distribution only
graft test

# Exclude Python bytecode
global-exclude *.pyc
include baked_version
global-exclude __pycache__
9 changes: 9 additions & 0 deletions docs/linode_api4/linode_client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ Includes methods for interacting with our Longview service.
:members:
:special-members:

LockGroup
^^^^^^^^^^^^^

Includes methods for interacting with our Lock service.

.. autoclass:: linode_api4.linode_client.LockGroup
:members:
:special-members:

NetworkingGroup
^^^^^^^^^^^^^^^

Expand Down
2 changes: 2 additions & 0 deletions linode_api4/groups/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@
from .database import *
from .domain import *
from .image import *
from .image_share_group import *
from .linode import *
from .lke import *
from .lke_tier import *
from .lock import *
from .longview import *
from .maintenance import *
from .monitor import *
Expand Down
142 changes: 142 additions & 0 deletions linode_api4/groups/image_share_group.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
from typing import Optional

from linode_api4.groups import Group
from linode_api4.objects import (
ImageShareGroup,
ImageShareGroupImagesToAdd,
ImageShareGroupToken,
)
from linode_api4.objects.base import _flatten_request_body_recursive
from linode_api4.util import drop_null_keys


class ImageShareGroupAPIGroup(Group):
"""
Collections related to Private Image Sharing.

NOTE: Private Image Sharing features are in beta and may not be generally available.
"""

def __call__(self, *filters):
"""
Retrieves a list of Image Share Groups created by the user (producer).
You can filter this query to retrieve only Image Share Groups
relevant to a specific query, for example::

filtered_share_groups = client.sharegroups(
ImageShareGroup.label == "my-label")

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-sharegroups

:param filters: Any number of filters to apply to this query.
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
for more details on filtering.

:returns: A list of Image Share Groups.
:rtype: PaginatedList of ImageShareGroup
"""
return self.client._get_and_filter(ImageShareGroup, *filters)

def sharegroups_by_image_id(self, image_id: str):
"""
Retrieves a list of Image Share Groups that share a specific Private Image.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-images-sharegroups-image

:param image_id: The ID of the Image to query for.
:type image_id: str

:returns: A list of Image Share Groups sharing the specified Image.
:rtype: PaginatedList of ImageShareGroup
"""
return self.client._get_and_filter(
ImageShareGroup, endpoint="/images/{}/sharegroups".format(image_id)
)

def tokens(self, *filters):
"""
Retrieves a list of Image Share Group Tokens created by the user (consumer).
You can filter this query to retrieve only Image Share Group Tokens
relevant to a specific query, for example::

filtered_share_group_tokens = client.sharegroups.tokens(
ImageShareGroupToken.label == "my-label")

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-user-tokens

:param filters: Any number of filters to apply to this query.
See :doc:`Filtering Collections</linode_api4/objects/filtering>`
for more details on filtering.

:returns: A list of Image Share Group Tokens.
:rtype: PaginatedList of ImageShareGroupToken
"""
return self.client._get_and_filter(ImageShareGroupToken, *filters)

def create_sharegroup(
self,
label: Optional[str] = None,
description: Optional[str] = None,
images: Optional[ImageShareGroupImagesToAdd] = None,
):
"""
Creates a new Image Share Group.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-sharegroups

:param label: The label for the resulting Image Share Group.
:type label: str
:param description: The description for the new Image Share Group.
:type description: str
:param images: A list of Images to share in the new Image Share Group, formatted in JSON.
:type images: Optional[ImageShareGroupImagesToAdd]

:returns: The new Image Share Group.
:rtype: ImageShareGroup
"""
params = {
"label": label,
"description": description,
}

if images:
params["images"] = images

result = self.client.post(
"/images/sharegroups",
data=_flatten_request_body_recursive(drop_null_keys(params)),
)

return ImageShareGroup(self.client, result["id"], result)

def create_token(
self, valid_for_sharegroup_uuid: str, label: Optional[str] = None
):
"""
Creates a new Image Share Group Token and returns the token value.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-sharegroup-tokens

:param valid_for_sharegroup_uuid: The UUID of the Image Share Group that this token will be valid for.
:type valid_for_sharegroup_uuid: Optional[str]
:param label: The label for the resulting Image Share Group Token.
:type label: str

:returns: The new Image Share Group Token object and the one-time use token itself.
:rtype: (ImageShareGroupToken, str)
"""
params = {"valid_for_sharegroup_uuid": valid_for_sharegroup_uuid}

if label:
params["label"] = label

result = self.client.post(
"/images/sharegroups/tokens",
data=_flatten_request_body_recursive(drop_null_keys(params)),
)

token_value = result.pop("token", None)
token_obj = ImageShareGroupToken(
self.client, result["token_uuid"], result
)
return token_obj, token_value
4 changes: 1 addition & 3 deletions linode_api4/groups/linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
NetworkInterface,
_expand_placement_group_assignment,
)
from linode_api4.objects.linode_interfaces import (
LinodeInterfaceOptions,
)
from linode_api4.objects.linode_interfaces import LinodeInterfaceOptions
from linode_api4.util import drop_null_keys


Expand Down
Loading
Loading