'Poll an operation for a result.'

@staticmethod
def execute_api_client_operation_req(orig_req, op_resp, client, operation_timeout=180, poll_interval=5):

    parsed_url = GCPUtils.parse_gcp_url(orig_req.uri)
    project_id = parsed_url['project']
    resource_name = GCPUtils.get_gcp_resource_from_methodId(orig_req.methodId)
    resource = GCPUtils.build_resource_from_name(client, resource_name)
    start_time = time.time()
    complete = False
    attempts = 1
    while (not complete):
        if ((start_time + operation_timeout) >= time.time()):
            op_req = client.globalOperations().get(project=project_id, operation=op_resp['name'])
            op_resp = op_req.execute()
            if (op_resp['status'] != 'DONE'):
                time.sleep(poll_interval)
                attempts += 1
            else:
                complete = True
                if (op_resp['operationType'] == 'delete'):
                    return True
                elif (op_resp['operationType'] in ['insert', 'update', 'patch']):
                    resource_name_singular = GCPUtils.get_entity_name_from_resource_name(resource_name)
                    if ((op_resp['operationType'] == 'insert') or ('entity_name' not in parsed_url)):
                        parsed_url['entity_name'] = GCPUtils.parse_gcp_url(op_resp['targetLink'])['entity_name']
                    args = {'project': project_id, resource_name_singular: parsed_url['entity_name']}
                    new_req = resource.get(**args)
                    resp = new_req.execute()
                    return resp
                else:
                    new_req = resource.list(project=project_id)
                    resp = new_req.execute()
                    return resp
        else:
            raise GCPOperationTimeoutError(('Operation    timed    out:    %s' % op_resp['targetLink']))
