1212# See the License for the specific language governing permissions and
1313# limitations under the License.
1414
15- """Create / interact with Stackdriver Logging connections ."""
15+ """Interact with Stackdriver Logging via JSON-over-HTTP ."""
1616
1717import functools
1818
@@ -67,7 +67,7 @@ class _LoggingAPI(object):
6767
6868 def __init__ (self , client ):
6969 self ._client = client
70- self ._connection = client ._connection
70+ self .api_request = client ._connection . api_request
7171
7272 def list_entries (self , projects , filter_ = None , order_by = None ,
7373 page_size = None , page_token = None ):
@@ -161,8 +161,7 @@ def write_entries(self, entries, logger_name=None, resource=None,
161161 if labels is not None :
162162 data ['labels' ] = labels
163163
164- self ._connection .api_request (method = 'POST' , path = '/entries:write' ,
165- data = data )
164+ self .api_request (method = 'POST' , path = '/entries:write' , data = data )
166165
167166 def logger_delete (self , project , logger_name ):
168167 """API call: delete all entries in a logger via a DELETE request
@@ -177,7 +176,7 @@ def logger_delete(self, project, logger_name):
177176 :param logger_name: name of logger containing the log entries to delete
178177 """
179178 path = '/projects/%s/logs/%s' % (project , logger_name )
180- self ._connection . api_request (method = 'DELETE' , path = path )
179+ self .api_request (method = 'DELETE' , path = path )
181180
182181
183182class _SinksAPI (object ):
@@ -191,7 +190,7 @@ class _SinksAPI(object):
191190 """
192191 def __init__ (self , client ):
193192 self ._client = client
194- self ._connection = client ._connection
193+ self .api_request = client ._connection . api_request
195194
196195 def list_sinks (self , project , page_size = None , page_token = None ):
197196 """List sinks for the project associated with this client.
@@ -253,7 +252,7 @@ def sink_create(self, project, sink_name, filter_, destination):
253252 'filter' : filter_ ,
254253 'destination' : destination ,
255254 }
256- self ._connection . api_request (method = 'POST' , path = target , data = data )
255+ self .api_request (method = 'POST' , path = target , data = data )
257256
258257 def sink_get (self , project , sink_name ):
259258 """API call: retrieve a sink resource.
@@ -271,7 +270,7 @@ def sink_get(self, project, sink_name):
271270 :returns: The JSON sink object returned from the API.
272271 """
273272 target = '/projects/%s/sinks/%s' % (project , sink_name )
274- return self ._connection . api_request (method = 'GET' , path = target )
273+ return self .api_request (method = 'GET' , path = target )
275274
276275 def sink_update (self , project , sink_name , filter_ , destination ):
277276 """API call: update a sink resource.
@@ -299,7 +298,7 @@ def sink_update(self, project, sink_name, filter_, destination):
299298 'filter' : filter_ ,
300299 'destination' : destination ,
301300 }
302- self ._connection . api_request (method = 'PUT' , path = target , data = data )
301+ self .api_request (method = 'PUT' , path = target , data = data )
303302
304303 def sink_delete (self , project , sink_name ):
305304 """API call: delete a sink resource.
@@ -314,7 +313,7 @@ def sink_delete(self, project, sink_name):
314313 :param sink_name: the name of the sink
315314 """
316315 target = '/projects/%s/sinks/%s' % (project , sink_name )
317- self ._connection . api_request (method = 'DELETE' , path = target )
316+ self .api_request (method = 'DELETE' , path = target )
318317
319318
320319class _MetricsAPI (object ):
@@ -328,7 +327,7 @@ class _MetricsAPI(object):
328327 """
329328 def __init__ (self , client ):
330329 self ._client = client
331- self ._connection = client ._connection
330+ self .api_request = client ._connection . api_request
332331
333332 def list_metrics (self , project , page_size = None , page_token = None ):
334333 """List metrics for the project associated with this client.
@@ -389,7 +388,7 @@ def metric_create(self, project, metric_name, filter_, description=None):
389388 'filter' : filter_ ,
390389 'description' : description ,
391390 }
392- self ._connection . api_request (method = 'POST' , path = target , data = data )
391+ self .api_request (method = 'POST' , path = target , data = data )
393392
394393 def metric_get (self , project , metric_name ):
395394 """API call: retrieve a metric resource.
@@ -407,7 +406,7 @@ def metric_get(self, project, metric_name):
407406 :returns: The JSON metric object returned from the API.
408407 """
409408 target = '/projects/%s/metrics/%s' % (project , metric_name )
410- return self ._connection . api_request (method = 'GET' , path = target )
409+ return self .api_request (method = 'GET' , path = target )
411410
412411 def metric_update (self , project , metric_name , filter_ , description ):
413412 """API call: update a metric resource.
@@ -434,7 +433,7 @@ def metric_update(self, project, metric_name, filter_, description):
434433 'filter' : filter_ ,
435434 'description' : description ,
436435 }
437- self ._connection . api_request (method = 'PUT' , path = target , data = data )
436+ self .api_request (method = 'PUT' , path = target , data = data )
438437
439438 def metric_delete (self , project , metric_name ):
440439 """API call: delete a metric resource.
@@ -449,7 +448,7 @@ def metric_delete(self, project, metric_name):
449448 :param metric_name: the name of the metric.
450449 """
451450 target = '/projects/%s/metrics/%s' % (project , metric_name )
452- self ._connection . api_request (method = 'DELETE' , path = target )
451+ self .api_request (method = 'DELETE' , path = target )
453452
454453
455454def _item_to_entry (iterator , resource , loggers ):
0 commit comments