Skip to content
Open
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: 0 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,3 @@
**What are the steps to reproduce the issue or verify the changes?**

**How do I run the relevant unit/integration tests?**

## 📷 Preview

**If applicable, include a screenshot or code snippet of this change. Otherwise, please remove this section.**
10 changes: 9 additions & 1 deletion .github/workflows/e2e-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ on:
pull_request_number:
description: 'The number of the PR.'
required: false
test_report_upload:
description: 'Indicates whether to upload the test report to object storage. Defaults to "false"'
required: false
default: 'false'
type: choice
options:
- 'true'
- 'false'

name: PR E2E Tests

Expand Down Expand Up @@ -101,7 +109,7 @@ jobs:
LINODE_TOKEN: ${{ secrets.LINODE_TOKEN }}

- name: Upload test results
if: always()
if: always() && github.repository == 'linode/linode_api4-python' && (github.event_name == 'pull_request' || (github.event_name == 'workflow_dispatch' && inputs.test_report_upload == 'true'))
run: |
filename=$(ls | grep -E '^[0-9]{12}_sdk_test_report\.xml$')
python3 e2e_scripts/tod_scripts/xml_to_obj_storage/scripts/add_gha_info_to_xml.py \
Expand Down
13 changes: 11 additions & 2 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ on:
options:
- 'true'
- 'false'
test_report_upload:
description: 'Indicates whether to upload the test report to object storage. Defaults to "false"'
type: choice
required: false
default: 'false'
options:
- 'true'
- 'false'
push:
branches:
- main
Expand Down Expand Up @@ -172,7 +180,8 @@ jobs:
process-upload-report:
runs-on: ubuntu-latest
needs: [integration-tests]
if: always() && github.repository == 'linode/linode_api4-python' # Run even if integration tests fail and only on main repository
# Run even if integration tests fail on main repository AND push event OR test_report_upload is true in case of manual run
if: always() && github.repository == 'linode/linode_api4-python' && (github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.test_report_upload == 'true'))
outputs:
summary: ${{ steps.set-test-summary.outputs.summary }}

