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
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))
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))
def update(module, link, kind, fetch): auth = GcpSession(module, 'sql') return wait_for_operation(module, auth.put(link, resource_to_request(module)))
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)))
def create(module, link): auth = GcpSession(module, 'pubsub') return return_if_object(module, auth.put(link, resource_to_request(module)))
def update(module, link, kind): auth = GcpSession(module, 'storage') return return_if_object(module, auth.put(link, resource_to_request(module)), kind)
def update(module, link, kind, fetch): auth = GcpSession(module, 'compute') return wait_for_operation(module, auth.put(link, resource_to_request(module)))
def update(module, link): auth = GcpSession(module, 'container') return wait_for_operation(module, auth.put(link, resource_to_request(module)))
def update(module, link): auth = GcpSession(module, 'runtimeconfig') return return_if_object(module, auth.put(link, resource_to_request(module)))
def update(module, link): auth = GcpSession(module, 'spanner') return return_if_object(module, auth.put(link, resource_to_request(module)))
def update(module, link): auth = GcpSession(module, 'serviceusage') return wait_for_operation(module, auth.put(link, resource_to_request(module)))
def create(module, link): auth = GcpSession(module, 'pubsub') return return_if_object(module, auth.put(link, resource_to_request(module)))
def update(module, link, kind): auth = GcpSession(module, 'storage') return return_if_object(module, auth.put(link, resource_to_request(module)), kind)