Debian Codegraph @

ansible_collections/azure/azcollection/plugins/modules/azure_rm_containerregistryreplication_info.py

raw symbols SCIP
1 #!/usr/bin/python
2 #
3 # Copyright (c) 2017 Zim Kalinowski, <[email protected]>
4 #
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 __metaclass__ = type
9
10
11 DOCUMENTATION = '''
12 ---
13 module: azure_rm_containerregistryreplication_info
14 version_added: "0.0.1"
15 short_description: Get Replication facts.
16 description:
17 - Get facts of Replication.
18
19 options:
20 resource_group:
21 description:
22 - The name of the resource group to which the container registry belongs.
23 required: True
24 type: str
25 registry_name:
26 description:
27 - The name of the container registry.
28 required: True
29 type: str
30 replication_name:
31 description:
32 - The name of the replication.
33 required: True
34 type: str
35
36 extends_documentation_fragment:
37 - azure.azcollection.azure
38
39 author:
40 - "Zim Kalinowski (@zikalino)"
41
42 '''
43
44 EXAMPLES = '''
45 - name: Get instance of Replication
46 azure_rm_containerregistryreplication_info:
47 resource_group: resource_group_name
48 registry_name: registry_name
49 replication_name: replication_name
50 '''
51
52 RETURN = '''
53 replications:
54 description: A list of dict results where the key is the name of the Replication and the values are the facts for that Replication.
55 returned: always
56 type: complex
57 contains:
58 replication_name:
59 description: The key is the name of the server that the values relate to.
60 type: complex
61 contains:
62 id:
63 description:
64 - The resource ID.
65 returned: always
66 type: str
67 sample: "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registr
68 ies/myRegistry/replications/myReplication"
69 name:
70 description:
71 - The name of the resource.
72 returned: always
73 type: str
74 sample: myReplication
75 type:
76 description:
77 - The type of the resource.
78 returned: always
79 type: str
80 sample: Microsoft.ContainerRegistry/registries/replications
81 location:
82 description:
83 - The location of the resource. This cannot be changed after the resource is created.
84 returned: always
85 type: str
86 sample: eastus
87 status:
88 description:
89 - The status of the replication at the time the operation was called.
90 returned: always
91 type: complex
92 contains:
93 message:
94 description:
95 - The detailed message for the status, including alerts and error messages.
96 returned: always
97 type: str
98 sample: "The replication is ready."
99 timestamp:
100 description:
101 - The timestamp when the status was changed to the current value.
102 returned: always
103 type: str
104 sample: "2017-03-01T23:15:37.0707808Z"
105 '''
106
107 from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase
108
109 try:
110 from azure.core.exceptions import ResourceNotFoundError
111 except ImportError:
112 # This is handled in azure_rm_common
113 pass
114
115
116 class AzureRMReplicationsFacts(AzureRMModuleBase):
117 def __init__(self):
118 # define user inputs into argument
119 self.module_arg_spec = dict(
120 resource_group=dict(
121 type='str',
122 required=True
123 ),
124 registry_name=dict(
125 type='str',
126 required=True
127 ),
128 replication_name=dict(
129 type='str',
130 required=True
131 )
132 )
133 # store the results of the module operation
134 self.results = dict(
135 changed=False,
136 ansible_facts=dict()
137 )
138 self.resource_group = None
139 self.registry_name = None
140 self.replication_name = None
141 super(AzureRMReplicationsFacts, self).__init__(self.module_arg_spec, supports_tags=False, supports_check_mode=True)
142
143 def exec_module(self, **kwargs):
144 for key in self.module_arg_spec:
145 setattr(self, key, kwargs[key])
146
147 if (self.resource_group is not None and
148 self.registry_name is not None and
149 self.replication_name is not None):
150 self.results['replications'] = self.get()
151 return self.results
152
153 def get(self):
154 '''
155 Gets facts of the specified Replication.
156
157 :return: deserialized Replicationinstance state dictionary
158 '''
159 response = None
160 results = {}
161 try:
162 response = self.containerregistry_client.replications.get(resource_group_name=self.resource_group,
163 registry_name=self.registry_name,
164 replication_name=self.replication_name)
165 self.log("Response : {0}".format(response))
166 except ResourceNotFoundError as e:
167 self.log('Could not get facts for Replications: {0}'.format(str(e)))
168
169 if response is not None:
170 results[response.name] = response.as_dict()
171
172 return results
173
174
175 def main():
176 AzureRMReplicationsFacts()
177
178
179 if __name__ == '__main__':
180 main()