Class: Emasser::CloudResource
- Inherits:
-
SubCommandBase
- Object
- Thor
- SubCommandBase
- Emasser::CloudResource
- Defined in:
- lib/emasser/post.rb,
lib/emasser/delete.rb
Overview
The Cloud Resource Results endpoint provides the ability to remove cloud resources and their scan results in the assets module for a system.
Endpoint:
/api/systems/{systemId}/cloud-resource-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
876 877 878 |
# File 'lib/emasser/post.rb', line 876 def self.exit_on_failure? true end |
Instance Method Details
#add ⇒ Object
rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 |
# File 'lib/emasser/post.rb', line 911 def add # Required and Optional main fields body = {} body[:provider] = [:provider] body[:resourceId] = [:resourceId] body[:resourceName] = [:resourceName] body[:resourceType] = [:resourceType] body[:initiatedBy] = [:initiatedBy] if [:initiatedBy] body[:cspAccountId] = [:cspAccountId] if [:cspAccountId] body[:cspRegion] = [:cspRegion] if [:cspRegion] body[:isBaseline] = [:isBaseline] if [:isBaseline] # Optional tags field = {} [:test] = [:test] if [:test] # Required and Optional compliances results fields compliance_results = {} compliance_results[:cspPolicyDefinitionId] = [:cspPolicyDefinitionId] compliance_results[:isCompliant] = [:isCompliant] compliance_results[:policyDefinitionTitle] = [:policyDefinitionTitle] # Optional fields compliance_results[:assessmentProcedure] = [:assessmentProcedure] if [:assessmentProcedure] compliance_results[:complianceCheckTimestamp] = [:complianceCheckTimestamp] if [:complianceCheckTimestamp] compliance_results[:complianceReason] = [:complianceReason] if [:complianceReason] compliance_results[:control] = [:control] if [:control] compliance_results[:policyDeploymentName] = [:policyDeploymentName] if [:policyDeploymentName] compliance_results[:policyDeploymentVersion] = [:policyDeploymentVersion] if [:policyDeploymentVersion] compliance_results[:severity] = [:severity] if [:severity] compliance_results_array = Array.new(1, compliance_results) # Build the body array body[:tags] = body[:complianceResults] = compliance_results_array body_array = Array.new(1, body) # Call the API begin result = EmassClient::CloudResourceResultsApi .new.add_cloud_resources_by_system_id([:systemId], body_array) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling StaticCodeScansApi->add_cloud_resources_by_system_id'.red puts to_output_hash(e) end end |
#remove ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 |
# File 'lib/emasser/delete.rb', line 214 def remove body = EmassClient::CloudResourcesDeleteBodyInner.new body.resource_id = [:resourceId] body_array = Array.new(1, body) result = EmassClient::CloudResourceResultsApi.new.delete_cloud_resources([:systemId], body_array) puts to_output_hash(result).green rescue EmassClient::ApiError => e puts 'Exception when calling CloudResourceResultsApi->delete_cloud_resources'.red puts to_output_hash(e) end |