Debian Codegraph @

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

raw symbols SCIP
1 #!/usr/bin/python
2 #
3 # GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
4
5 from __future__ import absolute_import, division, print_function
6 __metaclass__ = type
7
8
9 DOCUMENTATION = '''
10 ---
11 module: azure_rm_containerregistryscopemap_info
12 version_added: "3.7.0"
13 short_description: Get Azure Container Registry Scope Map facts
14 description:
15 - Get or list facts for Container Registry Scope Map.
16
17 options:
18 resource_group:
19 description:
20 - The name of the resource group to which the container registry belongs.
21 type: str
22 required: true
23 registry_name:
24 description:
25 - The name of the container registry.
26 type: str
27 required: true
28 name:
29 description:
30 - The name of the container registry scope map.
31 type: str
32
33 extends_documentation_fragment:
34 - azure.azcollection.azure
35
36 author:
37 - magodo (@magodo)
38 - Fred-sun (@Fred-sun)
39
40 '''
41
42 EXAMPLES = '''
43 - name: Get instance of Registry Scope Map
44 azure_rm_containerregistryscopemap_info:
45 resource_group: myResourceGroup
46 registry_name: myRegistry
47 name: myscopemap
48
49 - name: List instances of Registry Scope Map
50 azure_rm_containerregistryscopemap_info:
51 resource_group: myResourceGroup
52 registry_name: myRegistry
53 '''
54
55 RETURN = '''
56 registry_scope_maps:
57 description:
58 - A list of dictionaries containing facts for scope map.
59 returned: always
60 type: complex
61 contains:
62 id:
63 description:
64 - The resource ID.
65 returned: always
66 type: str
67 sample: "/subscriptions/xxx-xxx/resourceGroups/myRG/providers/Microsoft.ContainerRegistry/registries/acr01/scopeMaps/map01"
68 name:
69 description:
70 - The name of the resource.
71 returned: always
72 type: str
73 sample: map01
74 registry_name:
75 description:
76 - The name of the container registry.
77 type: str
78 returned: always
79 sample: registry01
80 resource_group:
81 description:
82 - The name fo the resource group.
83 type: str
84 returned: always
85 sample: myRG
86 actions:
87 description:
88 - The list of scoped permissions for registry artifacts.
89 type: list
90 returned: always
91 sample: ["repositories/test01/content/read"]
92 creation_date:
93 description:
94 - The creation date of scope map.
95 type: str
96 returned: always
97 sample: "2025-07-21T03:15:59.951533Z"
98 description:
99 description:
100 - The user friendly description of the scope map.
101 type: str
102 returned: always
103 sample: "Just for test"
104 provisioning_state:
105 description:
106 - Provisioning state of the resource.
107 type: str
108 returned: always
109 sample: Success
110 system_data:
111 description:
112 - Metadata pertaining to creation and last modification of the resource.
113 type: str
114 returned: always
115 sample: {
116 "created_at": "2025-07-21T03:15:59.287282Z",
117 "created_by": "[email protected]",
118 "created_by_type": "User",
119 "last_modified_at": "2025-07-21T03:15:59.287282Z",
120 "last_modified_by": "[email protected]",
121 "last_modified_by_type": "User"
122 }
123 type:
124 description:
125 - The type of the resource.
126 type: str
127 returned: always
128 sample: 'Microsoft.ContainerRegistry/registries/scopeMaps'
129 type_properties_type:
130 description:
131 - The type of the scope map.
132 type: str
133 returned: always
134 sample: UserDefined
135 '''
136
137 from ansible_collections.azure.azcollection.plugins.module_utils.azure_rm_common import AzureRMModuleBase
138
139
140 class AzureRMContainerRegistryScopeMapInfo(AzureRMModuleBase):
141 def __init__(self):
142 # define user inputs into argument
143 self.module_arg_spec = dict(
144 resource_group=dict(
145 type='str',
146 required=True,
147 ),
148 registry_name=dict(
149 type='str',
150 required=True
151 ),
152 name=dict(
153 type='str'
154 )
155 )
156 # store the results of the module operation
157 self.results = dict(
158 changed=False
159 )
160 self.resource_group = None
161 self.registry_name = None
162 self.name = None
163
164 super(AzureRMContainerRegistryScopeMapInfo, self).__init__(self.module_arg_spec, supports_check_mode=True, supports_tags=False, facts_module=True)
165
166 def exec_module(self, **kwargs):
167
168 for key in list(self.module_arg_spec):
169 setattr(self, key, kwargs[key])
170
171 if self.name:
172 self.results['registry_scope_maps'] = self.get()
173 else:
174 self.results['registry_scope_maps'] = self.list()
175
176 return self.results
177
178 def get(self):
179 try:
180 response = self.containerregistrytoken_client.scope_maps.get(resource_group_name=self.resource_group,
181 registry_name=self.registry_name,
182 scope_map_name=self.name)
183 self.log("Response : {0}".format(response))
184 except Exception as e:
185 self.log("Could not get facts for Registry Scope Map: {0}".format(str(e)))
186 return []
187
188 return [self.format_item(response)]
189
190 def list(self):
191 response = None
192 try:
193 response = self.containerregistrytoken_client.scope_maps.list(resource_group_name=self.resource_group,
194 registry_name=self.registry_name)
195 self.log("Response : {0}".format(response))
196 except Exception as e:
197 self.log("Could not list facts for Registry Scope Map: {0}".format(str(e)))
198
199 return [self.format_item(item) for item in response if response]
200
201 def format_item(self, item):
202 result = item.as_dict()
203 result['resource_group'] = self.resource_group
204 result['registry_name'] = self.registry_name
205
206 return result
207
208
209 def main():
210 AzureRMContainerRegistryScopeMapInfo()
211
212
213 if __name__ == '__main__':
214 main()