Class: EnvironmentManager::Api

Inherits:
Object
  • Object
show all
Defined in:
lib/environment_manager/api.rb

Instance Method Summary collapse

Constructor Details

#initialize(server, user, password, retries = 5) ⇒ Api

Returns a new instance of Api.



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/environment_manager/api.rb', line 10

def initialize(server, user, password, retries=5)
  # Instantiate variables
  @server = server
  @user = user
  @password = password
  @retries = retries
  @token = nil

  # Sanitise input
  if server.empty? or user.empty? or password.empty?
    raise(IndexError, "API(server: SERVERNAME, user: USERNAME, password: PASSWORD, [retries: N])")
  end
end

Instance Method Details

#delete_account_config(accountnumber = nil) ⇒ Object



154
155
156
157
158
159
160
161
# File 'lib/environment_manager/api.rb', line 154

def (accountnumber=nil)
  # Remove an AWS Account association
  if accountnumber.nil?
    raise("Required value has not been specified")
  end
  request_endpoint = "/api/v1/config/accounts/#{accountnumber}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_asg(environment = nil, asgname = nil) ⇒ Object



205
206
207
208
209
210
211
212
# File 'lib/environment_manager/api.rb', line 205

def delete_asg(environment=nil, asgname=nil)
  # Delete ASG and it"s target state
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}?environment=#{environment}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_cluster_config(cluster = nil) ⇒ Object



358
359
360
361
362
363
364
365
# File 'lib/environment_manager/api.rb', line 358

def delete_cluster_config(cluster=nil)
  # Delete a Cluster configuration
  if cluster.nil?
    raise("Cluster name has not been specified")
  end
  request_endpoint = "/api/v1/config/clusters/#{cluster}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_deployment_map(deployment_name = nil) ⇒ Object



456
457
458
459
460
461
462
463
# File 'lib/environment_manager/api.rb', line 456

def delete_deployment_map(deployment_name=nil)
  # Delete a deployment map configuration
  if deployment_name.nil?
    raise("Deployment name has not been specified")
  end
  request_endpoint = "/api/v1/deployment-maps/#{deployment_name}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_environment_config(environment = nil) ⇒ Object



623
624
625
626
627
628
629
630
# File 'lib/environment_manager/api.rb', line 623

def delete_environment_config(environment=nil)
  # Delete an environment configuration
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/config/environments/#{environment}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_environmenttype_config(environmenttype = nil) ⇒ Object



673
674
675
676
677
678
679
680
# File 'lib/environment_manager/api.rb', line 673

def delete_environmenttype_config(environmenttype=nil)
  # Delete an environment type
  if environmenttype.nil?
    raise("Environment type has not been specified")
  end
  request_endpoint = "/api/v1/config/environment-types/#{environmenttype}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_lbsettings_vhost_config(environment = nil, vhostname = nil) ⇒ Object



818
819
820
821
822
823
824
825
826
827
828
# File 'lib/environment_manager/api.rb', line 818

def delete_lbsettings_vhost_config(environment=nil, vhostname=nil)
  # Delete an load balancer setting
  if environment.nil?
    raise("Environment has not been specified")
  end
  if vhostname.nil?
    raise("Virtual Host Name (vhostname) has not been specified")
  end
  request_endpoint = "/api/v1/config/lb-settings/#{environment}/#{vhostname}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_notificationsetting_config(notification_id = nil) ⇒ Object



871
872
873
874
875
876
877
878
# File 'lib/environment_manager/api.rb', line 871

def delete_notificationsetting_config(notification_id=nil)
  # Remove Notification settings
  if notification_id.nil?
    raise("Notification id has not been specified")
  end
  request_endpoint = "/api/v1/notification-settings/#{notification_id}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_permission_config(name = nil) ⇒ Object



943
944
945
946
947
948
949
950
# File 'lib/environment_manager/api.rb', line 943

def delete_permission_config(name=nil)
  # Delete a permissions configuration
  if name.nil?
    raise("Permission name has not been specified")
  end
  request_endpoint = "/api/v1/config/permissions/#{name}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_service_config(service = nil, cluster = nil) ⇒ Object



1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
# File 'lib/environment_manager/api.rb', line 1095

def delete_service_config(service=nil, cluster=nil)
  # Delete a service configuration
  if service.nil?
    raise("Service has not been specified")
  end
  if cluster.nil?
    raise("Cluster name (team) has not been specified")
  end
  request_endpoint = "/api/v1/config/services/#{service}/#{cluster}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_target_state(environment = nil) ⇒ Object



1127
1128
1129
1130
1131
1132
1133
1134
# File 'lib/environment_manager/api.rb', line 1127

def delete_target_state(environment=nil)
  # Remove the target state for all services in a given environment
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/target-state/#{environment}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_target_state_service(environment = nil, service = nil) ⇒ Object



1137
1138
1139
1140
1141
1142
1143
1144
# File 'lib/environment_manager/api.rb', line 1137

def delete_target_state_service(environment=nil, service=nil)
  # Remove the target state for all versions of a service
  if environment.nil? or service.nil?
    raise("Environment or Service has not been specified")
  end
  request_endpoint = "/api/v1/target-state/#{environment}/#{service}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_target_state_service_version(environment = nil, service = nil, version = nil) ⇒ Object



1147
1148
1149
1150
1151
1152
1153
1154
# File 'lib/environment_manager/api.rb', line 1147

def delete_target_state_service_version(environment=nil, service=nil, version=nil)
  # Remove the target state for a specific version of a service
  if environment.nil? or service.nil? or version.nil?
    raise("Environment or Service has not been specified")
  end
  request_endpoint = "/api/v1/target-state/#{environment}/#{service}/#{version}"
  return query(request_endpoint, query_type: "DELETE")
