Class: SemgrepWebApp::UpdateProjectRequest

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

Overview

UpdateProjectRequest 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_slug:, project_name:, managed_scan_config: SKIP, primary_branch: SKIP, tags: SKIP, additional_properties: nil) ⇒ UpdateProjectRequest

Returns a new instance of UpdateProjectRequest.



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

def initialize(deployment_slug:, project_name:, managed_scan_config: SKIP,
               primary_branch: SKIP, tags: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @deployment_slug = deployment_slug
  @managed_scan_config = managed_scan_config unless managed_scan_config == SKIP
  @primary_branch = primary_branch unless primary_branch == SKIP
  @project_name = project_name
  @tags = tags unless tags == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#deployment_slugString

Slug of the deployment name. 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_project_request.rb', line 15

def deployment_slug
  @deployment_slug
end

#managed_scan_configManagedScanConfig

[Beta] Configuration of Semgrep Managed Scans for the project, if relevant.

Returns:



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

def managed_scan_config
  @managed_scan_config
end

#primary_branchString

The full name of the branch you would like to set as primary. Use "None" if default_branch is known and you wish to set primary to always be the default branch.

Returns:

  • (String)


26
27
28
# File 'lib/semgrep_web_app/models/update_project_request.rb', line 26

def primary_branch
  @primary_branch
end

#project_nameString

Name of the project, typically the repository formatted as a path.

Returns:

  • (String)


30
31
32
# File 'lib/semgrep_web_app/models/update_project_request.rb', line 30

def project_name
  @project_name
end

#tagsArray[String]

Tags associated to this project.

Returns:

  • (Array[String])


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

def tags
  @tags
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/semgrep_web_app/models/update_project_request.rb', line 75

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  deployment_slug =
    hash.key?('deploymentSlug') ? hash['deploymentSlug'] : nil
  project_name = hash.key?('projectName') ? hash['projectName'] : nil
  managed_scan_config = ManagedScanConfig.from_hash(hash['managed_scan_config']) if
    hash['managed_scan_config']
  primary_branch =
    hash.key?('primary_branch') ? hash['primary_branch'] : SKIP
  tags = hash.key?('tags') ? hash['tags'] : SKIP

  # 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.
  UpdateProjectRequest.new(deployment_slug: deployment_slug,
                           project_name: project_name,
                           managed_scan_config: managed_scan_config,
                           primary_branch: primary_branch,
                           tags: tags,
                           additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



37
38
39
40
41
42
43
44
45
# File 'lib/semgrep_web_app/models/update_project_request.rb', line 37

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['deployment_slug'] = 'deploymentSlug'
  @_hash['managed_scan_config'] = 'managed_scan_config'
  @_hash['primary_branch'] = 'primary_branch'
  @_hash['project_name'] = 'projectName'
  @_hash['tags'] = 'tags'
  @_hash
end

.nullablesObject

An array for nullable fields



57
58
59
# File 'lib/semgrep_web_app/models/update_project_request.rb', line 57

def self.nullables
  []
end

.optionalsObject

An array for optional fields



48
49
50
51
52
53
54
# File 'lib/semgrep_web_app/models/update_project_request.rb', line 48

def self.optionals
  %w[
    managed_scan_config
    primary_branch
    tags
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



113
114
115
116
117
118
119
# File 'lib/semgrep_web_app/models/update_project_request.rb', line 113

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} deployment_slug: #{@deployment_slug.inspect}, managed_scan_config:"\
  " #{@managed_scan_config.inspect}, primary_branch: #{@primary_branch.inspect}, project_name:"\
  " #{@project_name.inspect}, tags: #{@tags.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



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

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} deployment_slug: #{@deployment_slug}, managed_scan_config:"\
  " #{@managed_scan_config}, primary_branch: #{@primary_branch}, project_name:"\
  " #{@project_name}, tags: #{@tags}, additional_properties: #{@additional_properties}>"
end