-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
149d3b3
commit 217b05f
Showing
3 changed files
with
38 additions
and
70 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
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 |
---|---|---|
@@ -1,84 +1,37 @@ | ||
#!/usr/bin/python | ||
# -*- coding: utf-8 -*- | ||
|
||
"""This module allows users to retrieve information about the current Linode profile.""" | ||
"""This module contains all of the functionality for Linode Profile info.""" | ||
|
||
from __future__ import absolute_import, division, print_function | ||
|
||
from typing import Any, List, Optional | ||
|
||
import ansible_collections.linode.cloud.plugins.module_utils.doc_fragments.profile_info as docs | ||
from ansible_collections.linode.cloud.plugins.module_utils.linode_common import ( | ||
LinodeModuleBase, | ||
) | ||
from ansible_collections.linode.cloud.plugins.module_utils.linode_docs import ( | ||
global_authors, | ||
global_requirements, | ||
) | ||
from ansible_specdoc.objects import ( | ||
FieldType, | ||
SpecDocMeta, | ||
SpecField, | ||
SpecReturnValue, | ||
from ansible_collections.linode.cloud.plugins.module_utils.linode_common_info import ( | ||
InfoModule, | ||
InfoModuleResult, | ||
) | ||
from ansible_specdoc.objects import FieldType | ||
|
||
spec = { | ||
# Disable the default values | ||
"label": SpecField(type=FieldType.string, required=False, doc_hide=True), | ||
"state": SpecField(type=FieldType.string, required=False, doc_hide=True), | ||
} | ||
|
||
|
||
SPECDOC_META = SpecDocMeta( | ||
description=["Get info about a Linode Profile."], | ||
requirements=global_requirements, | ||
author=global_authors, | ||
options=spec, | ||
module = InfoModule( | ||
examples=docs.specdoc_examples, | ||
return_values={ | ||
"profile": SpecReturnValue( | ||
description="The profile info in JSON serialized form.", | ||
docs_url="https://techdocs.akamai.com/linode-api/reference/get-profile", | ||
type=FieldType.dict, | ||
sample=docs.result_profile_samples, | ||
) | ||
}, | ||
primary_result=InfoModuleResult( | ||
display_name="Profile", | ||
field_name="profile", | ||
field_type=FieldType.dict, | ||
docs_url="https://techdocs.akamai.com/linode-api/reference/get-profile", | ||
samples=docs.result_profile_samples, | ||
get=lambda client, params: client.profile()._raw_json, | ||
), | ||
) | ||
|
||
SPECDOC_META = module.spec | ||
|
||
DOCUMENTATION = r""" | ||
""" | ||
EXAMPLES = r""" | ||
""" | ||
RETURN = r""" | ||
""" | ||
|
||
|
||
class Module(LinodeModuleBase): | ||
"""Module for getting info about a Linode Profile""" | ||
|
||
def __init__(self) -> None: | ||
self.required_one_of: List[str] = [] | ||
self.results = {"profile": None} | ||
|
||
self.module_arg_spec = SPECDOC_META.ansible_spec | ||
|
||
super().__init__( | ||
module_arg_spec=self.module_arg_spec, | ||
required_one_of=self.required_one_of, | ||
) | ||
|
||
def exec_module(self, **kwargs: Any) -> Optional[dict]: | ||
"""Entrypoint for volume info module""" | ||
|
||
self.results["profile"] = self.client.profile()._raw_json | ||
|
||
return self.results | ||
|
||
|
||
def main() -> None: | ||
"""Constructs and calls the profile_info module""" | ||
Module() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() | ||
module.run() |