Esempio n. 1
0
def lineitem():
    if project.verbose: print('LINEITEM')

    if 'read' in project.task:
        advertisers = []
        insertion_orders = []
        line_items = []

        if 'advertisers' in project.task['read']:
            advertisers = get_rows(project.task['auth'],
                                   project.task['read']['advertisers'])

        elif 'insertion_orders' in project.task['read']:
            insertion_orders = get_rows(
                project.task['auth'], project.task['read']['insertion_orders'])

        elif 'line_items' in project.task['read']:
            line_items = get_rows(project.task['auth'],
                                  project.task['read']['line_items'])

        rows = lineitem_read(project.task['auth'], advertisers,
                             insertion_orders, line_items)

        if rows:
            if 'bigquery' in project.task['read']['out']:
                project.task['read']['out']['bigquery'][
                    'schema'] = LineItem_Read_Schema
                project.task['read']['out']['bigquery']['skip_rows'] = 0

            put_rows(project.task['auth'], project.task['read']['out'], rows)

    elif 'write' in project.task:
        rows = get_rows(project.task['auth'], project.task['write'])
        lineitem_write(project.task['auth'], rows,
                       project.task['write'].get('dry_run', True))
Esempio n. 2
0
def main():

  parser = argparse.ArgumentParser(
    formatter_class=argparse.RawDescriptionHelpFormatter,
    description=textwrap.dedent('''\
      Command line interface for fetching line items via legacy API.
      Helps developers quickly debug lineitem issues or permissions access issues.

      Example: python helper.py [line item id] -u [user credentials]
  '''))

  parser = argparse.ArgumentParser()
  parser.add_argument('lineitem', help='lineitem ID to pull schema, or "list" to get index')

  # initialize project
  project.from_commandline(parser=parser, arguments=('-u', '-c', '-s', '-v'))
  auth = 'service' if project.args.service else 'user'

  # print lineitem
  for row in lineitem_read(auth, lineitems=[project.args.lineitem]):
    print(row)
Esempio n. 3
0
#  See the License for the specific language governing permissions and
#  limitations under the License.
#
###########################################################################
"""Command line interface for fetching line items via API.

Helps developers quickl debug lineitem issues or permissions access issues.

For example: https://developers.google.com/bid-manager/v1/lineitems/downloadlineitems
python lineitem/helper.py [line item id] -u [credentials]
"""

import argparse

from starthinker.util.project import project
from starthinker.util.dbm import lineitem_read, lineitem_write

if __name__ == "__main__":

    # get parameters
    parser = argparse.ArgumentParser()
    parser.add_argument(
        'lineitem', help='lineitem ID to pull schema, or "list" to get index')

    # initialize project
    project.from_commandline(parser=parser)
    auth = 'service' if project.args.service else 'user'

    for row in lineitem_read(auth, lineitems=[project.args.lineitem]):
        print(row)