Skip to content

Commit

Permalink
Implement object_storage_endpoint_list module
Browse files Browse the repository at this point in the history
  • Loading branch information
lgarber-akamai committed Feb 12, 2025
1 parent 5309ad0 commit ee9587f
Show file tree
Hide file tree
Showing 5 changed files with 323 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ Name | Description |
[linode.cloud.nodebalancer_list](./docs/modules/nodebalancer_list.md)|List and filter on Node Balancers.|
[linode.cloud.nodebalancer_type_list](./docs/modules/nodebalancer_type_list.md)|List and filter on Node Balancer Types.|
[linode.cloud.object_cluster_list](./docs/modules/object_cluster_list.md)|**NOTE: This module has been deprecated because it relies on deprecated API endpoints. Going forward, `region` will be the preferred way to designate where Object Storage resources should be created.**|
[linode.cloud.object_storage_endpoint_list](./docs/modules/object_storage_endpoint_list.md)|List and filter on Object Storage Endpoints.|
[linode.cloud.placement_group_list](./docs/modules/placement_group_list.md)|List and filter on Placement Groups.|
[linode.cloud.region_list](./docs/modules/region_list.md)|List and filter on Regions.|
[linode.cloud.ssh_key_list](./docs/modules/ssh_key_list.md)|List and filter on SSH Keys.|
Expand Down
155 changes: 155 additions & 0 deletions docs/modules/object_storage_endpoint_list.md
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 plugins/module_utils/doc_fragments/object_storage_endpoint_list.py
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"
}
]''']
32 changes: 32 additions & 0 deletions plugins/modules/object_storage_endpoint_list.py
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()
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 "" }}'

0 comments on commit ee9587f

Please sign in to comment.