Metadata-Version: 2.4
Name: garf-bid-manager
Version: 1.0.1
Summary: Garf implementation for Google Bid Manager API
Author-email: Andrei Markin <amarkin@google.com>, "Google Inc. (gTech gPS CSE team)" <no-reply@google.com>
License: Apache 2.0
Classifier: Development Status :: 4 - Beta
Classifier: Programming Language :: Python
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: garf-core>=1.0.0
Requires-Dist: garf-io>=1.0.0
Requires-Dist: google-api-python-client
Requires-Dist: google_auth_oauthlib
Requires-Dist: tenacity

# `garf` for Bid Manager API

[![PyPI](https://img.shields.io/pypi/v/garf-bid-manager?logo=pypi&logoColor=white&style=flat-square)](https://pypi.org/project/garf-bid-manager)
[![Downloads PyPI](https://img.shields.io/pypi/dw/garf-bid-manager?logo=pypi)](https://pypi.org/project/garf-bid-manager/)

`garf-bid-manager` simplifies fetching data from Bid Manager API using SQL-like queries.

## Prerequisites

* [Bid Manager API](https://console.cloud.google.com/apis/library/analytics.googleapis.com) enabled.
* [Credentials](https://developers.google.com/bid-manager/guides/get-started/generate-credentials) configured.

## Installation

`pip install garf-bid-manager`

## Usage

### Run as a library
```
from garf.community.google.bid_manager import BidManagerApiReportFetcher
from garf.io import writer

# Fetch report
query = """
  SELECT
    advertiser_name,
    metric_clicks AS clicks
  FROM standard
  WHERE advertiser = 1
    AND dataRange IN (2025-01-01, 2025-12-31)
"""
fetched_report = BidManagerApiReportFetcher() .fetch(query, query=query)

# Write report to console
console_writer = writer.create_writer('console')
console_writer.write(fetched_report, 'output')
```

### Run via CLI

> Install `garf-executors` package to run queries via CLI (`pip install garf-executors`).

```
garf <PATH_TO_QUERIES> --source bid-manager \
  --output <OUTPUT_TYPE> \
  --source.<SOURCE_PARAMETER=VALUE>
```

where:

* `<PATH_TO_QUERIES>` - local or remove files containing queries
* `output` - output supported by [`garf-io` library](https://google.github.io/garf/usage/writers/).
* `<SOURCE_PARAMETER=VALUE` - key-value pairs to refine fetching, check [available source parameters](#available-source-parameters).

## Available source parameters

| name | values| comments |
|----- | ----- | -------- |
| `credentials_file`   | File with Oauth or service account credentials | You can expose `credentials_file` as `GARF_BID_MANAGER_CREDENTIALS_FILE` ENV variable|
| `auth_mode`   | Type of authentication: `oauth` or `service_account` | `oauth` is the default mode|