end

#delete_upstream_config(upstream = nil, account = "Non-Prod") ⇒ Object



1223
1224
1225
1226
1227
1228
1229
1230
# File 'lib/environment_manager/api.rb', line 1223

def delete_upstream_config(upstream=nil, ="Non-Prod")
  # Delete an upstream configuration
  if upstream.nil?
    raise("Upstream name has not been specified")
  end
  request_endpoint = "/api/v1/config/upstreams/#{upstream}?account=#{account}"
  return query(request_endpoint, query_type: "DELETE")
end

#export_resource(resource = nil, account = nil) ⇒ Object



684
685
686
687
688
689
690
691
# File 'lib/environment_manager/api.rb', line 684

def export_resource(resource=nil, =nil)
  # Export a configuration resources dynamo table
  if resource.nil? or .nil?
    raise("Resource or account has not been specified")
  end
  request_endpoint = "/api/v1/config/export/#{resource}?account=#{account}"
  return query(request_endpoint, query_type: "GET")
end

#get_accounts_configObject



130
131
132
133
134
# File 'lib/environment_manager/api.rb', line 130

def get_accounts_config()
  # List the AWS Accounts that associated with Environment Manager
  request_endpoint = "/api/v1/config/accounts"
  return query(request_endpoint, query_type: "GET")
end

#get_asg(environment = nil, asgname = nil) ⇒ Object



185
186
187
188
189
190
191
192
# File 'lib/environment_manager/api.rb', line 185

def get_asg(environment=nil, asgname=nil)
  # Get a single ASG for the given environment
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}?environment=#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_asg_ips(environment = nil, asgname = nil) ⇒ Object



225
226
227
228
229
230
231
232
# File 'lib/environment_manager/api.rb', line 225

def get_asg_ips(environment=nil, asgname=nil)
  # Get IPs associated with an ASG in the given environment
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}/ips?environment=#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_asg_launch_config(environment = nil, asgname = nil) ⇒ Object



265
266
267
268
269
270
271
272
# File 'lib/environment_manager/api.rb', line 265

def get_asg_launch_config(environment=nil, asgname=nil)
  # Get the launch config associated with an ASG in the given environment
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}/launch-config?environment=#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_asg_ready(environment = nil, asgname = nil) ⇒ Object



215
216
217
218
219
220
221
222
# File 'lib/environment_manager/api.rb', line 215

def get_asg_ready(environment=nil, asgname=nil)
  # Determine if an ASG is ready to deploy to, eg. at least one instance is present and all are "InService"
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}/ready?environment=#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_asg_scaling_schedule(environment = nil, asgname = nil) ⇒ Object



235
236
237
238
239
240
241
242
# File 'lib/environment_manager/api.rb', line 235

def get_asg_scaling_schedule(environment=nil, asgname=nil)
  # Get scaling schedule actions for given ASG
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}/scaling-schedule?environment=#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_asgs(account = "Non-Prod") ⇒ Object



178
179
180
181
182
# File 'lib/environment_manager/api.rb', line 178

def get_asgs(="Non-Prod")
  # List ASGS matching the given criteria. By default returns all ASGs across all accounts
  request_endpoint = "/api/v1/asgs?account=#{account}"
  return query(request_endpoint, query_type: "GET")
end

#get_audit_config(since_time = nil, until_time = nil) ⇒ Object



286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
# File 'lib/environment_manager/api.rb', line 286

def get_audit_config(since_time=nil, until_time=nil)
  # Get Audit Logs for a given time period. Default values are "since yesterday" and "until now"
  if since_time.nil?
    since_time_qs = ""
  else
    since_time_qs = "since=#{since_time}"
  end
  if until_time.nil?
    until_time_qs = ""
  else
    until_time_qs = "until=#{until_time}"
  end
  # Construct qs
  if since_time.nil? and not until_time.nil?
    constructed_qs = "?#{until_time_qs}"
  elsif not since_time.nil? and until_time.nil?
    constructed_qs = "?#{since_time_qs}"
  elsif not since_time.nil? and not until_time.nil?
    constructed_qs = "?#{since_time_qs}&#{until_qs}"
  else
    constructed_qs = ""
  end
  request_endpoint = "/api/v1/config/audit#{constructed_qs}"
  return query(request_endpoint, query_type: "GET")
end

#get_audit_key_config(key = nil) ⇒ Object



313
314
315
316
317
318
319
320
# File 'lib/environment_manager/api.rb', line 313

def get_audit_key_config(key=nil)
  # Get a specific audit log
  if key.nil?
    raise("Key has not been specified")
  end
  request_endpoint = "/api/v1/config/audit/#{key}"
  return query(request_endpoint, query_type: "GET")
end

#get_cluster_config(cluster = nil) ⇒ Object



338
339
340
341
342
343
344
345
# File 'lib/environment_manager/api.rb', line 338

def get_cluster_config(cluster=nil)
  # Get a specific Cluster configuration
  if cluster.nil?
    raise("Cluster name has not been specified")
  end
  request_endpoint = "/api/v1/config/clusters/#{cluster}"
  return query(request_endpoint, query_type: "GET")
end

#get_clusters_configObject



324
325
326
327
328
# File 'lib/environment_manager/api.rb', line 324

def get_clusters_config()
  # Get all Cluster configurations
  request_endpoint = "/api/v1/config/clusters"
  return query(request_endpoint, query_type: "GET")
end

#get_deployment(deployment_id = nil) ⇒ Object



383
384
385
386
387
388
389
390
# File 'lib/environment_manager/api.rb', line 383

