diff --git a/README.md b/README.md index 3264718d..7f37e46a 100644 --- a/README.md +++ b/README.md @@ -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.| diff --git a/docs/modules/account_availability_info.md b/docs/modules/account_availability_info.md new file mode 100644 index 00000000..c65f0996 --- /dev/null +++ b/docs/modules/account_availability_info.md @@ -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` |
`str`
|
Optional
| 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 + + diff --git a/plugins/module_utils/doc_fragments/account_availability_info.py b/plugins/module_utils/doc_fragments/account_availability_info.py new file mode 100644 index 00000000..f5ab513f --- /dev/null +++ b/plugins/module_utils/doc_fragments/account_availability_info.py @@ -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 +'''] diff --git a/plugins/modules/account_availability_info.py b/plugins/modules/account_availability_info.py new file mode 100644 index 00000000..6cc96838 --- /dev/null +++ b/plugins/modules/account_availability_info.py @@ -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() diff --git a/tests/integration/targets/account_availability_info/tasks/main.yaml b/tests/integration/targets/account_availability_info/tasks/main.yaml new file mode 100644 index 00000000..1ba63e8d --- /dev/null +++ b/tests/integration/targets/account_availability_info/tasks/main.yaml @@ -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 "" }}'