Completed
Pull Request — master (#414)
by Anthony
02:34
created

CreateResourceAction   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %
Metric Value
dl 0
loc 24
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 23 1
1
from azure.mgmt.resource import (
2
    ResourceManagementClient,
3
    ResourceManagementClientConfiguration)
4
from azure.mgmt.resource import GenericResource
5
6
from lib.base import AzureBaseResourceManagerAction
7
8
9
class CreateResourceAction(AzureBaseResourceManagerAction):
10
    def run(self, subscription_id, group_name, resource_name,
11
            resource_provider_namespace, resource_type, parent_resource_path,
12
            api_version, location):
13
        credentials = self.credentials
14
15
        resource_client = ResourceManagementClient(
16
            ResourceManagementClientConfiguration(
17
                credentials,
18
                subscription_id))
19
20
        result = resource_client.resources.create_or_update(
21
            group_name,
22
            resource_provider_namespace=resource_provider_namespace,
23
            parent_resource_path=parent_resource_path,
24
            resource_type=resource_type,
25
            resource_name=resource_name,
26
            api_version=api_version,
27
            resource=GenericResource(
28
                location=location,
29
                properties={},
30
            ),
31
        )
32
        return result
33