def get_deployment(deployment_id=nil)
  # Get information for a deployment
  if deployment_id.nil?
    raise("Deployment id has not been specified")
  end
  request_endpoint = "/api/v1/deployments/#{deployment_id}"
  return query(request_endpoint, query_type: "GET")
end

#get_deployment_log(deployment_id = nil, account = "Non-Prod", instance = nil) ⇒ Object



403
404
405
406
407
408
409
410
411
412
413
# File 'lib/environment_manager/api.rb', line 403

def get_deployment_log(deployment_id=nil, ="Non-Prod", instance=nil)
  # Retrieve logs for a particular deployment
  if deployment_id.nil?
    raise("Deployment id has not been specified")
  end
  if instance.nil?
    raise("Instance id has not been specified")
  end
  request_endpoint = "/api/v1/deployments/#{deployment_id}/log?account=#{account}&instance=#{instance}"
  return query(request_endpoint, query_type: "GET")
end

#get_deployment_map(deployment_name = nil) ⇒ Object



431
432
433
434
435
436
437
438
# File 'lib/environment_manager/api.rb', line 431

def get_deployment_map(deployment_name=nil)
  # Get a specific deployment map configuration
  if deployment_name.nil?
    raise("Deployment name has not been specified")
  end
  request_endpoint = "/api/v1/deployment-maps/#{deployment_name}"
  return query(request_endpoint, query_type: "GET")
end

#get_deployment_mapsObject



417
418
419
420
421
# File 'lib/environment_manager/api.rb', line 417

def get_deployment_maps()
  # Get all deployment map configurations
  request_endpoint = "/api/v1/config/deployments-maps"
  return query(request_endpoint, query_type: "GET")
end

#get_deploymentsObject



369
370
371
372
373
# File 'lib/environment_manager/api.rb', line 369

def get_deployments()
  # List all deployments matching the given criteria. If no parameters are provided, the default is "since yesterday"
  request_endpoint = "/api/v1/deployments"
  return query(request_endpoint, query_type: "GET")
end

#get_environment(environment = nil) ⇒ Object



474
475
476
477
478
479
480
481
# File 'lib/environment_manager/api.rb', line 474

def get_environment(environment=nil)
  # Get an environment
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/environments/#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_environment_account_name(environment = nil) ⇒ Object



539
540
541
542
543
544
545
546
# File 'lib/environment_manager/api.rb', line 539

def (environment=nil)
  # Get account name for given environment
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/environments/#{environment}/accountName"
  return query(request_endpoint, query_type: "GET")
end

#get_environment_asg_servers(environment = nil, asgname = nil) ⇒ Object



504
505
506
507
508
509
510
511
# File 'lib/environment_manager/api.rb', line 504

def get_environment_asg_servers(environment=nil, asgname=nil)
  # Get a specific server in a given environment
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/environments/#{environment}/servers/#{asgname}"
  return query(request_endpoint, query_type: "GET")
end

#get_environment_config(environment = nil) ⇒ Object



598
599
600
601
602
603
604
605
# File 'lib/environment_manager/api.rb', line 598

def get_environment_config(environment=nil)
  # Get a specific environment configuration
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/config/environments/#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_environment_protected(environment = nil, action = nil) ⇒ Object



484
485
486
487
488
489
490
491
# File 'lib/environment_manager/api.rb', line 484

def get_environment_protected(environment=nil, action=nil)
  # Find if environment is protected from action
  if environment.nil? or action.nil?
    raise("Environment or Action has not been specified")
  end
  request_endpoint = "/api/v1/environments/#{environment}/protected?action=#{action}"
  return query(request_endpoint, query_type: "GET")
end

#get_environment_schedule(environment = nil) ⇒ Object



514
515
516
517
518
519
520
521
# File 'lib/environment_manager/api.rb', line 514

def get_environment_schedule(environment=nil)
  # Get schedule for an environment
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/environments/#{environment}/schedule"
  return query(request_endpoint, query_type: "GET")
end

#get_environment_schedule_status(environment = nil, at_time = nil) ⇒ Object



549
550
551
552
553
554
555
556
557
558
559
560
561
# File 'lib/environment_manager/api.rb', line 549

def get_environment_schedule_status(environment=nil, at_time=nil)
  # Get the schedule status for a given environment at a given time. If no "at" parameter is provided, the current status is returned
  if environment.nil?
    raise("Environment has not been specified")
  end
  if at_time.nil?
    at_qs = ""
  else
    at_qs = "?at=#{at_time}"
  end
  request_endpoint = "/api/v1/environments/#{environment}/schedule-status#{at_qs}"
  return query(request_endpoint, query_type: "GET")
end

#get_environment_servers(environment = nil) ⇒ Object



494
495
496
497
498
499
500
501
# File 'lib/environment_manager/api.rb', line 494

def get_environment_servers(environment=nil)
  # Get the list of servers in an environment
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/environments/#{environment}/servers"
  return query(request_endpoint, query_type: "GET")
end

#get_environmentsObject



467
468
469
470
471
# File 'lib/environment_manager/api.rb', line 467

def get_environments()
  # Get all environments
  request_endpoint = "/api/v1/environments"
  return query(request_endpoint, query_type: "GET")
end

#get_environments_config(environmenttype = nil, cluster = nil) ⇒ Object



564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
# File 'lib/environment_manager/api.rb', line 564

