Beispiel #1
0
def translation(graphql_id):
    """Get translations for the GraphQL ID of a id_pair_xlate_group.

    Args:
        None

    Returns:
        result: AgentPair object

    """
    # Initialize key variables
    xlate_query = '''\
{
  agentXlate(id: "IDENTIFIER") {
    id
    agentProgram
    translation
    language {
      code
    }
  }
}
'''.replace('IDENTIFIER', graphql_id)

    # Get data from API server
    xlate_data = get(xlate_query)
    result = AgentPair([AgentXlate(xlate_data)])
    return result
Beispiel #2
0
def translations():
    """Get translations for all id_pair_xlate_group GraphQL IDs.

    Args:
        None

    Returns:
        result: AgentPair object

    """
    # Initialize key variables
    query = '''\
{
  allAgentXlate {
    edges {
      node {
        id
        agentProgram
        translation
        language {
          code
        }
      }
    }
  }
}
'''
    # Get translations from API server
    query_result = get(query)
    result = AgentPair(AgentXlates(query_result).agents())
    return result
Beispiel #3
0
def datapoints():
    """Get DataPoints entry for all database datapoints.

    Args:
        None

    Returns:
        result: DataPoints object

    """
    # Initialize key variables
    query = """\
{
  allDatapoints {
    edges {
      cursor
      node {
        id
        idxDatapoint
        agent {
          agentProgram
          agentPolledTarget
          idxPairXlateGroup
          pairXlateGroup{
            id
          }
        }
        glueDatapoint {
          edges {
            node {
              pair {
                key
                value
              }
            }
          }
        }
      }
    }
    pageInfo {
      startCursor
      endCursor
      hasNextPage
      hasPreviousPage
    }
  }
}
"""

    # Get data from API server
    data = get(query)
    result = DataPoints(data)
    return result
Beispiel #4
0
def datapoint(graphql_id):
    """Get translations for the GraphQL ID of a datapoint query.

    Args:
        graphql_id: GraphQL ID

    Returns:
        result: DataPoint object

    """
    # Initialize key variables
    query = '''\
{
  datapoint(id: "IDENTIFIER") {
    id
    idxDatapoint
    agent {
      agentProgram
      agentPolledTarget
      idxPairXlateGroup
      pairXlateGroup{
        id
      }
    }
    glueDatapoint {
      edges {
        node {
          pair {
            key
            value
          }
        }
      }
    }
  }
}
'''.replace('IDENTIFIER', graphql_id)

    # Get data from API server
    data = None

    # Get data from remote system
    try:
        data = get(query)
    except:
        _exception = sys.exc_info()
        log_message = ('Cannot connect to pattoo web API')
        log.log2exception(80014, _exception, message=log_message)

    # Return
    result = DataPoint(data)
    return result
Beispiel #5
0
def agents():
    """Process an allAgent query.

    Args:
        None

    Returns:
        result: DataPoints object

    """
    # Initialize key variables
    query = """\
{
  allAgent {
    edges {
      node {
        id
        idxAgent
        agentPolledTarget
        agentProgram
        pairXlateGroup{
          id
        }
      }
    }
    pageInfo {
      startCursor
      endCursor
      hasNextPage
      hasPreviousPage
    }
  }
}
"""

    # Get data from API server
    data = get(query)
    result = Agents(data)
    return result
Beispiel #6
0
def translations():
    """Get translations for all id_pair_xlate_group GraphQL IDs.

    Args:
        None

    Returns:
        result: KeyPair object

    """
    # Initialize key variables
    query = '''\
{
  allPairXlateGroup {
    edges {
      node {
        idxPairXlateGroup
        id
        pairXlatePairXlateGroup {
          edges {
            node {
              key
              translation
              units
              language {
                code
              }
            }
          }
        }
      }
    }
  }
}
'''
    # Get translations from API server
    query_result = get(query)
    result = KeyPair(PairXlates(query_result).datapoints())
    return result
Beispiel #7
0
def translation(graphql_id):
    """Get translations for the GraphQL ID of a id_pair_xlate_group.

    Args:
        None

    Returns:
        result: KeyPair object

    """
    # Initialize key variables
    xlate_query = '''\
{
  pairXlateGroup(id: "IDENTIFIER") {
    idxPairXlateGroup
    id
    pairXlatePairXlateGroup {
      edges {
        node {
          key
          translation
          units
            language {
              code
            }
        }
      }
    }
  }
}
'''.replace('IDENTIFIER', graphql_id)

    # Get data from API server
    xlate_data = get(xlate_query)
    result = KeyPair([PairXlate(xlate_data)])
    return result
Beispiel #8
0
def datapoints_agent(graphql_id, screen=None):
    """Get translations for the GraphQL ID of a datapointAgent query.

    Args:
        graphql_id: GraphQL ID
        screen: GraphQL filter for screening results

    Returns:
        result: DataPoint object

    """
    # Initialize key variables
    query = '''\
{
  agent(id: "IDENTIFIER") {
    datapointAgent SCREEN {
      edges {
        cursor
        node {
          id
          idxDatapoint
          idxAgent
          agent {
            agentProgram
            agentPolledTarget
            idxPairXlateGroup
            pairXlateGroup{
              id
            }
          }
          glueDatapoint {
            edges {
              node {
                pair {
                  key
                  value
                }
              }
            }
          }
        }
      }
      pageInfo {
        startCursor
        endCursor
        hasNextPage
        hasPreviousPage
      }
    }
  }
}
'''.replace('IDENTIFIER', graphql_id)

    if screen is None:
        query = query.replace('SCREEN', '')
    else:
        query = query.replace('SCREEN', screen)

    # Get data from API server
    data = None

    # Get data from remote system
    try:
        data = get(query)
    except:
        _exception = sys.exc_info()
        log_message = ('Cannot connect to pattoo web API')
        log.log2exception(80016, _exception, message=log_message)

    # Return
    result = DataPointsAgent(data)
    return result