-
Notifications
You must be signed in to change notification settings - Fork 76
Enhanced Interfaces: Add support for Linode-related endpoints and fields #533
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
lgarber-akamai
wants to merge
9
commits into
linode:proj/enhanced-interfaces
Choose a base branch
from
lgarber-akamai:new/enhanced-interfaces-linodes
base: proj/enhanced-interfaces
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5739a51
Add support for Linode-related endpoints and fields
lgarber-akamai eb2566c
oops
lgarber-akamai 79a9798
tiny fixes
lgarber-akamai b1a8215
fix docsa
lgarber-akamai d5d7c35
Add docs examples
lgarber-akamai 543145a
Docs fixes
lgarber-akamai bbb021e
oops
lgarber-akamai 3e1c325
Remove irrelevant test
lgarber-akamai 6b9d55b
Add LA notices
lgarber-akamai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -180,6 +180,64 @@ def ipv6_ranges(self, *filters): | |
""" | ||
return self.client._get_and_filter(IPv6Range, *filters) | ||
|
||
def ipv6_range_allocate( | ||
self, | ||
prefix_length: int, | ||
route_target: Optional[str] = None, | ||
linode: Optional[Union[Instance, int]] = None, | ||
**kwargs, | ||
) -> IPv6Range: | ||
Comment on lines
+183
to
+189
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This endpoint wasn't added as part of Enhanced Interfaces but it was oddly missing from the SDK. I added it here to unblock some of the IPv6 interface test cases below. Let me know if this is worth splitting out into a separate PR 🙂 |
||
""" | ||
Creates an IPv6 Range and assigns it based on the provided Linode or route target IPv6 SLAAC address. | ||
|
||
API Documentation: https://techdocs.akamai.com/linode-api/reference/post-ipv6-range | ||
|
||
Create an IPv6 range assigned to a Linode by ID:: | ||
|
||
range = client.networking.ipv6_range_allocate(64, linode_id=123) | ||
|
||
|
||
Create an IPv6 range assigned to a Linode by SLAAC:: | ||
|
||
range = client.networking.ipv6_range_allocate( | ||
64, | ||
route_target=instance.ipv6.split("/")[0] | ||
) | ||
|
||
:param prefix_length: The prefix length of the IPv6 range. | ||
:type prefix_length: int | ||
:param route_target: The IPv6 SLAAC address to assign this range to. Required if linode is not specified. | ||
:type route_target: str | ||
:param linode: The ID of the Linode to assign this range to. | ||
The SLAAC address for the provided Linode is used as the range's route_target. | ||
Required if linode is not specified. | ||
:type linode: Instance or int | ||
|
||
:returns: The new IPAddress. | ||
:rtype: IPAddress | ||
""" | ||
|
||
params = { | ||
"prefix_length": prefix_length, | ||
"route_target": route_target, | ||
"linode_id": linode, | ||
} | ||
|
||
params.update(**kwargs) | ||
|
||
result = self.client.post( | ||
"/networking/ipv6/ranges", | ||
data=drop_null_keys(_flatten_request_body_recursive(params)), | ||
) | ||
|
||
if not "range" in result: | ||
raise UnexpectedResponseError( | ||
"Unexpected response when allocating IPv6 range!", json=result | ||
) | ||
|
||
result = IPv6Range(self.client, result["range"], result) | ||
return result | ||
|
||
def ipv6_pools(self, *filters): | ||
""" | ||
Returns a list of IPv6 pools on this account. | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No longer necessary due to
_flatten_request_body_recursive(drop_null_keys(params))
below