def get_environments_config(environmenttype=nil, cluster=nil)
  # Get all environment configurations
  if environmenttype.nil?
    environmenttype_qs = ""
  else
    environmenttype_qs = "environmentType=#{environmenttype}"
  end
  if cluster.nil?
    cluster_qs = ""
  else
    cluster_qs = "cluster=#{cluster}"
  end
  # Construct qs
  if environmenttype.nil? and not cluster.nil?
    constructed_qs = "?#{cluster_qs}"
  elsif not environmenttype.nil? and cluster.nil?
    constructed_qs = "?#{environmenttype_qs}"
  elsif not environmenttype.nil? and not cluster.nil?
    constructed_qs = "?#{environmenttype_qs}&#{cluster_qs}"
  else
    constructed_qs = ""
  end
  request_endpoint = "/api/v1/config/environments#{constructed_qs}"
  return query(request_endpoint, query_type: "GET")
end

#get_environmenttype_config(environmenttype = nil) ⇒ Object



648
649
650
651
652
653
654
655
# File 'lib/environment_manager/api.rb', line 648

def get_environmenttype_config(environmenttype=nil)
  # Get an specific environment type configuration
  if environmenttype.nil?
    raise("Environment type has not been specified")
  end
  request_endpoint = "/api/v1/config/environment-types/#{environmenttype}"
  return query(request_endpoint, query_type: "GET")
end

#get_environmenttypes_configObject



634
635
636
637
638
# File 'lib/environment_manager/api.rb', line 634

def get_environmenttypes_config()
  # Get all environment type configurations
  request_endpoint = "/api/v1/config/environment-types"
  return query(request_endpoint, query_type: "GET")
end

#get_images(account = nil) ⇒ Object



165
166
167
168
169
170
171
172
173
174
# File 'lib/environment_manager/api.rb', line 165

def get_images(=nil)
  # Get the list of available AMI images. Only those that are privately published under associated accounts are included
  if .nil?
     = ""
  else
     = "?account=#{account}"
  end
  request_endpoint = "/api/v1/images#{account_qs}"
  return query(request_endpoint, query_type: "GET")
end

#get_instance(instance_id = nil) ⇒ Object



726
727
728
729
730
731
732
733
# File 'lib/environment_manager/api.rb', line 726

def get_instance(instance_id=nil)
  # Get a specific instance
  if instance_id.nil?
    raise("Instance id has not been specified")
  end
  request_endpoint = "/api/v1/instances/#{instance_id}"
  return query(request_endpoint, query_type: "GET")
end

#get_instance_connect(instance_id = nil) ⇒ Object



736
737
738
739
740
741
742
743
# File 'lib/environment_manager/api.rb', line 736

def get_instance_connect(instance_id=nil)
  # Connect to the instance via remote desktop
  if instance_id.nil?
    raise("Instance id has not been specified")
  end
  request_endpoint = "/api/v1/instances/#{instance_id}/connect"
  return query(request_endpoint, query_type: "GET")
end

#get_instances(environment = nil, cluster = nil, account = nil) ⇒ Object



706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
# File 'lib/environment_manager/api.rb', line 706

def get_instances(environment=nil, cluster=nil, =nil)
  # Get all instances matching the given criteria
  request_endpoint = "/api/v1/instances"
  queries = Array.new()
  if not environment.nil?
    queries.push("environment=#{environment}")
  end
  if not cluster.nil?
    queries.push("cluster=#{cluster}")
  end
  if not .nil?
    queries.push("account=#{account}")
  end
  if queries.size > 0
    request_endpoint << '?%s' % queries.join("&")
  end
  return query(request_endpoint, query_type: "GET")
end

#get_lbsettings_config(query_type = nil, query_value = nil) ⇒ Object



767
768
769
770
771
772
773
774
775
776
777
# File 'lib/environment_manager/api.rb', line 767

def get_lbsettings_config(query_type=nil, query_value=nil)
  # List all load balancer settings
  if query_type.nil? or query_value.nil?
    raise('query_type and query_value are required')
  end
  if !query_value.kind_of?(Array)
    raise('query_value must be an array')
  end
  request_endpoint = "/api/v1/config/lb-settings?qa=#{query_type}&qv=#{query_value.join(',')}"
  return query(request_endpoint, query_type: "GET")
end

#get_lbsettings_vhost_config(environment = nil, vhostname = nil) ⇒ Object



787
788
789
790
791
792
793
794
795
796
797
# File 'lib/environment_manager/api.rb', line 787

def get_lbsettings_vhost_config(environment=nil, vhostname=nil)
  # Get a specific load balancer setting
  if environment.nil?
    raise("Environment has not been specified")
  end
  if vhostname.nil?
    raise("Virtual Host Name (vhostname) has not been specified")
  end
  request_endpoint = "/api/v1/config/lb-settings/#{environment}/#{vhostname}"
  return query(request_endpoint, query_type: "GET")
end

#get_loadbalancer(id = nil) ⇒ Object



757
758
759
760
761
762
763
764
# File 'lib/environment_manager/api.rb', line 757

def get_loadbalancer(id=nil)
  # Get load balancer data
  if id.nil?
    raise("Load Balancer ID has not been specified")
  end
  request_endpoint = "/api/v1/load-balancer/#{id}"
  return query(request_endpoint, query_type: "GET")
end

#get_notificationsetting_config(notification_id = nil) ⇒ Object



846
847
848
849
850
851
852
853
# File 'lib/environment_manager/api.rb', line 846

def get_notificationsetting_config(notification_id=nil)
  # Get Notification settings
  if notification_id.nil?
    raise("Notification id has not been specified")
  end
  request_endpoint = "/api/v1/notification-settings/#{notification_id}"
  return query(request_endpoint, query_type: "GET")
end

#get_notificationsettings_configObject



832
833
834
835
836
# File 'lib/environment_manager/api.rb', line 832

def get_notificationsettings_config()
  # List Notification settings
  request_endpoint = "/api/v1/config/notification-settings"
  return query(request_endpoint, query_type: "GET")
