def target_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/global/forwardingRules/{name}/setTarget"
        ]).format(**module.params),
        {u'target': module.params.get('target')},
    )
Beispiel #2
0
def security_policy_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/global/backendServices/{name}/setSecurityPolicy"
        ]).format(**module.params),
        {u'securityPolicy': module.params.get('security_policy')},
    )
def tensorflow_version_update(module, request, response):
    auth = GcpSession(module, 'tpu')
    auth.post(
        ''.join([
            "https://tpu.googleapis.com/v1/",
            "projects/{project}/locations/{zone}/nodes/{name}:reimage"
        ]).format(**module.params),
        {u'tensorflowVersion': module.params.get('tensorflow_version')},
    )
def proxy_header_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/global/targetTcpProxies/{name}/setProxyHeader"
        ]).format(**module.params),
        {u'proxyHeader': module.params.get('proxy_header')},
    )
def quic_override_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/global/targetHttpsProxies/{name}/setQuicOverride"
        ]).format(**module.params),
        {u'quicOverride': module.params.get('quic_override')},
    )
def size_gb_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/regions/{region}/disks/{name}/resize"
        ]).format(**module.params),
        {u'sizeGb': module.params.get('size_gb')},
    )
def ip_cidr_range_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/regions/{region}/subnetworks/{name}/expandIpCidrRange"
        ]).format(**module.params),
        {u'ipCidrRange': module.params.get('ip_cidr_range')},
    )
def private_ip_google_access_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/regions/{region}/subnetworks/{name}/setPrivateIpGoogleAccess"
        ]).format(**module.params),
        {
            u'privateIpGoogleAccess':
            module.params.get('private_ip_google_access')
        },
    )
Beispiel #9
0
def labels_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/global/images/{name}/setLabels"
        ]).format(**module.params),
        {
            u'labels': module.params.get('labels'),
            u'labelFingerprint': response.get('labelFingerprint')
        },
    )
def url_map_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/targetHttpsProxies/{name}/setUrlMap"
        ]).format(**module.params),
        {
            u'urlMap':
            replace_resource_dict(module.params.get(u'url_map', {}),
                                  'selfLink')
        },
    )
def ssl_certificates_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/targetHttpsProxies/{name}/setSslCertificates"
        ]).format(**module.params),
        {
            u'sslCertificates':
            replace_resource_dict(module.params.get('ssl_certificates', []),
                                  'selfLink')
        },
    )
def ssl_policy_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join([
            "https://www.googleapis.com/compute/v1/",
            "projects/{project}/global/targetHttpsProxies/{name}/setSslPolicy"
        ]).format(**module.params),
        {
            u'sslPolicy':
            replace_resource_dict(module.params.get(u'ssl_policy', {}),
                                  'selfLink')
        },
    )
def set_default(module):
    res = {
        'project': module.params['project'],
        'model': replace_resource_dict(module.params['model'], 'name'),
        'name': module.params['name']
    }
    link = "https://ml.googleapis.com/v1/projects/{project}/models/{model}/versions/{name}:setDefault".format(
        **res)

    auth = GcpSession(module, 'mlengine')
    return_if_object(module, auth.post(link))
Beispiel #14
0
    def kms_encrypt(self, module):
        payload = {"plaintext": module.params['plaintext']}

        if module.params['additional_authenticated_data']:
            payload['additionalAuthenticatedData'] = module.params[
                'additional_authenticated_data']

        auth = GcpSession(module, 'cloudkms')
        url = "https://cloudkms.googleapis.com/v1/projects/{projects}/locations/{locations}/" \
            "keyRings/{key_ring}/cryptoKeys/{crypto_key}:encrypt".format(**module.params)
        response = auth.post(url, body=payload)
        return response.json()['ciphertext']
    def list_instances(self):
        auth = GcpSession(self.module, 'compute')
        response = return_if_object(
            self.module,
            auth.post(self._list_instances_url(), {'instanceState': 'ALL'}),
            'compute#instanceGroupsListInstances')

        # Transform instance list into a list of selfLinks for diffing with module parameters
        instances = []
        for instance in response.get('items', []):
            instances.append(instance['instance'])
        return instances
def create(module, link, kind):
    auth = GcpSession(module, 'compute')
    return wait_for_operation(module,
                              auth.post(link, resource_to_request(module)))
def create(module, link):
    auth = GcpSession(module, 'cloudfunctions')
    return wait_for_operation(module,
                              auth.post(link, resource_to_request(module)))
Beispiel #18
0
 def stop(self):
     auth = GcpSession(self.module, 'cloudtasks')
     return_if_object(self.module, auth.post(self._stop_url()))
Beispiel #19
0
def node_template_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/zones/{zone}/nodeGroups/{name}/setNodeTemplate"]).format(**module.params),
        {u'nodeTemplate': replace_resource_dict(module.params.get(u'node_template', {}), 'selfLink')},
    )
Beispiel #20
0
def create(module, link, kind):
    auth = GcpSession(module, 'storage')
    return return_if_object(module,
                            auth.post(link, resource_to_request(module)), kind)
Beispiel #21
0
def create_change(original, updated, module):
    auth = GcpSession(module, 'dns')
    return return_if_change_object(
        module,
        auth.post(collection(module),
                  resource_to_change_request(original, updated, module)))
def create(module, link):
    auth = GcpSession(module, 'resourcemanager')
    return wait_for_operation(module, auth.post(link, resource_to_request(module)))
def create(module):
    auth = GcpSession(module, 'iam')
    json_content = return_if_object(module, auth.post(self_link(module), resource_to_request(module)))
    with open(module.params['path'], 'w') as f:
        private_key_contents = to_native(base64.b64decode(json_content['privateKeyData']))
        f.write(private_key_contents)
Beispiel #24
0
def create(module, link):
    auth = GcpSession(module, 'spanner')
    return wait_for_operation(module,
                              auth.post(link, resource_to_create(module)))
Beispiel #25
0
def delete(module, link):
    auth = GcpSession(module, 'serviceusage')
    return wait_for_operation(module, auth.post(link))
 def remove_instances(self, instances):
     auth = GcpSession(self.module, 'compute')
     wait_for_operation(
         self.module,
         auth.post(self._remove_instances_url(),
                   self._build_request(instances)))
Beispiel #27
0
def create(module, link):
    auth = GcpSession(module, 'cloudtasks')
    return return_if_object(module, auth.post(link,
                                              resource_to_request(module)))
Beispiel #28
0
def create(module, link):
    auth = GcpSession(module, 'runtimeconfig')
    return return_if_object(module, auth.post(link,
                                              resource_to_request(module)))
Beispiel #29
0
def target_update(module, request, response):
    auth = GcpSession(module, 'compute')
    auth.post(
        ''.join(["https://www.googleapis.com/compute/v1/", "projects/{project}/regions/{region}/forwardingRules/{name}/setTarget"]).format(**module.params),
        {u'target': replace_resource_dict(module.params.get(u'target', {}), 'selfLink')},
    )