Class: SemgrepWebApp::UpdatePolicyRequest

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/semgrep_web_app/models/update_policy_request.rb

Overview

UpdatePolicyRequest Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(deployment_id:, policy_id:, policy_mode:, rule_path:, additional_properties: nil) ⇒ UpdatePolicyRequest

Returns a new instance of UpdatePolicyRequest.



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 60

def initialize(deployment_id:, policy_id:, policy_mode:, rule_path:,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @deployment_id = deployment_id
  @policy_id = policy_id
  @policy_mode = policy_mode
  @rule_path = rule_path
  @additional_properties = additional_properties
end

Instance Attribute Details

#deployment_idString

Deployment ID (numeric). Example: 123. Can be found at /deployments, or in your Settings in the web UI.

Returns:

  • (String)


15
16
17
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 15

def deployment_id
  @deployment_id
end

#policy_idString

Policy ID (numeric). Example: 456. Can be found at /deployments/{deploymentId}/policies.

Returns:

  • (String)


20
21
22
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 20

def policy_id
  @policy_id
end

#policy_modePolicyMode3

New policy mode to set for the Rule.

  • MODE_MONITOR: Monitor mode, silently report findings
  • MODE_COMMENT: Comment mode, leaves PR comments but does not block
  • MODE_BLOCK: Block mode, leaves PR comments and blocks PR
  • MODE_DISABLED: Disabled mode, not active
value description
MODE_MONITOR Monitor mode, silently report findings
MODE_COMMENT Comment mode, leaves PR comments but does not block
MODE_BLOCK Block mode, leaves PR comments and blocks PR
MODE_DISABLED Disabled mode, not active

Returns:



34
35
36
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 34

def policy_mode
  @policy_mode
end

#rule_pathString

Full path of the Rule.

Returns:

  • (String)


38
39
40
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 38

def rule_path
  @rule_path
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 73

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  deployment_id = hash.key?('deploymentId') ? hash['deploymentId'] : nil
  policy_id = hash.key?('policyId') ? hash['policyId'] : nil
  policy_mode = hash.key?('policyMode') ? hash['policyMode'] : nil
  rule_path = hash.key?('rulePath') ? hash['rulePath'] : nil

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  UpdatePolicyRequest.new(deployment_id: deployment_id,
                          policy_id: policy_id,
                          policy_mode: policy_mode,
                          rule_path: rule_path,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['deployment_id'] = 'deploymentId'
  @_hash['policy_id'] = 'policyId'
  @_hash['policy_mode'] = 'policyMode'
  @_hash['rule_path'] = 'rulePath'
  @_hash
end

.nullablesObject

An array for nullable fields



56
57
58
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 56

def self.nullables
  []
end

.optionalsObject

An array for optional fields



51
52
53
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 51

def self.optionals
  []
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



106
107
108
109
110
111
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 106

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} deployment_id: #{@deployment_id.inspect}, policy_id: #{@policy_id.inspect},"\
  " policy_mode: #{@policy_mode.inspect}, rule_path: #{@rule_path.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



98
99
100
101
102
103
# File 'lib/semgrep_web_app/models/update_policy_request.rb', line 98

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} deployment_id: #{@deployment_id}, policy_id: #{@policy_id}, policy_mode:"\
  " #{@policy_mode}, rule_path: #{@rule_path}, additional_properties:"\
  " #{@additional_properties}>"
end