end

#get_package_upload_url(service = nil, version = nil) ⇒ Object



893
894
895
896
897
898
899
900
# File 'lib/environment_manager/api.rb', line 893

def get_package_upload_url(service=nil, version=nil)
  # Upload an environment-independent package
  if service.nil? or version.nil?
    raise("Parameter has not been specified")
  end
  request_endpoint = "/api/v1/package-upload-url/#{service}/#{version}"
  return query(request_endpoint, query_type: "GET")
end

#get_package_upload_url_environment(service = nil, version = nil, environment = nil) ⇒ Object



883
884
885
886
887
888
889
890
# File 'lib/environment_manager/api.rb', line 883

def get_package_upload_url_environment(service=nil, version=nil, environment=nil)
  # Upload an environment-specific package
  if service.nil? or version.nil? or environment.nil?
    raise("Parameter has not been specified")
  end
  request_endpoint = "/api/v1/package-upload-url/#{service}/#{version}/#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_permission_config(name = nil) ⇒ Object



918
919
920
921
922
923
924
925
# File 'lib/environment_manager/api.rb', line 918

def get_permission_config(name=nil)
  # Get a specific permission configuration
  if name.nil?
    raise("Permission name has not been specified")
  end
  request_endpoint = "/api/v1/config/permissions/#{name}"
  return query(request_endpoint, query_type: "GET")
end

#get_permissions_configObject



904
905
906
907
908
# File 'lib/environment_manager/api.rb', line 904

def get_permissions_config()
  # Get all permission configurations
  request_endpoint = "/api/v1/config/permissions"
  return query(request_endpoint, query_type: "GET")
end

#get_service(service = nil) ⇒ Object



961
962
963
964
965
966
967
968
# File 'lib/environment_manager/api.rb', line 961

def get_service(service=nil)
  # Get a currently deployed service
  if service.nil?
    raise("Service has not been specified")
  end
  request_endpoint = "/api/v1/services/#{service}"
  return query(request_endpoint, query_type: "GET")
end

#get_service_asgs(service = nil, environment = nil, slice = nil) ⇒ Object



971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
# File 'lib/environment_manager/api.rb', line 971

def get_service_asgs(service=nil, environment=nil, slice=nil)
  # Get the ASGs to which a service is deployed
  if service.nil?
    raise("Service has not been specified")
  end
  if environment.nil?
    raise("Environment has not been specified")
  end
  if slice.nil?
    slice_qs = ""
  else
    slice_qs = "&slice=#{slice}"
  end
  request_endpoint = "/api/v1/services/#{service}/asgs?environment=#{environment}#{slice_qs}"
  return query(request_endpoint, query_type: "GET")
end

#get_service_config(service = nil, cluster = nil) ⇒ Object



1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
# File 'lib/environment_manager/api.rb', line 1064

def get_service_config(service=nil, cluster=nil)
  # Get a specific service configuration
  if service.nil?
    raise("Service has not been specified")
  end
  if cluster.nil?
    raise("Cluster name (team) has not been specified")
  end
  request_endpoint = "/api/v1/config/services/#{service}/#{cluster}"
  return query(request_endpoint, query_type: "GET")
end

#get_service_health(service = nil, environment = nil, slice = nil, server_role = nil) ⇒ Object



1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
# File 'lib/environment_manager/api.rb', line 1002

def get_service_health(service=nil, environment=nil, slice=nil, server_role=nil)
  # Get health for a specific service
  if service.nil?
    raise("Service has not been specified")
  end
  if environment.nil?
    raise("Environment has not been specified")
  end
  if slice.nil?
    raise("Slice has not been specified")
  end
  request_endpoint = "/api/v1/services/#{service}/health/#{slice}?environment=#{environment}"
  if not server_role.nil?
    request_endpoint = "#{request_endpoint}&serverRole=#{server_role}"
  end
  return query(request_endpoint, query_type: "GET")
end

#get_service_overall_health(service = nil, environment = nil) ⇒ Object



989
990
991
992
993
994
995
996
997
998
999
# File 'lib/environment_manager/api.rb', line 989

def get_service_overall_health(service=nil, environment=nil)
  # Get a overall health for a deployed service
  if service.nil?
    raise("Service has not been specified")
  end
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/services/#{service}/health?environment=#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_service_slices(service = nil, environment = nil, active = nil) ⇒ Object



1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
# File 'lib/environment_manager/api.rb', line 1021

def get_service_slices(service=nil, environment=nil, active=nil)
  # Get slices for a deployed service
  if service.nil?
    raise SyntaxError("Service has not been specified")
  end
  if environment.nil?
    raise SyntaxError("Environment has not been specified")
  end
  request_endpoint = "/api/v1/services/#{service}/slices?environment=#{environment}"
  if not active.nil?
    request_endpoint = "#{request_endpoint}&active=#{active}"
  end
  return query(request_endpoint, query_type: "GET")
end

#get_servicesObject



954
955
956
957
958
# File 'lib/environment_manager/api.rb', line 954

def get_services()
  # Get the list of currently deployed services
  request_endpoint = "/api/v1/services"
  return query(request_endpoint, query_type: "GET")
end

#get_services_configObject



1050
1051
1052
1053
1054
# File 'lib/environment_manager/api.rb', line 1050

def get_services_config()
  # Get all service configurations
  request_endpoint = "/api/v1/config/services"
  return query(request_endpoint, query_type: "GET")
end

#get_statusObject



1109
1110
1111
1112
1113
# File 'lib/environment_manager/api.rb', line 1109

