コード例 #1
0
 def __init__(self, client=None):
   self.client = client or bigquery.BigqueryV2(
       credentials=auth.get_service_credentials())
   self._unique_row_id = 0
   # For testing scenarios where we pass in a client we do not want a
   # randomized prefix for row IDs.
   self._row_id_prefix = '' if client else uuid.uuid4()
   self._temporary_table_suffix = uuid.uuid4().hex
コード例 #2
0
 def __init__(self, client=None):
   self.client = client or bigquery.BigqueryV2(
       credentials=auth.get_service_credentials())
   self._unique_row_id = 0
   # For testing scenarios where we pass in a client we do not want a
   # randomized prefix for row IDs.
   self._row_id_prefix = '' if client else uuid.uuid4()
   self._temporary_table_suffix = uuid.uuid4().hex
コード例 #3
0
 def test_create_application_client(self):
   try:
     test_args = [
         'test', '--service_account_name', 'abc', '--service_account_key_file',
         os.path.join(os.path.dirname(__file__), '..', 'tests',
                      'data', 'privatekey.p12')]
     with mock.patch.object(sys, 'argv', test_args):
       credentials = auth.get_service_credentials()
       self.assertIsNotNone(credentials)
   except NotImplementedError:
     self.skipTest('service account tests require pyOpenSSL module.')
コード例 #4
0
 def test_create_application_client(self):
     try:
         test_args = [
             'test', '--service_account_name', 'abc',
             '--service_account_key_file',
             os.path.join(os.path.dirname(__file__), '..', 'tests', 'data',
                          'privatekey.p12')
         ]
         with mock.patch.object(sys, 'argv', test_args):
             credentials = auth.get_service_credentials()
             self.assertIsNotNone(credentials)
     except NotImplementedError:
         self.skipTest('service account tests require pyOpenSSL module.')
コード例 #5
0
 def __new__(cls, storage_client=None):
   if storage_client:
     return super(GcsIO, cls).__new__(cls, storage_client)
   else:
     # Create a single storage client for each thread.  We would like to avoid
     # creating more than one storage client for each thread, since each
     # initialization requires the relatively expensive step of initializing
     # credentaials.
     local_state = threading.local()
     if getattr(local_state, 'gcsio_instance', None) is None:
       credentials = auth.get_service_credentials()
       storage_client = storage.StorageV1(credentials=credentials)
       local_state.gcsio_instance = (
           super(GcsIO, cls).__new__(cls, storage_client))
       local_state.gcsio_instance.client = storage_client
     return local_state.gcsio_instance
コード例 #6
0
ファイル: gcsio.py プロジェクト: jasonkuster/incubator-beam
 def __new__(cls, storage_client=None):
   if storage_client:
     return super(GcsIO, cls).__new__(cls, storage_client)
   else:
     # Create a single storage client for each thread.  We would like to avoid
     # creating more than one storage client for each thread, since each
     # initialization requires the relatively expensive step of initializing
     # credentaials.
     local_state = threading.local()
     if getattr(local_state, 'gcsio_instance', None) is None:
       credentials = auth.get_service_credentials()
       storage_client = storage.StorageV1(credentials=credentials)
       local_state.gcsio_instance = (
           super(GcsIO, cls).__new__(cls, storage_client))
       local_state.gcsio_instance.client = storage_client
     return local_state.gcsio_instance
コード例 #7
0
ファイル: apiclient.py プロジェクト: jasonkuster/beam
 def __init__(self, options, environment_version):
     """Initializes a Dataflow API client object."""
     self.standard_options = options.view_as(StandardOptions)
     self.google_cloud_options = options.view_as(GoogleCloudOptions)
     self.environment_version = environment_version
     if self.google_cloud_options.no_auth:
         credentials = None
     else:
         credentials = get_service_credentials()
     self._client = dataflow.DataflowV1b3(
         url=self.google_cloud_options.dataflow_endpoint,
         credentials=credentials,
         get_credentials=(not self.google_cloud_options.no_auth))
     self._storage_client = storage.StorageV1(
         url='https://www.googleapis.com/storage/v1',
         credentials=credentials,
         get_credentials=(not self.google_cloud_options.no_auth))
コード例 #8
0
 def __init__(self, options, environment_version):
   """Initializes a Dataflow API client object."""
   self.standard_options = options.view_as(StandardOptions)
   self.google_cloud_options = options.view_as(GoogleCloudOptions)
   self.environment_version = environment_version
   if self.google_cloud_options.no_auth:
     credentials = None
   else:
     credentials = get_service_credentials()
   self._client = dataflow.DataflowV1b3(
       url=self.google_cloud_options.dataflow_endpoint,
       credentials=credentials,
       get_credentials=(not self.google_cloud_options.no_auth))
   self._storage_client = storage.StorageV1(
       url='https://www.googleapis.com/storage/v1',
       credentials=credentials,
       get_credentials=(not self.google_cloud_options.no_auth))
コード例 #9
0
ファイル: helper.py プロジェクト: sbilac/incubator-beam
def get_datastore(project):
  """Returns a Cloud Datastore client."""
  credentials = auth.get_service_credentials()
  return Datastore(project, credentials)
コード例 #10
0
ファイル: helper.py プロジェクト: jasonkuster/incubator-beam
def get_datastore(project):
  """Returns a Cloud Datastore client."""
  credentials = auth.get_service_credentials()
  return Datastore(project, credentials)