Skip to content

Commit 3e7772e

Browse files
committed
Remove fields implementation.
This was copy-pasted from Storage and not thought through yet.
1 parent 602013d commit 3e7772e

File tree

4 files changed

+15
-63
lines changed

4 files changed

+15
-63
lines changed

runtimeconfig/google/cloud/runtimeconfig/config.py

+5-38
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ def exists(self, client=None):
159159
except NotFound:
160160
return False
161161

162-
def reload(self, client=None, fields=None):
162+
def reload(self, client=None):
163163
"""API call: reload the config via a ``GET`` request.
164164
165165
This method will reload the newest data for the config.
@@ -171,25 +171,15 @@ def reload(self, client=None, fields=None):
171171
:data:`NoneType <types.NoneType>`
172172
:param client: the client to use. If not passed, falls back to
173173
the client stored on the current config.
174-
175-
:type fields: string or ``NoneType``
176-
:param fields: Selector specifying which fields to include in a
177-
partial response. Must be a list of fields. For example
178-
to get a partial response with just the name and
179-
description: 'name,description'
180174
"""
181175
client = self._require_client(client)
182-
query_params = {}
183-
if fields is not None:
184-
query_params['fields'] = fields
185176

186177
# We assume the config exists. If it doesn't it will raise a NotFound
187178
# exception.
188-
resp = client.connection.api_request(method='GET', path=self.path,
189-
query_params=query_params)
179+
resp = client.connection.api_request(method='GET', path=self.path)
190180
self._set_properties(api_response=resp)
191181