def get_status()
  # Get version and status information
  request_endpoint = "/api/v1/diagnostics/healthcheck"
  return query(request_endpoint, query_type: "GET")
end

#get_target_state(environment = nil) ⇒ Object



1117
1118
1119
1120
1121
1122
1123
1124
# File 'lib/environment_manager/api.rb', line 1117

def get_target_state(environment=nil)
  # Get the target state for a given environment
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/target-state/#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_upstream_config(upstream = nil, account = "Non-Prod") ⇒ Object



1198
1199
1200
1201
1202
1203
1204
1205
# File 'lib/environment_manager/api.rb', line 1198

def get_upstream_config(upstream=nil, ="Non-Prod")
  # Get an a specific upstream configuration
  if upstream.nil?
    raise("Upstream name has not been specified")
  end
  request_endpoint = "/api/v1/config/upstreams/#{upstream}?account=#{account}"
  return query(request_endpoint, query_type: "GET")
end

#get_upstream_slices(upstream = nil, environment = nil) ⇒ Object



1158
1159
1160
1161
1162
1163
1164
1165
# File 'lib/environment_manager/api.rb', line 1158

def get_upstream_slices(upstream=nil, environment=nil)
  # Get slices for a given upstream
  if upstream.nil? or environment.nil?
    raise("Upstream or Environment name has not been specified")
  end
  request_endpoint = "/api/v1/upstreams/#{upstream}/slices?environment=#{environment}"
  return query(request_endpoint, query_type: "GET")
end

#get_upstreams_config(query_type = nil, query_value = nil) ⇒ Object



1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
# File 'lib/environment_manager/api.rb', line 1178

def get_upstreams_config(query_type=nil, query_value=nil)
# Get all upstream configurations
  if query_type.nil? or query_value.nil?
    raise('query_type and query_value are required')
  end
  if !query_value.kind_of?(Array)
    raise('query_value must be an array')
  end
  request_endpoint = "/api/v1/config/upstreams?qa=#{query_type}&qv=#{query_value.join(',')}"
  return query(request_endpoint, query_type: "GET")
end

#import_resource(resource = nil, account = nil, mode = nil, data = Hash.new) ⇒ Object



695
696
697
698
699
700
701
702
# File 'lib/environment_manager/api.rb', line 695

def import_resource(resource=nil, =nil, mode=nil, data=Hash.new)
  # Import a configuration resources dynamo table
  if resource.nil? or .nil? or mode.nil?
    raise("Resource or account has not been specified")
  end
  request_endpoint = "/api/v1/config/import/#{resource}?account=#{account}&mode=#{mode}"
  return query(request_endpoint, query_type: "PUT", data: data)
end

#patch_deployment(deployment_id = nil, data = Hash.new) ⇒ Object



393
394
395
396
397
398
399
400
# File 'lib/environment_manager/api.rb', line 393

def patch_deployment(deployment_id=nil, data=Hash.new)
  # Modify deployment - cancel in-progress, or modify Action
  if deployment_id.nil?
    raise("Deployment id has not been specified")
  end
  request_endpoint = "/api/v1/deployments/#{deployment_id}"
  return query(request_endpoint, query_type: "PATCH", data: data)
end

#post_accounts_config(data = Hash.new) ⇒ Object



137
138
139
140
141
# File 'lib/environment_manager/api.rb', line 137

def post_accounts_config(data=Hash.new)
  # Add an association to an AWS Account
  request_endpoint = "/api/v1/config/accounts"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_clusters_config(data = Hash.new) ⇒ Object



331
332
333
334
335
# File 'lib/environment_manager/api.rb', line 331

def post_clusters_config(data=Hash.new)
  # Create a Cluster configuration
  request_endpoint = "/api/v1/config/clusters"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_deployment_maps(data = Hash.new) ⇒ Object



424
425
426
427
428
# File 'lib/environment_manager/api.rb', line 424

def post_deployment_maps(data=Hash.new)
  # Create a deployment map configuration
  request_endpoint = "/api/v1/config/deployments-maps"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_deployments(dry_run = False, data = Hash.new) ⇒ Object



376
377
378
379
380
# File 'lib/environment_manager/api.rb', line 376

def post_deployments(dry_run=False, data=Hash.new)
  # Create a new deployment. This will provision any required infrastructure and update the required target-state
  request_endpoint = "/api/v1/deployments?dry_run=#{dry_run}"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_environments_config(data = Hash.new) ⇒ Object



591
592
593
594
595
# File 'lib/environment_manager/api.rb', line 591

def post_environments_config(data=Hash.new)
  # Create a new environment configuration
  request_endpoint = "/api/v1/config/environments"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_environmenttypes_config(data = Hash.new) ⇒ Object



641
642
643
644
645
# File 'lib/environment_manager/api.rb', line 641

def post_environmenttypes_config(data=Hash.new)
  # Create an Environment Type configuration
  request_endpoint = "/api/v1/config/environment-types"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_lbsettings_config(data = Hash.new) ⇒ Object



780
781
782
783
784
# File 'lib/environment_manager/api.rb', line 780

def post_lbsettings_config(data=Hash.new)
  # Create a load balancer setting
  request_endpoint = "/api/v1/config/lb-settings"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_notificationsettings_config(data = Hash.new) ⇒ Object



839
840
841
842
843
# File 'lib/environment_manager/api.rb', line 839

def post_notificationsettings_config(data=Hash.new)
  # Post new Notification settings
  request_endpoint = "/api/v1/config/notification-settings"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_permissions_config(data = Hash.new) ⇒ Object



911
912
913
914
915
# File 'lib/environment_manager/api.rb', line 911

