Skip to content

Commit

Permalink
new: Add account_availability_info module (#445)
Browse files Browse the repository at this point in the history
* add info module

* nit

* fix lint

* fix lint

* update docs

* fix readme

* nit
  • Loading branch information
yec-akamai authored Dec 13, 2023
1 parent 099f0e4 commit 8380945
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Modules for retrieving information about existing Linode infrastructure.

Name | Description |
--- | ------------ |
[linode.cloud.account_availability_info](./docs/modules/account_availability_info.md)|Get info about a Linode Account Availability.|
[linode.cloud.account_info](./docs/modules/account_info.md)|Get info about a Linode Account.|
[linode.cloud.database_mysql_info](./docs/modules/database_mysql_info.md)|Get info about a Linode MySQL Managed Database.|
[linode.cloud.database_postgresql_info](./docs/modules/database_postgresql_info.md)|Get info about a Linode PostgreSQL Managed Database.|
Expand Down
40 changes: 40 additions & 0 deletions docs/modules/account_availability_info.md
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 plugins/module_utils/doc_fragments/account_availability_info.py
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
''']
43 changes: 43 additions & 0 deletions plugins/modules/account_availability_info.py
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()
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 "" }}'

0 comments on commit 8380945

Please sign in to comment.