192-
def get_variable(self, variable_name, fields=None, client=None):
182+
def get_variable(self, variable_name, client=None):
193183
"""API call: get a variable via a ``GET`` request.
194184
195185
This will return None if the variable doesn't exist::
@@ -205,12 +195,6 @@ def get_variable(self, variable_name, fields=None, client=None):
205195
:type variable_name: string
206196
:param variable_name: The name of the variable to retrieve.
207197
208-
:type fields: string or ``NoneType``
209-
:param fields: Selector specifying which fields to include in a
210-
partial response. Must be a list of fields. For example
211-
to get a partial response with just the name and value:
212-
'name,value'
213-
214198
:type client: :class:`~google.cloud.runtimeconfig.client.Client` or
215199
``NoneType``
216200
:param client: Optional. The client to use. If not passed, falls back
@@ -222,13 +206,12 @@ def get_variable(self, variable_name, fields=None, client=None):
222206
client = self._require_client(client)
223207
variable = Variable(config=self, name=variable_name)
224208
try:
225-
variable.reload(fields=fields, client=client)
209+
variable.reload(client=client)
226210
return variable
227211
except NotFound:
228212
return None
229213

230-
def list_variables(self, page_size=None, page_token=None, filter_=None,
231-
fields=None, client=None):
214+
def list_variables(self, page_size=None, page_token=None, client=None):
232215
"""API call: list variables for this config.
233216
234217
This only lists variable names, not the values.
@@ -243,16 +226,6 @@ def list_variables(self, page_size=None, page_token=None, filter_=None,
243226
:param page_token: opaque marker for the next "page" of variables. If
244227
not passed, will return the first page of variables.
245228
246-
:type filter_: string or ``NoneType``
247-
:param filter_: optional filter used to filter variables.
248-
249-
:type fields: string or ``NoneType``
250-
:param fields: Selector specifying which fields to include in a
251-
partial response. Must be a list of fields. For example
252-
to get a partial response with just the next page token
253-
and the name of each variable returned:
254-
'variables/name,nextPageToken'
255-
256229
:type client: :class:`~google.cloud.runtimeconfig.client.Client` or
257230
``NoneType``
258231
:param client: Optional. The client to use. If not passed, falls back
@@ -273,12 +246,6 @@ def list_variables(self, page_size=None, page_token=None, filter_=None,
273246
if page_token is not None:
274247
params['pageToken'] = page_token
275248

276-
if filter_ is not None:
277-
params['filter'] = filter_
278-
279-
if fields is not None:
280-
params['fields'] = fields
281-
282249
path = '%s/variables' % (self.path,)
283250
client = self._require_client(client)
284251
connection = client.connection

runtimeconfig/google/cloud/runtimeconfig/variable.py

+6-15
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,10 @@ def value(self):
8181
:returns: The value of the variable or ``None`` if the property
8282
is not set locally.
8383
"""
84-
if 'value' in self._properties:
85-
return base64.b64decode(self._properties['value'])
86-
return None
84+
value = self._properties.get('value')
85+
if value is not None:
86+
value = base64.b64decode(value)
87+
return value
8788

8889
@property
8990
def state(self):
@@ -166,32 +167,22 @@ def exists(self, client=None):
166167
except NotFound:
167168
return False
168169

169-
def reload(self, fields=None, client=None):
170+
def reload(self, client=None):
170171
"""API call: reload the variable via a ``GET`` request.
171172
172173
This method will reload the newest data for the variable.
173174
174175
See:
175176
https://cloud.google.com/deployment-manager/runtime-configurator/reference/rest/v1beta1/projects.configs/get
176177
177-
:type fields: string or ``NoneType``
178-
:param fields: Selector specifying which fields to include in a
179-
partial response. Must be a list of fields. For example
180-
to get a partial response with just the name and value:
181-
'name,value'
182-
183178
:type client: :class:`google.cloud.runtimeconfig.client.Client` or
184179
:data:`NoneType <types.NoneType>`
185180
:param client: the client to use. If not passed, falls back to
186181
the client stored on the current config.
187182
"""
188183
client = self._require_client(client)
189-
query_params = {}
190-
if fields is not None:
191-
query_params['fields'] = fields
192184

193185
# We assume the variable exists. If it doesn't it will raise a NotFound
194186
# exception.
195-
resp = client.connection.api_request(method='GET', path=self.path,
196-
query_params=query_params)
187+
resp = client.connection.api_request(method='GET', path=self.path)
197188
self._set_properties(api_response=resp)

runtimeconfig/unit_tests/test_config.py

+2-8
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ def test_exists_hit_w_alternate_client(self):
8282
self.assertEqual(req['path'], '/%s' % (self.CONFIG_PATH,))
8383
self.assertEqual(req['query_params'], {'fields': 'name'})
8484

85-
def test_reload_w_no_fields(self):
85+
def test_reload_w_empty_resource(self):
8686
RESOURCE = {}
8787
conn = _Connection(RESOURCE)
8888
client = _Client(project=self.PROJECT, connection=conn)
8989
config = self._makeOne(name=self.CONFIG_NAME, client=client)
9090

91-
config.reload(fields='')
91+
config.reload()
9292

9393
self.assertEqual(len(conn._requested), 1)
9494
req = conn._requested[0]
@@ -250,8 +250,6 @@ def test_list_variables_defaults(self):
250250
def test_list_variables_explicit(self):
251251
from google.cloud.runtimeconfig.variable import Variable
252252

253-
FILTER = 'filter'
254-
FIELDS = 'variables/name,nextPageToken'
255253
VARIABLE_1 = 'variable-one'
256254
VARIABLE_2 = 'variable/two'
257255
PATH = 'projects/%s/configs/%s/variables' % (
@@ -273,8 +271,6 @@ def test_list_variables_explicit(self):
273271
variables, token = config.list_variables(
274272
page_size=3,
275273
page_token=TOKEN,
276-
filter_=FILTER,
277-
fields=FIELDS,
278274
client=client)
279275

280276
self.assertEqual(len(variables), len(DATA['variables']))
@@ -295,8 +291,6 @@ def test_list_variables_explicit(self):
295291
{
296292
'pageSize': 3,
297293
'pageToken': TOKEN,
298-
'filter': FILTER,
299-
'fields': FIELDS
300294
})
301295

302296

runtimeconfig/unit_tests/test_variable.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,14 +120,14 @@ def test_reload_w_bound_client(self):
120120
self.assertEqual(req['path'], '/%s' % (self.PATH,))
121121
self._verifyResourceProperties(variable, RESOURCE)
122122

123-
def test_reload_w_no_fields(self):
123+
def test_reload_w_empty_resource(self):
124124
RESOURCE = {}
125125
conn = _Connection(RESOURCE)
126126
client = _Client(project=self.PROJECT, connection=conn)
127127
config = Config(name=self.CONFIG_NAME, client=client)
128128
variable = self._makeOne(name=self.VARIABLE_NAME, config=config)
129129

130-
variable.reload(fields='')
130+
variable.reload()
131131

132132
# Name should not be overwritten.
133133
self.assertEqual(self.VARIABLE_NAME, variable.name)

0 commit comments

Comments
 (0)