def post_permissions_config(data=Hash.new)
  # Create a new permission configuration"""
  request_endpoint = "/api/v1/config/permissions"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_services_config(data = Hash.new) ⇒ Object



1057
1058
1059
1060
1061
# File 'lib/environment_manager/api.rb', line 1057

def post_services_config(data=Hash.new)
  # Create a service configuration
  request_endpoint = "/api/v1/config/services"
  return query(request_endpoint, query_type: "POST", data: data)
end

#post_upstreams_config(data = Hash.new) ⇒ Object



1191
1192
1193
1194
1195
# File 'lib/environment_manager/api.rb', line 1191

def post_upstreams_config(data=Hash.new)
  # Create an upstream configuration
  request_endpoint = "/api/v1/config/upstreams"
  return query(request_endpoint, query_type: "POST", data: data)
end

#put_account_config(accountnumber = nil, data = Hash.new) ⇒ Object



144
145
146
147
148
149
150
151
# File 'lib/environment_manager/api.rb', line 144

def (accountnumber=nil, data=Hash.new)
  # Update an associated AWS Account
  if accountnumber.nil?
    raise("acountnumber has not been specified")
  end
  request_endpoint = "/api/v1/config/accounts/#{accountnumber}"
  return query(request_endpoint, query_type: "PUT", data: data)
end

#put_asg(environment = nil, asgname = nil, data = Hash.new) ⇒ Object



195
196
197
198
199
200
201
202
# File 'lib/environment_manager/api.rb', line 195

def put_asg(environment=nil, asgname=nil, data=Hash.new)
  # Update properties of an ASG
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}?environment=#{environment}"
  return query(request_endpoint, query_type: "PUT", data: data)
end

#put_asg_launch_config(environment = nil, asgname = nil, data = Hash.new) ⇒ Object



275
276
277
278
279
280
281
282
# File 'lib/environment_manager/api.rb', line 275

def put_asg_launch_config(environment=nil, asgname=nil, data=Hash.new)
  # Update the launch config associated with an ASG in the given environment
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}/launch-config?environment=#{environment}"
  return query(request_endpoint, query_type: "PUT", data: data)
end

#put_asg_scaling_schedule(environment = nil, asgname = nil, data = Hash.new) ⇒ Object



245
246
247
248
249
250
251
252
# File 'lib/environment_manager/api.rb', line 245

def put_asg_scaling_schedule(environment=nil, asgname=nil, data=Hash.new)
  # Update scaling schedule actions for given ASG
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}/scaling-schedule?environment=#{environment}"
  return query(request_endpoint, query_type: "PUT", data: data)
end

#put_asg_size(environment = nil, asgname = nil, data = Hash.new) ⇒ Object



255
256
257
258
259
260
261
262
# File 'lib/environment_manager/api.rb', line 255

def put_asg_size(environment=nil, asgname=nil, data=Hash.new)
  # Resize an ASG in the given environment
  if environment.nil? or asgname.nil?
    raise("Either environment or asgname has not been specified")
  end
  request_endpoint = "/api/v1/asgs/#{asgname}/size?environment=#{environment}"
  return query(request_endpoint, query_type: "PUT", data: data)
end

#put_cluster_config(cluster = nil, data = Hash.new) ⇒ Object



348
349
350
351
352
353
354
355
# File 'lib/environment_manager/api.rb', line 348

def put_cluster_config(cluster=nil, data=Hash.new)
  # Update a Cluster configuration
  if cluster.nil?
    raise("Cluster name has not been specified")
  end
  request_endpoint = "/api/v1/config/clusters/#{cluster}"
  return query(request_endpoint, query_type: "PUT", data: data)
end

#put_deployment_map(deployment_name = nil, expected_version = nil, data = Hash.new) ⇒ Object



441
442
443
444
445
446
447
448
449
450
451
452
453
# File 'lib/environment_manager/api.rb', line 441

def put_deployment_map(deployment_name=nil, expected_version=nil, data=Hash.new)
  # Update a deployment map configuration
  if deployment_name.nil?
    raise("Deployment name has not been specified")
  end
  if expected_version.nil?
    headers = ""
  else
    headers = {"expected-version" => expected_version}
  end
  request_endpoint = "/api/v1/deployment-maps/#{deployment_name}"
  return query(request_endpoint, query_type: "PUT", headers: headers, data: data)
end

#put_environment_config(environment = nil, expected_version = nil, data = Hash.new) ⇒ Object



608
609
610
611
612
613
614
615
616
617
618
619
620
# File 'lib/environment_manager/api.rb', line 608

def put_environment_config(environment=nil, expected_version=nil, data=Hash.new)
  # Update an environment configuration
  if environment.nil?
    raise("Environment has not been specified")
  end
  if expected_version.nil?
    headers = ""
  else
    headers = {"expected-version" => expected_version}
  end
  request_endpoint = "/api/v1/config/environments/#{environment}"
  return query(request_endpoint, query_type: "PUT", headers: headers, data: data)
end

#put_environment_schedule(environment = nil, expected_version = nil, data = Hash.new) ⇒ Object



524
525
526
527
528
529
530
531
532
533
534
535
536
# File 'lib/environment_manager/api.rb', line 524

def put_environment_schedule(environment=nil, expected_version=nil, data=Hash.new)
  # Set the schedule for an environment
  if environment.nil?
    raise("Environment has not been specified")
  end
  if expected_version.nil?
    headers = nil
  else
    headers = {"expected-version" => expected_version}
  end
  request_endpoint = "/api/v1/environments/#{environment}/schedule"
  return query(request_endpoint, query_type: "PUT", headers: headers, data: data)
end

#put_environmenttype_config(environmenttype = nil, expected_version = nil, data = Hash.new) ⇒ Object



