@@ -42,6 +42,22 @@ def create_uptime_check_config(project_name, host_name=None,
4242# [END monitoring_uptime_check_create]
4343
4444
45+ # [START monitoring_uptime_check_update]
46+ def update_uptime_check_config (config_name , new_display_name = None ,
47+ new_http_check_path = None ):
48+ client = monitoring_v3 .UptimeCheckServiceClient ()
49+ config = client .get_uptime_check_config (config_name )
50+ field_mask = monitoring_v3 .types .FieldMask ()
51+ if new_display_name :
52+ field_mask .paths .append ('display_name' )
53+ config .display_name = new_display_name
54+ if new_http_check_path :
55+ field_mask .paths .append ('http_check.path' )
56+ config .http_check .path = new_http_check_path
57+ client .update_uptime_check_config (config , field_mask )
58+ # [END monitoring_uptime_check_update]
59+
60+
4561# [START monitoring_uptime_check_list_configs]
4662def list_uptime_check_configs (project_name ):
4763 client = monitoring_v3 .UptimeCheckServiceClient ()
@@ -153,6 +169,23 @@ def project_name():
153169 required = True ,
154170 )
155171
172+ update_uptime_check_config_parser = subparsers .add_parser (
173+ 'update-uptime-check-config' ,
174+ help = update_uptime_check_config .__doc__
175+ )
176+ update_uptime_check_config_parser .add_argument (
177+ '-m' , '--name' ,
178+ required = True ,
179+ )
180+ update_uptime_check_config_parser .add_argument (
181+ '-d' , '--display_name' ,
182+ required = False ,
183+ )
184+ update_uptime_check_config_parser .add_argument (
185+ '-p' , '--uptime_check_path' ,
186+ required = False ,
187+ )
188+
156189 args = parser .parse_args ()
157190
158191 if args .command == 'list-uptime-check-configs' :
@@ -170,3 +203,11 @@ def project_name():
170203
171204 elif args .command == 'delete-uptime-check-config' :
172205 delete_uptime_check_config (args .name )
206+
207+ elif args .command == 'update-uptime-check-config' :
208+ if not args .display_name and not args .uptime_check_path :
209+ print ('Nothing to update. Pass --display_name or '
210+ '--uptime_check_path.' )
211+ else :
212+ update_uptime_check_config (args .name , args .display_name ,
213+ args .uptime_check_path )
0 commit comments