Skip to content

Commit

Permalink
chore: additional replacements to read the project id from google.auth (
Browse files Browse the repository at this point in the history
#166)

* feat: events samples: get project_id from auth.default

* lint fix

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

* 🦉 Updates from OwlBot post-processor

See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md

Co-authored-by: Anthonios Partheniou <[email protected]>
Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored and dandhlee committed Dec 2, 2022
1 parent ac66ffe commit 8427194
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
# limitations under the License.

import argparse
import os

project_id = os.environ["GOOGLE_CLOUD_PROJECT"]
import google.auth

project_id = google.auth.default()[1]


def main(project_id, dataset_id, table_id):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def main(bucket_name):
# Import user events into a catalog from GCS using Retail API

import time
import google.auth

from google.cloud.retail import (
GcsSource,
Expand All @@ -31,7 +32,7 @@ def main(bucket_name):
)

# Read the project number from the environment variable
project_id = os.getenv("GOOGLE_CLOUD_PROJECT")
project_id = google.auth.default()[1]

# Read bucket name from the environment variable
bucket_name = os.getenv("EVENTS_BUCKET_NAME")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,23 @@
# Import user events into a catalog from inline source using Retail API
#
import datetime
import os
import random
import string
import time

import google.auth

from google.cloud.retail import (
ImportUserEventsRequest,
UserEvent,
UserEventInlineSource,
UserEventInputConfig,
UserEventServiceClient,
)

from google.protobuf.timestamp_pb2 import Timestamp

project_id = os.getenv("GOOGLE_CLOUD_PROJECT")
project_id = google.auth.default()[1]

default_catalog = "projects/{0}/locations/global/catalogs/default_catalog".format(
project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
# [START retail_purge_user_event]
# Import user events into a catalog from inline source using Retail API
#
import os
import google.auth

from google.cloud.retail import PurgeUserEventsRequest, UserEventServiceClient

from setup_events.setup_cleanup import write_user_event

project_id = os.getenv("GOOGLE_CLOUD_PROJECT")
project_id = google.auth.default()[1]

default_catalog = "projects/{0}/locations/global/catalogs/default_catalog".format(
project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
# [START retail_rejoin_user_event]
# Import user events into a catalog from inline source using Retail API
#
import os
import google.auth

from google.cloud.retail import RejoinUserEventsRequest, UserEventServiceClient

from setup_events.setup_cleanup import purge_user_event, write_user_event

project_id = os.getenv("GOOGLE_CLOUD_PROJECT")
project_id = google.auth.default()[1]

default_catalog = "projects/{0}/locations/global/catalogs/default_catalog".format(
project_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import datetime
import os

import google.auth

from setup_cleanup import create_bucket, upload_blob

project_id = os.environ["GOOGLE_CLOUD_PROJECT"]
project_id = google.auth.default()[1]
timestamp_ = datetime.datetime.now().timestamp().__round__()
bucket_name = os.environ["EVENTS_BUCKET_NAME"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@

import datetime
import json
import os
import re
import shlex
import subprocess

from google.api_core.exceptions import NotFound
import google.auth

from google.cloud import bigquery
from google.cloud import storage
from google.cloud.retail import ProductDetail, PurgeUserEventsRequest, \
UserEvent, UserEventServiceClient, WriteUserEventRequest
from google.cloud.retail_v2 import Product

from google.protobuf.timestamp_pb2 import Timestamp

project_id = os.getenv('GOOGLE_CLOUD_PROJECT')
project_id = google.auth.default()[1]
default_catalog = "projects/{0}/locations/global/catalogs/default_catalog".format(
project_id)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,16 @@
# Import user events into a catalog from inline source using Retail API
#
import datetime
import os

import google.auth

from google.cloud.retail import UserEvent, UserEventServiceClient, WriteUserEventRequest

from google.protobuf.timestamp_pb2 import Timestamp

from setup_events.setup_cleanup import purge_user_event

project_id = os.getenv("GOOGLE_CLOUD_PROJECT")
project_id = google.auth.default()[1]

default_catalog = "projects/{0}/locations/global/catalogs/default_catalog".format(
project_id
Expand Down

0 comments on commit 8427194

Please sign in to comment.