658
659
660
661
662
663
664
665
666
667
668
669
670
# File 'lib/environment_manager/api.rb', line 658

def put_environmenttype_config(environmenttype=nil, expected_version=nil, data=Hash.new)
  # Update an environment type configuration
  if environmenttype.nil?
    raise("Environment type has not been specified")
  end
  if expected_version.nil?
    headers = ""
  else
    headers = {"expected-version" => expected_version}
  end
  request_endpoint = "/api/v1/config/environment-types/#{environmenttype}"
  return query(request_endpoint, query_type: "PUT", headers: headers, data: data)
end

#put_instance_maintenance(instance_id = nil, data = Hash.new) ⇒ Object



746
747
748
749
750
751
752
753
# File 'lib/environment_manager/api.rb', line 746

def put_instance_maintenance(instance_id=nil, data=Hash.new)
  # Update the ASG standby-state of a given instance
  if instance_id.nil?
    raise("Instance id has not been specified")
  end
  request_endpoint = "/api/v1/instances/#{instance_id}/maintenance"
  return query(request_endpoint, query_type: "PUT")
end

#put_lbsettings_vhost_config(environment = nil, vhostname = nil, expected_version = nil, data = Hash.new) ⇒ Object



800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
# File 'lib/environment_manager/api.rb', line 800

def put_lbsettings_vhost_config(environment=nil, vhostname=nil, expected_version=nil, data=Hash.new)
  # Update a load balancer setting
  if environment.nil?
    raise("Environment has not been specified")
  end
  if vhostname.nil?
    raise("Virtual Host Name (vhostname) has not been specified")
  end
  if expected_version.nil?
    headers = ""
  else
    headers = {"expected-version" => expected_version}
  end
  request_endpoint = "/api/v1/config/lb-settings/#{environment}/#{vhostname}"
  return query(request_endpoint, query_type: "PUT", headers: headers, data: data)
end

#put_notificationsetting_config(notification_id = nil, expected_version = nil, data = Hash.new) ⇒ Object



856
857
858
859
860
861
862
863
864
865
866
867
868
# File 'lib/environment_manager/api.rb', line 856

def put_notificationsetting_config(notification_id=nil, expected_version=nil, data=Hash.new)
  # Update an associated AWS Account
  if notification_id.nil?
    raise("Notification id has not been specified")
  end
  if expected_version.nil?
    headers = ""
  else
    headers = {"expected-version" => expected_version}
  end
  request_endpoint = "/api/v1/notification-settings/#{notification_id}"
  return query(request_endpoint, query_type: "PUT", headers: headers, data: data)
end

#put_permission_config(name = nil, expected_version = nil, data = Hash.new) ⇒ Object



928
929
930
931
932
933
934
935
936
937
938
939
940
# File 'lib/environment_manager/api.rb', line 928

def put_permission_config(name=nil, expected_version=nil, data=Hash.new)
  # Update a permission configuration
  if name.nil?
    raise("Permission name has not been specified")
  end
  if expected_version.nil?
    headers = ""
  else
    headers = {"expected-version" => expected_version}
  end
  request_endpoint = "/api/v1/config/permissions/#{name}"
  return query(request_endpoint, query_type: "PUT", headers: headers, data: data)
end

#put_service_config(service = nil, cluster = nil, expected_version = nil, data = Hash.new) ⇒ Object



1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
# File 'lib/environment_manager/api.rb', line 1077

def put_service_config(service=nil, cluster=nil, expected_version=nil, data=Hash.new)
  # Update a service configuration
  if service.nil?
    raise("Service has not been specified")
  end
  if cluster.nil?
    raise("Cluster name (team) has not been specified")
  end
  if expected_version.nil?
    headers = ""
  else
    headers = {"expected-version" => expected_version}
  end
  request_endpoint = "/api/v1/config/services/#{service}/#{cluster}"
  return query(request_endpoint, query_type: "POST", data: data, headers: headers)
end

#put_service_slices_toggle(service = nil, environment = nil) ⇒ Object



1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
# File 'lib/environment_manager/api.rb', line 1037

def put_service_slices_toggle(service=nil, environment=nil)
  # Toggle the slices for a deployed service
  if service.nil?
    raise("Service has not been specified")
  end
  if environment.nil?
    raise("Environment has not been specified")
  end
  request_endpoint = "/api/v1/services/#{service}/slices/toggle?environment=#{environment}"
  return query(request_endpoint, query_type: "PUT")
end

#put_upstream_config(upstream = nil, expected_version = nil, data = Hash.new) ⇒ Object



1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
# File 'lib/environment_manager/api.rb', line 1208

def put_upstream_config(upstream=nil, expected_version=nil, data=Hash.new)
  # Update an upstream configuration
  if upstream.nil?
    raise("Upstream name has not been specified")
  end
  if expected_version.nil?
    headers = ""
  else
    headers = {"expected-version" => expected_version}
  end
  request_endpoint = "/api/v1/config/upstreams/#{upstream}"
  return query(request_endpoint, query_type: "PUT", headers: headers, data: data)
end

#put_upstream_slices_toggle(upstream = nil, environment = nil) ⇒ Object



1168
1169
1170
1171
1172
1173
1174
1175
# File 'lib/environment_manager/api.rb', line 1168

def put_upstream_slices_toggle(upstream=nil, environment=nil)
  # Toggle the slices for a given upstream
  if upstream.nil? or environment.nil?
    raise("Upstream name or Service name has not been specified")
  end
  request_endpoint = "/api/v1/upstreams/#{upstream}/slices/toggle?environment=#{environment}"
  return query(request_endpoint, query_type: "GET")
end