Expand Down Expand Up @@ -271,4 +280,4 @@ jobs:
payload: |
channel: ${{ secrets.SLACK_CHANNEL_ID }}
thread_ts: "${{ steps.main_message.outputs.ts }}"
text: "${{ needs.process-upload-report.outputs.summary }}"
text: "${{ needs.process-upload-report.outputs.summary }}"
2 changes: 0 additions & 2 deletions linode_api4/groups/linode.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,8 +335,6 @@ def instance_create(
:type network_helper: bool
:param maintenance_policy: The slug of the maintenance policy to apply during maintenance.
If not provided, the default policy (linode/migrate) will be applied.
NOTE: This field is in beta and may only
function if base_url is set to `https://api.linode.com/v4beta`.
:type maintenance_policy: str

:returns: A new Instance object, or a tuple containing the new Instance and
Expand Down
11 changes: 10 additions & 1 deletion linode_api4/groups/lke.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ def cluster_create(
self,
region,
label,
node_pools,
kube_version,
node_pools: Optional[list] = None,
control_plane: Union[
LKEClusterControlPlaneOptions, Dict[str, Any]
] = None,
Expand Down Expand Up @@ -119,6 +119,15 @@ def cluster_create(
:returns: The new LKE Cluster
:rtype: LKECluster
"""
if node_pools is None:
node_pools = []

if len(node_pools) == 0 and (
tier is None or tier.lower() != "enterprise"
):
raise ValueError(
"LKE standard clusters must have at least one node pool."
)

params = {
"label": label,
Expand Down
2 changes: 0 additions & 2 deletions linode_api4/groups/maintenance.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ class MaintenanceGroup(Group):

def maintenance_policies(self):
"""
.. note:: This endpoint is in beta. This will only function if base_url is set to `https://api.linode.com/v4beta`.

Returns a collection of MaintenancePolicy objects representing
available maintenance policies that can be applied to Linodes

Expand Down
2 changes: 1 addition & 1 deletion linode_api4/objects/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .dbase import DerivedBase
from .serializable import JSONObject
from .filtering import and_, or_
from .region import Region
from .region import Region, Capability
from .image import Image
from .linode import *
from .linode_interfaces import *
Expand Down
6 changes: 2 additions & 4 deletions linode_api4/objects/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,7 @@ class AccountSettings(Base):
"object_storage": Property(),
"backups_enabled": Property(mutable=True),
"interfaces_for_new_linodes": Property(mutable=True),
"maintenance_policy": Property(
mutable=True
), # Note: This field is only available when using v4beta.
"maintenance_policy": Property(mutable=True),
}


Expand Down Expand Up @@ -249,7 +247,7 @@ class Event(Base):
"duration": Property(),
"secondary_entity": Property(),
"message": Property(),
"maintenance_policy_set": Property(), # Note: This field is only available when using v4beta.
"maintenance_policy_set": Property(),
"description": Property(),
"source": Property(),
"not_before": Property(is_datetime=True),
Expand Down
21 changes: 17 additions & 4 deletions linode_api4/objects/linode.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import copy
import string
import sys
import warnings
from dataclasses import dataclass, field
from datetime import datetime
from enum import Enum
Expand Down Expand Up @@ -217,7 +218,7 @@ def resize(self, new_size):
class Kernel(Base):
"""
The primary component of every Linux system. The kernel interfaces
with the system’s hardware and it controls the operating system’s core functionality.
with the system’s hardware, and it controls the operating system’s core functionality.

Your Compute Instance is capable of running one of three kinds of kernels:

Expand All @@ -237,6 +238,10 @@ class Kernel(Base):
to compile the kernel from source than to download it from your package manager. For more
information on custom compiled kernels, review our guides for Debian, Ubuntu, and CentOS.

.. note::
The ``xen`` property is deprecated and is no longer returned by the API.
It is maintained for backward compatibility only.

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

Expand All @@ -256,6 +261,16 @@ class Kernel(Base):
"pvops": Property(),
}

def __getattribute__(self, name: str) -> object:
if name == "xen":
warnings.warn(
"The 'xen' property of Kernel is deprecated and is no longer "
"returned by the API. It is maintained for backward compatibility only.",
DeprecationWarning,
stacklevel=2,
)
return super().__getattribute__(name)


class Type(Base):
"""
Expand Down Expand Up @@ -800,9 +815,7 @@ class Instance(Base):
"lke_cluster_id": Property(),
"capabilities": Property(unordered=True),
"interface_generation": Property(),
"maintenance_policy": Property(
mutable=True
), # Note: This field is only available when using v4beta.
"maintenance_policy": Property(mutable=True),
"locks": Property(unordered=True),
}

Expand Down
6 changes: 3 additions & 3 deletions linode_api4/objects/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class LockType(StrEnum):
"""
LockType defines valid values for resource lock types.

API Documentation: https://techdocs.akamai.com/linode-api/reference/post-lock
API Documentation: TBD
"""

cannot_delete = "cannot_delete"
Expand All @@ -22,7 +22,7 @@ class LockEntity(JSONObject):
"""
Represents the entity that is locked.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-lock
API Documentation: TBD
"""

id: int = 0
Expand All @@ -35,7 +35,7 @@ class Lock(Base):
"""
A resource lock that prevents deletion or modification of a resource.

API Documentation: https://techdocs.akamai.com/linode-api/reference/get-lock
API Documentation: TBD
"""

api_endpoint = "/locks/{id}"
Expand Down
50 changes: 49 additions & 1 deletion linode_api4/objects/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,19 @@ class DashboardType(StrEnum):
custom = "custom"


class AlertStatus(StrEnum):
"""
Enum for supported alert status values.
"""

AlertDefinitionStatusProvisioning = "provisioning"
AlertDefinitionStatusEnabling = "enabling"
AlertDefinitionStatusDisabling = "disabling"
AlertDefinitionStatusEnabled = "enabled"
AlertDefinitionStatusDisabled = "disabled"
AlertDefinitionStatusFailed = "failed"


@dataclass
class Filter(JSONObject):
"""
Expand Down Expand Up @@ -428,6 +441,40 @@ class ChannelContent(JSONObject):
# Other channel types like 'webhook', 'slack' could be added here as Optional fields.


@dataclass
class EmailDetails(JSONObject):
"""
Represents email-specific details for an alert channel.
"""

usernames: Optional[List[str]] = None
recipient_type: Optional[str] = None


@dataclass
class ChannelDetails(JSONObject):
"""
Represents the details block for an AlertChannel, which varies by channel type.
"""

email: Optional[EmailDetails] = None


@dataclass
class AlertInfo(JSONObject):
"""
Represents a reference to alerts associated with an alert channel.
Fields:
- url: str - API URL to fetch the alerts for this channel
- type: str - Type identifier (e.g., 'alerts-definitions')
- alert_count: int - Number of alerts associated with this channel
"""

url: str = ""
_type: str = field(default="", metadata={"json_key": "type"})
alert_count: int = 0


class AlertChannel(Base):
"""
Represents an alert channel used to deliver notifications when alerts
Expand All @@ -450,7 +497,8 @@ class AlertChannel(Base):
"label": Property(),
"type": Property(),
"channel_type": Property(),
"alerts": Property(mutable=False, json_object=Alerts),
"details": Property(mutable=False, json_object=ChannelDetails),
"alerts": Property(mutable=False, json_object=AlertInfo),
"content": Property(mutable=False, json_object=ChannelContent),
"created": Property(is_datetime=True),
"updated": Property(is_datetime=True),
Expand Down
1 change: 1 addition & 0 deletions linode_api4/objects/nodebalancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ class NodeBalancer(Base):
"transfer": Property(),
"tags": Property(mutable=True, unordered=True),
"client_udp_sess_throttle": Property(mutable=True),
"locks": Property(unordered=True),
}

