Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 0 additions & 30 deletions gcloud/resource_manager/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 <exceptions.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 <exceptions.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.

Expand Down
11 changes: 0 additions & 11 deletions gcloud/resource_manager/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
"""Create / interact with gcloud.resource_manager connections."""


from oauth2client.client import AssertionCredentials

from gcloud import connection as base_connection


Expand All @@ -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)
10 changes: 0 additions & 10 deletions gcloud/resource_manager/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 0 additions & 7 deletions gcloud/resource_manager/test_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down