Class: Emasser::Container
- Inherits:
-
SubCommandBase
- Object
- Thor
- SubCommandBase
- Emasser::Container
- Defined in:
- lib/emasser/post.rb,
lib/emasser/delete.rb
Overview
The Container Scan Results endpoint provides the ability to remove containers and their scan results in the assets module for a system.
Endpoint:
/api/systems/{systemId}/container-scan-results
Class Method Summary collapse
Instance Method Summary collapse
-
#add ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
- #remove ⇒ Object
Methods inherited from SubCommandBase
Methods included from OutputConverters
#change_to_datetime, #to_output_hash
Methods included from InputConverters
Methods included from OptionsParser
#optional_options, #required_options
Class Method Details
.exit_on_failure? ⇒ Boolean
968 969 970 |
# File 'lib/emasser/post.rb', line 968 def self.exit_on_failure? true end |
Instance Method Details
#add ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 |
# File 'lib/emasser/post.rb', line 1004 def add # Required fields body = {} body[:containerId] = [:containerId] body[:containerName] = [:containerName] body[:time] = [:time] # Optional fields body[:namespace] = [:namespace] if [:namespace] body[:podIp] = [:podIp] if [:podIp] body[:podName] = [:podName] if [:podName] # Tags - Optional field = {} [:test] = [:test] if [:test] # Benchmarks - Required field benchmarks = {} benchmarks[:benchmark] = [:benchmark] # Benchmarks - Optional fields benchmarks[:isBaseline] = [:isBaseline] if [:isBaseline] benchmarks[:version] = [:version] if [:version] benchmarks[:release] = [:release] if [:release] # Benchmarks.Results - Required fields benchmarks_results = {} benchmarks_results[:lastSeen] = [:lastSeen] benchmarks_results[:ruleId] = [:ruleId] benchmarks_results[:status] = [:status] # Benchmarks.Results - Optional field benchmarks_results[:message] = [:message] if [:message] # Add Benchmark results to an array and add array to benchmarks object benchmarks_results_array = Array.new(1, benchmarks_results) benchmarks[:results] = benchmarks_results_array # Add benchmarks object to an array benchmarks_array = Array.new(1, benchmarks) # Add tags and benchmark ojects to body object body[:tags] = if .any? body[:benchmarks] = benchmarks_array # Build the body array body_array = Array.new(1, body) # Call the API begin result = EmassClient::ContainerScanResultsApi .new.add_container_sans_by_system_id([:systemId], body_array) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling ContainerScanResultsApi->add_container_sans_by_system_id'.red puts to_output_hash(e) end end |
#remove ⇒ Object
243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/emasser/delete.rb', line 243 def remove body = EmassClient::ContainerResourcesDeleteBodyInner.new body.container_id = [:containerId] body_array = Array.new(1, body) result = EmassClient::ContainerScanResultsApi.new.delete_container_sans([:systemId], body_array) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling ContainerScanResultsApi->delete_container_sans'.red puts to_output_hash(e) end |