forked from linode/ansible_linode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement object_storage_endpoint_list module
- Loading branch information
1 parent
5309ad0
commit ee9587f
Showing
5 changed files
with
323 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,155 @@ | ||
# object_storage_endpoint_list | ||
|
||
List and filter on Object Storage Endpoints. | ||
|
||
- [Minimum Required Fields](#minimum-required-fields) | ||
- [Examples](#examples) | ||
- [Parameters](#parameters) | ||
- [Return Values](#return-values) | ||
|
||
## Minimum Required Fields | ||
| Field | Type | Required | Description | | ||
|-------------|-------|--------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `api_token` | `str` | **Required** | The Linode account personal access token. It is necessary to run the module. <br/>It can be exposed by the environment variable `LINODE_API_TOKEN` instead. <br/>See details in [Usage](https://github.com/linode/ansible_linode?tab=readme-ov-file#usage). | | ||
|
||
## Examples | ||
|
||
```yaml | ||
- name: List all available Object Storage Endpoints | ||
linode.cloud.object_storage_endpoint_list: {} | ||
``` | ||
## Parameters | ||
| Field | Type | Required | Description | | ||
|-----------|------|----------|------------------------------------------------------------------------------| | ||
| `order` | <center>`str`</center> | <center>Optional</center> | The order to list Object Storage Endpoints in. **(Choices: `desc`, `asc`; Default: `asc`)** | | ||
| `order_by` | <center>`str`</center> | <center>Optional</center> | The attribute to order Object Storage Endpoints by. | | ||
| [`filters` (sub-options)](#filters) | <center>`list`</center> | <center>Optional</center> | A list of filters to apply to the resulting Object Storage Endpoints. | | ||
| `count` | <center>`int`</center> | <center>Optional</center> | The number of Object Storage Endpoints to return. If undefined, all results will be returned. | | ||
|
||
### filters | ||
|
||
| Field | Type | Required | Description | | ||
|-----------|------|----------|------------------------------------------------------------------------------| | ||
| `name` | <center>`str`</center> | <center>**Required**</center> | The name of the field to filter on. Valid filterable fields can be found [here](https://techdocs.akamai.com/linode-api/reference/get-object-storage-endpoints). | | ||
| `values` | <center>`list`</center> | <center>**Required**</center> | A list of values to allow for this field. Fields will pass this filter if at least one of these values matches. | | ||
|
||
## Return Values | ||
|
||
- `endpoints` - The returned Object Storage Endpoints. | ||
|
||
- Sample Response: | ||
```json | ||
[ | ||
{ | ||
"endpoint_type": "E0", | ||
"region": "us-southeast", | ||
"s3_endpoint": "us-southeast-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E0", | ||
"region": "us-east", | ||
"s3_endpoint": "us-east-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-iad", | ||
"s3_endpoint": "us-iad-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-mia", | ||
"s3_endpoint": "us-mia-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "fr-par", | ||
"s3_endpoint": "fr-par-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E3", | ||
"region": "gb-lon", | ||
"s3_endpoint": "gb-lon-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E2", | ||
"region": "sg-sin-2", | ||
"s3_endpoint": "sg-sin-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-ord", | ||
"s3_endpoint": "us-ord-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-sea", | ||
"s3_endpoint": "us-sea-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E2", | ||
"region": "au-mel", | ||
"s3_endpoint": "au-mel-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "id-cgk", | ||
"s3_endpoint": "id-cgk-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "in-maa", | ||
"s3_endpoint": "in-maa-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "se-sto", | ||
"s3_endpoint": "se-sto-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "it-mil", | ||
"s3_endpoint": "it-mil-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "jp-osa", | ||
"s3_endpoint": "jp-osa-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "es-mad", | ||
"s3_endpoint": "es-mad-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-lax", | ||
"s3_endpoint": "us-lax-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "nl-ams", | ||
"s3_endpoint": "nl-ams-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E0", | ||
"region": "ap-south", | ||
"s3_endpoint": "ap-south-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "br-gru", | ||
"s3_endpoint": "br-gru-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E0", | ||
"region": "eu-central", | ||
"s3_endpoint": "eu-central-1.linodeobjects.com" | ||
} | ||
] | ||
``` | ||
- See the [Linode API response documentation](https://techdocs.akamai.com/linode-api/reference/get-object-storage-endpoints) for a list of returned fields | ||
|
||
|
113 changes: 113 additions & 0 deletions
113
plugins/module_utils/doc_fragments/object_storage_endpoint_list.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,113 @@ | ||
"""Documentation fragments for the linode.cloud.object_storage_endpoint_list module.""" | ||
|
||
specdoc_examples = [''' | ||
- name: List all available Object Storage Endpoints | ||
linode.cloud.object_storage_endpoint_list: {}'''] | ||
|
||
result_endpoints_sample = ['''[ | ||
{ | ||
"endpoint_type": "E0", | ||
"region": "us-southeast", | ||
"s3_endpoint": "us-southeast-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E0", | ||
"region": "us-east", | ||
"s3_endpoint": "us-east-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-iad", | ||
"s3_endpoint": "us-iad-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-mia", | ||
"s3_endpoint": "us-mia-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "fr-par", | ||
"s3_endpoint": "fr-par-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E3", | ||
"region": "gb-lon", | ||
"s3_endpoint": "gb-lon-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E2", | ||
"region": "sg-sin-2", | ||
"s3_endpoint": "sg-sin-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-ord", | ||
"s3_endpoint": "us-ord-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-sea", | ||
"s3_endpoint": "us-sea-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E2", | ||
"region": "au-mel", | ||
"s3_endpoint": "au-mel-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "id-cgk", | ||
"s3_endpoint": "id-cgk-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "in-maa", | ||
"s3_endpoint": "in-maa-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "se-sto", | ||
"s3_endpoint": "se-sto-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "it-mil", | ||
"s3_endpoint": "it-mil-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "jp-osa", | ||
"s3_endpoint": "jp-osa-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "es-mad", | ||
"s3_endpoint": "es-mad-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "us-lax", | ||
"s3_endpoint": "us-lax-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "nl-ams", | ||
"s3_endpoint": "nl-ams-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E0", | ||
"region": "ap-south", | ||
"s3_endpoint": "ap-south-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E1", | ||
"region": "br-gru", | ||
"s3_endpoint": "br-gru-1.linodeobjects.com" | ||
}, | ||
{ | ||
"endpoint_type": "E0", | ||
"region": "eu-central", | ||
"s3_endpoint": "eu-central-1.linodeobjects.com" | ||
} | ||
]'''] |
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,32 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
"""This file implements the linode.cloud.object_storage_endpoints_list module.""" | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
import ansible_collections.linode.cloud.plugins.module_utils.doc_fragments.object_storage_endpoint_list as docs | ||
from ansible_collections.linode.cloud.plugins.module_utils.linode_common_list import ( | ||
ListModule, | ||
) | ||
|
||
module = ListModule( | ||
result_display_name="Object Storage Endpoints", | ||
result_field_name="endpoints", | ||
endpoint_template="/object-storage/endpoints", | ||
result_docs_url="https://techdocs.akamai.com/linode-api/reference/get-object-storage-endpoints", | ||
examples=docs.specdoc_examples, | ||
result_samples=docs.result_endpoints_sample, | ||
) | ||
|
||
SPECDOC_META = module.spec | ||
|
||
DOCUMENTATION = r""" | ||
""" | ||
EXAMPLES = r""" | ||
""" | ||
RETURN = r""" | ||
""" | ||
|
||
if __name__ == "__main__": | ||
module.run() |
22 changes: 22 additions & 0 deletions
22
tests/integration/targets/object_storage_endpoint_list/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,22 @@ | ||
- name: object_storage_endpoint_list | ||
block: | ||
- name: List all Object Storage endpoints | ||
linode.cloud.object_storage_endpoint_list: {} | ||
register: all | ||
|
||
- assert: | ||
that: | ||
- all.endpoints | length > 0 | ||
- all.endpoints[0].endpoint_type != None | ||
- all.endpoints[0].region != None | ||
- all.endpoints[0].s3_endpoint != None | ||
|
||
# NOTE: The /object-storage/endpoints endpoint does not support filtering at this time. | ||
|
||
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 "" }}' | ||
|