Class: SemgrepWebApp::ListProject

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

Overview

A project in your organization that uses Semgrep.

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(id:, name:, tags:, created_at: SKIP, default_branch: SKIP, latest_scan_at: SKIP, primary_branch: SKIP, url: SKIP, additional_properties: nil) ⇒ ListProject

Returns a new instance of ListProject.



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/semgrep_web_app/models/list_project.rb', line 74

def initialize(id:, name:, tags:, created_at: SKIP, default_branch: SKIP,
               latest_scan_at: SKIP, primary_branch: SKIP, url: SKIP,
               additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @created_at = created_at unless created_at == SKIP
  @default_branch = default_branch unless default_branch == SKIP
  @id = id
  @latest_scan_at = latest_scan_at unless latest_scan_at == SKIP
  @name = name
  @primary_branch = primary_branch unless primary_branch == SKIP
  @tags = tags
  @url = url unless url == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#created_atString

Time when this project was created.

Returns:

  • (String)


14
15
16
# File 'lib/semgrep_web_app/models/list_project.rb', line 14

def created_at
  @created_at
end

#default_branchString

The default branch in the SCM.

Returns:

  • (String)


18
19
20
# File 'lib/semgrep_web_app/models/list_project.rb', line 18

def default_branch
  @default_branch
end

#idInteger

Unique ID of this project.

Returns:

  • (Integer)


22
23
24
# File 'lib/semgrep_web_app/models/list_project.rb', line 22

def id
  @id
end

#latest_scan_atString

Time of latest scan, if there is one.

Returns:

  • (String)


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

def latest_scan_at
  @latest_scan_at
end

#nameString

Name of the project.

Returns:

  • (String)


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

def name
  @name
end

#primary_branchString

The primary branch of the project, if known.

Returns:

  • (String)


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

def primary_branch
  @primary_branch
end

#tagsArray[String]

Tags associated to this project.

Returns:

  • (Array[String])


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

def tags
  @tags
end

#urlString

URL of the project, if there is one.

Returns:

  • (String)


42
43
44
# File 'lib/semgrep_web_app/models/list_project.rb', line 42

def url
  @url
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# File 'lib/semgrep_web_app/models/list_project.rb', line 92

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  id = hash.key?('id') ? hash['id'] : nil
  name = hash.key?('name') ? hash['name'] : nil
  tags = hash.key?('tags') ? hash['tags'] : nil
  created_at = hash.key?('created_at') ? hash['created_at'] : SKIP
  default_branch =
    hash.key?('default_branch') ? hash['default_branch'] : SKIP
  latest_scan_at =
    hash.key?('latest_scan_at') ? hash['latest_scan_at'] : SKIP
  primary_branch =
    hash.key?('primary_branch') ? hash['primary_branch'] : SKIP
  url = hash.key?('url') ? hash['url'] : 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.
  ListProject.new(id: id,
                  name: name,
                  tags: tags,
                  created_at: created_at,
                  default_branch: default_branch,
                  latest_scan_at: latest_scan_at,
                  primary_branch: primary_branch,
                  url: url,
                  additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/semgrep_web_app/models/list_project.rb', line 45

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['created_at'] = 'created_at'
  @_hash['default_branch'] = 'default_branch'
  @_hash['id'] = 'id'
  @_hash['latest_scan_at'] = 'latest_scan_at'
  @_hash['name'] = 'name'
  @_hash['primary_branch'] = 'primary_branch'
  @_hash['tags'] = 'tags'
  @_hash['url'] = 'url'
  @_hash
end

.nullablesObject

An array for nullable fields



70
71
72
# File 'lib/semgrep_web_app/models/list_project.rb', line 70

def self.nullables
  []
end

.optionalsObject

An array for optional fields



59
60
61
62
63
64
65
66
67
# File 'lib/semgrep_web_app/models/list_project.rb', line 59

def self.optionals
  %w[
    created_at
    default_branch
    latest_scan_at
    primary_branch
    url
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



136
137
138
139
140
141
142
143
# File 'lib/semgrep_web_app/models/list_project.rb', line 136

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at.inspect}, default_branch:"\
  " #{@default_branch.inspect}, id: #{@id.inspect}, latest_scan_at:"\
  " #{@latest_scan_at.inspect}, name: #{@name.inspect}, primary_branch:"\
  " #{@primary_branch.inspect}, tags: #{@tags.inspect}, url: #{@url.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



128
129
130
131
132
133
# File 'lib/semgrep_web_app/models/list_project.rb', line 128

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} created_at: #{@created_at}, default_branch: #{@default_branch}, id: #{@id},"\
  " latest_scan_at: #{@latest_scan_at}, name: #{@name}, primary_branch: #{@primary_branch},"\
  " tags: #{@tags}, url: #{@url}, additional_properties: #{@additional_properties}>"
end