-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: Add
account_availability_info
module (#445)
* add info module * nit * fix lint * fix lint * update docs * fix readme * nit
- Loading branch information
1 parent
099f0e4
commit 8380945
Showing
5 changed files
with
116 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# account_availability_info | ||
|
||
Get info about a Linode Account Availability. | ||
|
||
- [Examples](#examples) | ||
- [Parameters](#parameters) | ||
- [Return Values](#return-values) | ||
|
||
## Examples | ||
|
||
```yaml | ||
- name: Get info about the current Linode account availability | ||
linode.cloud.account_info: | ||
region: us-east | ||
|
||
``` | ||
|
||
|
||
## Parameters | ||
|
||
| Field | Type | Required | Description | | ||
|-----------|------|----------|------------------------------------------------------------------------------| | ||
| `region` | <center>`str`</center> | <center>Optional</center> | The Region of the Account Availability to resolve. | | ||
|
||
## Return Values | ||
|
||
- `account_availability` - The returned Account Availability. | ||
|
||
- Sample Response: | ||
```json | ||
|
||
{ | ||
"region": "us-east", | ||
"unavailable": ["Linode"] | ||
} | ||
|
||
``` | ||
- See the [Linode API response documentation](TBD) for a list of returned fields | ||
|
||
|
15 changes: 15 additions & 0 deletions
15
plugins/module_utils/doc_fragments/account_availability_info.py
This file contains 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Documentation fragments for the account_availability module""" | ||
|
||
result_account_availability_samples = [''' | ||
{ | ||
"region": "us-east", | ||
"unavailable": ["Linode"] | ||
} | ||
'''] | ||
|
||
|
||
specdoc_examples = [''' | ||
- name: Get info about the current Linode account availability | ||
linode.cloud.account_info: | ||
region: us-east | ||
'''] |
This file contains 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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
"""This module contains all of the functionality for Linode Account Availability info.""" | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
from ansible_collections.linode.cloud.plugins.module_utils.doc_fragments import ( | ||
account_availability_info as docs, | ||
) | ||
from ansible_collections.linode.cloud.plugins.module_utils.linode_common_info import ( | ||
InfoModule, | ||
InfoModuleAttr, | ||
InfoModuleResult, | ||
) | ||
from ansible_specdoc.objects import FieldType | ||
from linode_api4 import AccountAvailability | ||
|
||
module = InfoModule( | ||
examples=docs.specdoc_examples, | ||
primary_result=InfoModuleResult( | ||
display_name="Account Availability", | ||
field_name="account_availability", | ||
field_type=FieldType.dict, | ||
docs_url="TBD", | ||
samples=docs.result_account_availability_samples, | ||
), | ||
attributes=[ | ||
InfoModuleAttr( | ||
name="region", | ||
display_name="Region", | ||
type=FieldType.string, | ||
get=lambda client, params: client.load( | ||
AccountAvailability, params.get("region") | ||
)._raw_json, | ||
), | ||
], | ||
) | ||
|
||
SPECDOC_META = module.spec | ||
|
||
if __name__ == "__main__": | ||
module.run() |
17 changes: 17 additions & 0 deletions
17
tests/integration/targets/account_availability_info/tasks/main.yaml
This file contains 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
- name: account_availability_info | ||
block: | ||
- name: Get info about the current account availability | ||
linode.cloud.account_availability_info: | ||
region: us-east | ||
register: account_availability | ||
|
||
- assert: | ||
that: | ||
- account_availability.account_availability.region == "us-east" | ||
|
||
environment: | ||
LINODE_UA_PREFIX: '{{ ua_prefix }}' | ||
LINODE_API_TOKEN: '{{ api_token }}' | ||
LINODE_API_URL: '{{ api_url }}' | ||
LINODE_API_VERSION: '{{ api_version }}' | ||
LINODE_CA: '{{ ca_file or "" }}' |