From aceaa1ca40239850c39e01bfb365a8ca8000c4c0 Mon Sep 17 00:00:00 2001 From: Danny Hermes Date: Thu, 28 Jan 2016 18:47:31 -0800 Subject: [PATCH] Removing restriction to only user accounts in resource manager. --- gcloud/resource_manager/client.py | 30 ---------------------- gcloud/resource_manager/connection.py | 11 -------- gcloud/resource_manager/test_client.py | 10 -------- gcloud/resource_manager/test_connection.py | 7 ----- 4 files changed, 58 deletions(-) diff --git a/gcloud/resource_manager/client.py b/gcloud/resource_manager/client.py index 9362659cbad5..74844019babc 100644 --- a/gcloud/resource_manager/client.py +++ b/gcloud/resource_manager/client.py @@ -48,36 +48,6 @@ class Client(BaseClient): _connection_class = Connection - @classmethod - def from_service_account_json(cls, *args, **kwargs): - """Factory to retrieve JSON credentials while creating client. - - The behavior from the parent class is disabled here since the Resource - Manager API can only use credentials from a user account, not a - service account. - - :raises: :class:`NotImplementedError ` - always. - """ - raise NotImplementedError('A service account cannot be used with the ' - 'Resource Manager API. Only user ' - 'credentials can be used.') - - @classmethod - def from_service_account_p12(cls, *args, **kwargs): - """Factory to retrieve P12 credentials while creating client. - - The behavior from the parent class is disabled here since the Resource - Manager API can only use credentials from a user account, not a - service account. - - :raises: :class:`NotImplementedError ` - always. - """ - raise NotImplementedError('A service account cannot be used with the ' - 'Resource Manager API. Only user ' - 'credentials can be used.') - def new_project(self, project_id, name=None, labels=None): """Creates a :class:`.Project` bound to the current client. diff --git a/gcloud/resource_manager/connection.py b/gcloud/resource_manager/connection.py index 1e8305fc3641..49ef2fc2e57b 100644 --- a/gcloud/resource_manager/connection.py +++ b/gcloud/resource_manager/connection.py @@ -15,8 +15,6 @@ """Create / interact with gcloud.resource_manager connections.""" -from oauth2client.client import AssertionCredentials - from gcloud import connection as base_connection @@ -42,12 +40,3 @@ class Connection(base_connection.JSONConnection): SCOPE = ('https://www.googleapis.com/auth/cloud-platform',) """The scopes required for authenticating as a Resouce Manager consumer.""" - - def __init__(self, credentials=None, http=None): - if isinstance(credentials, AssertionCredentials): - message = ('credentials (%r) inherits from ' - 'AppAssertionCredentials. Only user credentials can be ' - 'used with the Resource Manager API. ' % (credentials,)) - raise TypeError(message) - - super(Connection, self).__init__(credentials=credentials, http=http) diff --git a/gcloud/resource_manager/test_client.py b/gcloud/resource_manager/test_client.py index 2ad2873bf33e..d6713acd5ca3 100644 --- a/gcloud/resource_manager/test_client.py +++ b/gcloud/resource_manager/test_client.py @@ -88,16 +88,6 @@ def test_constructor(self): self.assertEqual(client.connection._credentials, credentials) self.assertEqual(client.connection._http, http) - def test_from_service_account_json_factory(self): - klass = self._getTargetClass() - with self.assertRaises(NotImplementedError): - klass.from_service_account_json() - - def test_from_service_account_p12_factory(self): - klass = self._getTargetClass() - with self.assertRaises(NotImplementedError): - klass.from_service_account_p12() - def test_new_project_factory(self): from gcloud.resource_manager.project import Project diff --git a/gcloud/resource_manager/test_connection.py b/gcloud/resource_manager/test_connection.py index de47592f990c..cce5cd95da1d 100644 --- a/gcloud/resource_manager/test_connection.py +++ b/gcloud/resource_manager/test_connection.py @@ -24,13 +24,6 @@ def _getTargetClass(self): def _makeOne(self, *args, **kw): return self._getTargetClass()(*args, **kw) - def test_constructor_with_assertion(self): - from oauth2client.client import AssertionCredentials - - credentials = AssertionCredentials(None) - with self.assertRaises(TypeError): - self._makeOne(credentials=credentials) - def test_build_api_url_no_extra_query_params(self): conn = self._makeOne() URI = '/'.join([