@@ -112,7 +112,7 @@ def get_bucket_config(self, bucket, **kwargs):
112
112
return response
113
113
114
114
115
- def update_bucket_config (self , bucket , firewall = None , activity_tracking = None , if_match = None , ** kwargs ):
115
+ def update_bucket_config (self , bucket , firewall = None , activity_tracking = None , metrics_monitoring = None , if_match = None , ** kwargs ):
116
116
"""
117
117
Make changes to a bucket's configuration.
118
118
@@ -134,6 +134,9 @@ def update_bucket_config(self, bucket, firewall=None, activity_tracking=None, if
134
134
Tracker and LogDNA to provide visibility into object read and write events. All
135
135
object events are sent to the activity tracker instance defined in the
136
136
`activity_tracker_crn` field.
137
+ :param MetricsMonitoring metrics_monitoring: Enables sending metrics to IBM Cloud
138
+ Monitoring. All metrics are sent to the IBM Cloud Monitoring instance defined in
139
+ the `monitoring_crn` field.
137
140
:param str if_match: An Etag previously returned in a header when fetching or
138
141
updating a bucket's metadata. If this value does not match the active Etag, the
139
142
request will fail.
@@ -148,6 +151,8 @@ def update_bucket_config(self, bucket, firewall=None, activity_tracking=None, if
148
151
firewall = self ._convert_model (firewall , Firewall )
149
152
if activity_tracking is not None :
150
153
activity_tracking = self ._convert_model (activity_tracking , ActivityTracking )
154
+ if metrics_monitoring is not None :
155
+ metrics_monitoring = self ._convert_model (metrics_monitoring , MetricsMonitoring )
151
156
152
157
headers = {
153
158
'if-match' : if_match
@@ -159,7 +164,8 @@ def update_bucket_config(self, bucket, firewall=None, activity_tracking=None, if
159
164
160
165
data = {
161
166
'firewall' : firewall ,
162
- 'activity_tracking' : activity_tracking
167
+ 'activity_tracking' : activity_tracking ,
168
+ 'metrics_monitoring' : metrics_monitoring
163
169
}
164
170
165
171
url = '/b/{0}' .format (* self ._encode_path_vars (bucket ))
@@ -277,9 +283,12 @@ class Bucket(object):
277
283
Activity Tracker and LogDNA to provide visibility into object read and write events.
278
284
All object events are sent to the activity tracker instance defined in the
279
285
`activity_tracker_crn` field.
286
+ :attr MetricsMonitoring metrics_monitoring: (optional) Enables sending metrics to IBM
287
+ Cloud Monitoring. All metrics are sent to the IBM Cloud Monitoring instance defined in
288
+ the `monitoring_crn` field.
280
289
"""
281
290
282
- def __init__ (self , name = None , crn = None , service_instance_id = None , service_instance_crn = None , time_created = None , time_updated = None , object_count = None , bytes_used = None , firewall = None , activity_tracking = None ):
291
+ def __init__ (self , name = None , crn = None , service_instance_id = None , service_instance_crn = None , time_created = None , time_updated = None , object_count = None , bytes_used = None , firewall = None , activity_tracking = None , metrics_monitoring = None ):
283
292
"""
284
293
Initialize a Bucket object.
285
294
@@ -308,6 +317,9 @@ def __init__(self, name=None, crn=None, service_instance_id=None, service_instan
308
317
Activity Tracker and LogDNA to provide visibility into object read and write
309
318
events. All object events are sent to the activity tracker instance defined in the
310
319
`activity_tracker_crn` field.
320
+ :param MetricsMonitoring metrics_monitoring: (optional) Enables sending metrics to
321
+ IBM Cloud Monitoring. All metrics are sent to the IBM Cloud Monitoring instance
322
+ defined in the `monitoring_crn` field.
311
323
"""
312
324
self .name = name
313
325
self .crn = crn
@@ -319,12 +331,13 @@ def __init__(self, name=None, crn=None, service_instance_id=None, service_instan
319
331
self .bytes_used = bytes_used
320
332
self .firewall = firewall
321
333
self .activity_tracking = activity_tracking
334
+ self .metrics_monitoring = metrics_monitoring
322
335
323
336
@classmethod
324
337
def _from_dict (cls , _dict ):
325
338
"""Initialize a Bucket object from a json dictionary."""
326
339
args = {}
327
- validKeys = ['name' , 'crn' , 'service_instance_id' , 'service_instance_crn' , 'time_created' , 'time_updated' , 'object_count' , 'bytes_used' , 'firewall' , 'activity_tracking' ]
340
+ validKeys = ['name' , 'crn' , 'service_instance_id' , 'service_instance_crn' , 'time_created' , 'time_updated' , 'object_count' , 'bytes_used' , 'firewall' , 'activity_tracking' , 'metrics_monitoring' ]
328
341
badKeys = set (_dict .keys ()) - set (validKeys )
329
342
if badKeys :
330
343
raise ValueError ('Unrecognized keys detected in dictionary for class Bucket: ' + ', ' .join (badKeys ))
@@ -348,6 +361,8 @@ def _from_dict(cls, _dict):
348
361
args ['firewall' ] = Firewall ._from_dict (_dict .get ('firewall' ))
349
362
if 'activity_tracking' in _dict :
350
363
args ['activity_tracking' ] = ActivityTracking ._from_dict (_dict .get ('activity_tracking' ))
364
+ if 'metrics_monitoring' in _dict :
365
+ args ['metrics_monitoring' ] = MetricsMonitoring ._from_dict (_dict .get ('metrics_monitoring' ))
351
366
return cls (** args )
352
367
353
368
def _to_dict (self ):
@@ -373,6 +388,8 @@ def _to_dict(self):
373
388
_dict ['firewall' ] = self .firewall ._to_dict ()
374
389
if hasattr (self , 'activity_tracking' ) and self .activity_tracking is not None :
375
390
_dict ['activity_tracking' ] = self .activity_tracking ._to_dict ()
391
+ if hasattr (self , 'metrics_monitoring' ) and self .metrics_monitoring is not None :
392
+ _dict ['metrics_monitoring' ] = self .metrics_monitoring ._to_dict ()
376
393
return _dict
377
394
378
395
def __str__ (self ):
@@ -449,3 +466,68 @@ def __ne__(self, other):
449
466
return not self == other
450
467
451
468
469
+ class MetricsMonitoring (object ):
470
+ """
471
+ Enables sending metrics to IBM Cloud Monitoring. All metrics are sent to the IBM Cloud
472
+ Monitoring instance defined in the `monitoring_crn` field.
473
+
474
+ :attr bool usage_metrics_enabled: (optional) If set to `true`, all usage metrics (i.e.
475
+ `bytes_used`) will be sent to the monitoring service.
476
+ :attr str metrics_monitoring_crn: (optional) Required the first time
477
+ `metrics_monitoring` is configured. The instance of IBM Cloud Monitoring that will
478
+ receive the bucket metrics. The format is "crn:v1:bluemix:public:logdnaat:{bucket
479
+ location}:a/{storage account}:{monitoring service instance}::".
480
+ """
481
+
482
+ def __init__ (self , usage_metrics_enabled = None , metrics_monitoring_crn = None ):
483
+ """
484
+ Initialize a MetricsMonitoring object.
485
+
486
+ :param bool usage_metrics_enabled: (optional) If set to `true`, all usage metrics
487
+ (i.e. `bytes_used`) will be sent to the monitoring service.
488
+ :param str metrics_monitoring_crn: (optional) Required the first time
489
+ `metrics_monitoring` is configured. The instance of IBM Cloud Monitoring that will
490
+ receive the bucket metrics. The format is "crn:v1:bluemix:public:logdnaat:{bucket
491
+ location}:a/{storage account}:{monitoring service instance}::".
492
+ """
493
+ self .usage_metrics_enabled = usage_metrics_enabled
494
+ self .metrics_monitoring_crn = metrics_monitoring_crn
495
+
496
+ @classmethod
497
+ def _from_dict (cls , _dict ):
498
+ """Initialize a MetricsMonitoring object from a json dictionary."""
499
+ args = {}
500
+ validKeys = ['usage_metrics_enabled' , 'metrics_monitoring_crn' ]
501
+ badKeys = set (_dict .keys ()) - set (validKeys )
502
+ if badKeys :
503
+ raise ValueError ('Unrecognized keys detected in dictionary for class MetricsMonitoring: ' + ', ' .join (badKeys ))
504
+ if 'usage_metrics_enabled' in _dict :
505
+ args ['usage_metrics_enabled' ] = _dict .get ('usage_metrics_enabled' )
506
+ if 'metrics_monitoring_crn' in _dict :
507
+ args ['metrics_monitoring_crn' ] = _dict .get ('metrics_monitoring_crn' )
508
+ return cls (** args )
509
+
510
+ def _to_dict (self ):
511
+ """Return a json dictionary representing this model."""
512
+ _dict = {}
513
+ if hasattr (self , 'usage_metrics_enabled' ) and self .usage_metrics_enabled is not None :
514
+ _dict ['usage_metrics_enabled' ] = self .usage_metrics_enabled
515
+ if hasattr (self , 'metrics_monitoring_crn' ) and self .metrics_monitoring_crn is not None :
516
+ _dict ['metrics_monitoring_crn' ] = self .metrics_monitoring_crn
517
+ return _dict
518
+
519
+ def __str__ (self ):
520
+ """Return a `str` version of this MetricsMonitoring object."""
521
+ return json .dumps (self ._to_dict (), indent = 2 )
522
+
523
+ def __eq__ (self , other ):
524
+ """Return `true` when self and other are equal, false otherwise."""
525
+ if not isinstance (other , self .__class__ ):
526
+ return False
527
+ return self .__dict__ == other .__dict__
528
+
529
+ def __ne__ (self , other ):
530
+ """Return `true` when self and other are not equal, false otherwise."""
531
+ return not self == other
532
+
533
+
0 commit comments