|
| 1 | +#!/usr/bin/python |
| 2 | +# -*- coding: utf-8 -*- |
| 3 | +# |
| 4 | +# Copyright (c) 2025, Samuel Hunter <samuel (at) shunter (dot) xyz> |
| 5 | +# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 6 | + |
| 7 | +from __future__ import absolute_import, division, print_function |
| 8 | + |
| 9 | +__metaclass__ = type |
| 10 | + |
| 11 | + |
| 12 | +DOCUMENTATION = """ |
| 13 | +--- |
| 14 | +module: vfs_info |
| 15 | +short_description: Get information about Vultr VFS subscriptions |
| 16 | +version_added: "1.14.0" |
| 17 | +description: |
| 18 | + - Get infos about Vultr virtual file system subscriptions available. |
| 19 | +author: |
| 20 | + - "Samuel Hunter (@samuel-hunter)" |
| 21 | +extends_documentation_fragment: |
| 22 | + - vultr.cloud.vultr_v2 |
| 23 | +""" |
| 24 | + |
| 25 | +EXAMPLES = """ |
| 26 | +- name: Get Vultr vfs infos |
| 27 | + vultr.cloud.vfs_info: |
| 28 | + register: result |
| 29 | +
|
| 30 | +- name: Print the infos |
| 31 | + ansible.builtin.debug: |
| 32 | + var: result.vultr_vfs_info |
| 33 | +""" |
| 34 | + |
| 35 | +RETURN = """ |
| 36 | +--- |
| 37 | +vultr_api: |
| 38 | + description: Response from Vultr API with a few additions/modification. |
| 39 | + returned: success |
| 40 | + type: dict |
| 41 | + contains: |
| 42 | + api_timeout: |
| 43 | + description: Timeout used for the API requests. |
| 44 | + returned: success |
| 45 | + type: int |
| 46 | + sample: 60 |
| 47 | + api_retries: |
| 48 | + description: Amount of max retries for the API requests. |
| 49 | + returned: success |
| 50 | + type: int |
| 51 | + sample: 5 |
| 52 | + api_retry_max_delay: |
| 53 | + description: Exponential backoff delay in seconds between retries up to this max delay value. |
| 54 | + returned: success |
| 55 | + type: int |
| 56 | + sample: 12 |
| 57 | + api_results_per_page: |
| 58 | + description: Number of results returned per call to API. |
| 59 | + returned: success |
| 60 | + type: int |
| 61 | + sample: 100 |
| 62 | + api_endpoint: |
| 63 | + description: Endpoint used for the API requests. |
| 64 | + returned: success |
| 65 | + type: str |
| 66 | + sample: "https://api.vultr.com/v2" |
| 67 | +vultr_vfs_info: |
| 68 | + description: Response from Vultr API as list. |
| 69 | + returned: success |
| 70 | + type: list |
| 71 | + contains: |
| 72 | + billing: |
| 73 | + description: Billing info |
| 74 | + returned: success |
| 75 | + type: dict |
| 76 | + contains: |
| 77 | + charges: |
| 78 | + description: Current billing charges |
| 79 | + returned: success |
| 80 | + type: float |
| 81 | + sample: 10.5 |
| 82 | + monthly: |
| 83 | + description: Monthly billing amount |
| 84 | + returned: success |
| 85 | + type: float |
| 86 | + sample: 30 |
| 87 | + date_created: |
| 88 | + description: Creation timestamp of the VFS |
| 89 | + returned: success |
| 90 | + type: str |
| 91 | + sample: "2024-01-01T12:00:00Z" |
| 92 | + disk_type: |
| 93 | + description: Type of storage disk |
| 94 | + returned: success |
| 95 | + type: str |
| 96 | + sample: nvme |
| 97 | + label: |
| 98 | + description: User-defined label for the VFS |
| 99 | + returned: success |
| 100 | + type: str |
| 101 | + sample: my file system |
| 102 | + id: |
| 103 | + description: Unique identifier for the VFS |
| 104 | + returned: success |
| 105 | + type: str |
| 106 | + sample: cb676a46-66fd-4dfb-b839-443f2e6c0b60 |
| 107 | + region: |
| 108 | + description: Region identifier where the VFS is located |
| 109 | + returned: success |
| 110 | + type: str |
| 111 | + sample: ewr |
| 112 | + status: |
| 113 | + description: Current status of the VFS |
| 114 | + returned: success |
| 115 | + type: str |
| 116 | + sample: active |
| 117 | + storage_size: |
| 118 | + description: Storage provisioned |
| 119 | + returned: success |
| 120 | + type: dict |
| 121 | + contains: |
| 122 | + bytes: |
| 123 | + description: Size in bytes |
| 124 | + returned: success |
| 125 | + type: int |
| 126 | + sample: 10737418240 |
| 127 | + gb: |
| 128 | + description: Size in gigabytes |
| 129 | + returned: success |
| 130 | + type: int |
| 131 | + sample: 10 |
| 132 | + storage_used: |
| 133 | + description: Storage used |
| 134 | + returned: success |
| 135 | + type: dict |
| 136 | + contains: |
| 137 | + bytes: |
| 138 | + description: Size in bytes |
| 139 | + returned: success |
| 140 | + type: int |
| 141 | + sample: 10737418240 |
| 142 | + gb: |
| 143 | + description: Size in gigabytes |
| 144 | + returned: success |
| 145 | + type: int |
| 146 | + sample: 10 |
| 147 | + tags: |
| 148 | + description: List of tags associated with the VFS |
| 149 | + returned: success |
| 150 | + type: list |
| 151 | + elements: str |
| 152 | + sample: [ prod, web ] |
| 153 | +""" |
| 154 | + |
| 155 | +from ansible.module_utils.basic import AnsibleModule |
| 156 | + |
| 157 | +from ..module_utils.vultr_v2 import AnsibleVultr, vultr_argument_spec |
| 158 | + |
| 159 | + |
| 160 | +def main(): |
| 161 | + argument_spec = vultr_argument_spec() |
| 162 | + |
| 163 | + module = AnsibleModule( |
| 164 | + argument_spec=argument_spec, |
| 165 | + supports_check_mode=True, |
| 166 | + ) |
| 167 | + |
| 168 | + vultr = AnsibleVultr( |
| 169 | + module=module, |
| 170 | + namespace="vultr_vfs_info", |
| 171 | + resource_path="/vfs", |
| 172 | + ressource_result_key_singular="vfs", |
| 173 | + ressource_result_key_plural="vfs", |
| 174 | + ) |
| 175 | + |
| 176 | + vultr.get_result(vultr.query_list()) |
| 177 | + |
| 178 | + |
| 179 | +if __name__ == "__main__": |
| 180 | + main() |
0 commit comments