# create derived objects
Expand Down
62 changes: 62 additions & 0 deletions linode_api4/objects/region.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,68 @@

from linode_api4.errors import UnexpectedResponseError
from linode_api4.objects.base import Base, JSONObject, Property
from linode_api4.objects.serializable import StrEnum


class Capability(StrEnum):
"""
An enum class that represents the capabilities that Linode offers
across different regions and services.

These capabilities indicate what services are available in each data center.
"""

linodes = "Linodes"
nodebalancers = "NodeBalancers"
block_storage = "Block Storage"
object_storage = "Object Storage"
object_storage_regions = "Object Storage Access Key Regions"
object_storage_endpoint_types = "Object Storage Endpoint Types"
lke = "Kubernetes"
lke_ha_controlplanes = "LKE HA Control Planes"
lke_e = "Kubernetes Enterprise"
firewall = "Cloud Firewall"
gpu = "GPU Linodes"
vlans = "Vlans"
vpcs = "VPCs"
vpcs_extra = "VPCs Extra"
machine_images = "Machine Images"
dbaas = "Managed Databases"
dbaas_beta = "Managed Databases Beta"
bs_migrations = "Block Storage Migrations"
metadata = "Metadata"
premium_plans = "Premium Plans"
edge_plans = "Edge Plans"
distributed_plans = "Distributed Plans"
lke_control_plane_acl = "LKE Network Access Control List (IP ACL)"
aclb = "Akamai Cloud Load Balancer"
support_ticket_severity = "Support Ticket Severity"
backups = "Backups"
placement_group = "Placement Group"
disk_encryption = "Disk Encryption"
la_disk_encryption = "LA Disk Encryption"
akamai_ram_protection = "Akamai RAM Protection"
blockstorage_encryption = "Block Storage Encryption"
blockstorage_perf_b1 = "Block Storage Performance B1"
blockstorage_perf_b1_default = "Block Storage Performance B1 Default"
aclp = "Akamai Cloud Pulse"
aclp_logs = "Akamai Cloud Pulse Logs"
aclp_logs_lkee = "Akamai Cloud Pulse Logs LKE-E Audit"
aclp_logs_dc_lkee = "ACLP Logs Datacenter LKE-E"
smtp_enabled = "SMTP Enabled"
stackscripts = "StackScripts"
vpu = "NETINT Quadra T1U"
linode_interfaces = "Linode Interfaces"
maintenance_policy = "Maintenance Policy"
vpc_dual_stack = "VPC Dual Stack"
vpc_ipv6_stack = "VPC IPv6 Stack"
nlb = "Network LoadBalancer"
natgateway = "NAT Gateway"
lke_e_byovpc = "Kubernetes Enterprise BYO VPC"
lke_e_stacktype = "Kubernetes Enterprise Dual Stack"
ruleset = "Cloud Firewall Rule Set"
prefixlists = "Cloud Firewall Prefix Lists"
current_prefixlists = "Cloud Firewall Prefix List Current References"


@dataclass
Expand Down
6 changes: 4 additions & 2 deletions test/fixtures/nodebalancers.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"updated": "2018-01-01T00:01:01",
"label": "balancer123456",
"client_conn_throttle": 0,
"tags": ["something"]
"tags": ["something"],
"locks": ["cannot_delete_with_subresources"]
},
{
"created": "2018-01-01T00:01:01",
Expand All @@ -22,7 +23,8 @@
"updated": "2018-01-01T00:01:01",
"label": "balancer123457",
"client_conn_throttle": 0,
"tags": []
"tags": [],
"locks": []
}
],
"results": 2,
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/nodebalancers_123456.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@
"client_conn_throttle": 0,
"tags": [
"something"
],
"locks": [
"cannot_delete_with_subresources"
]
}
Loading
Loading