コード例 #1
0
    def test_put(self):
        responses.add(responses.PUT,
                      self.url,
                      status=200,
                      json=self.success_json)

        with self.setup_auth():
            body = {"content": "some_content"}
            module = FakeModule({
                "scopes": "foo",
                "service_account_file": "file_name",
                "project": "test_project",
                "auth_kind": "serviceaccount",
            })

            session = GcpSession(module, "mock")
            resp = session.put(self.url, body={"foo": "bar"})

            # Ensure Google header added.
            assert responses.calls[0].request.headers[
                "User-Agent"] == self.user_agent

            # Ensure proper request was made.
            assert resp.json() == self.success_json
            assert resp.status_code == 200
コード例 #2
0
ファイル: gcp_iam_role.py プロジェクト: zealot00/ansible
def update(module, link, fetch):
    auth = GcpSession(module, 'iam')
    params = {
        'updateMask':
        updateMask(resource_to_request(module),
                   response_to_hash(module, fetch))
    }
    request = resource_to_request(module)
    del request['name']
    return return_if_object(module, auth.put(link, request, params=params))
コード例 #3
0
def update(module, link, fetch):
    auth = GcpSession(module, 'cloudfunctions')
    params = {
        'updateMask':
        updateMask(resource_to_request(module),
                   response_to_hash(module, fetch))
    }
    request = resource_to_request(module)
    del request['name']
    return wait_for_operation(module, auth.put(link, request, params=params))
コード例 #4
0
def update(module, link, kind, fetch):
    auth = GcpSession(module, 'sql')
    return wait_for_operation(module,
                              auth.put(link, resource_to_request(module)))
コード例 #5
0
def update(module, link, kind, fetch):
    update_fields(module, resource_to_request(module),
                  response_to_hash(module, fetch))
    auth = GcpSession(module, 'compute')
    return wait_for_operation(module,
                              auth.put(link, resource_to_request(module)))
コード例 #6
0
ファイル: gcp_pubsub_topic.py プロジェクト: zealot00/ansible
def create(module, link):
    auth = GcpSession(module, 'pubsub')
    return return_if_object(module, auth.put(link,
                                             resource_to_request(module)))
コード例 #7
0
ファイル: gcp_storage_bucket.py プロジェクト: zship/ansible
def update(module, link, kind):
    auth = GcpSession(module, 'storage')
    return return_if_object(module,
                            auth.put(link, resource_to_request(module)), kind)
コード例 #8
0
def update(module, link, kind, fetch):
    auth = GcpSession(module, 'compute')
    return wait_for_operation(module, auth.put(link, resource_to_request(module)))
コード例 #9
0
def update(module, link):
    auth = GcpSession(module, 'container')
    return wait_for_operation(module,
                              auth.put(link, resource_to_request(module)))
コード例 #10
0
def update(module, link):
    auth = GcpSession(module, 'runtimeconfig')
    return return_if_object(module, auth.put(link,
                                             resource_to_request(module)))
コード例 #11
0
def update(module, link):
    auth = GcpSession(module, 'spanner')
    return return_if_object(module, auth.put(link,
                                             resource_to_request(module)))
コード例 #12
0
def update(module, link):
    auth = GcpSession(module, 'serviceusage')
    return wait_for_operation(module,
                              auth.put(link, resource_to_request(module)))
コード例 #13
0
def create(module, link):
    auth = GcpSession(module, 'pubsub')
    return return_if_object(module, auth.put(link, resource_to_request(module)))
コード例 #14
0
def update(module, link, kind):
    auth = GcpSession(module, 'storage')
    return return_if_object(module, auth.put(link, resource_to_request(module)), kind)