Class: SemgrepWebApp::Project
- Defined in:
- lib/semgrep_web_app/models/project.rb
Overview
A project in your organization that uses Semgrep.
Instance Attribute Summary collapse
-
#created_at ⇒ String
Time when this project was created.
-
#default_branch ⇒ String
The default branch in the SCM.
-
#id ⇒ Integer
Unique ID of this project.
-
#latest_scan_at ⇒ String
Time of latest scan, if there is one.
-
#managed_scan_config ⇒ ManagedScanConfig
[Beta] Configuration of Semgrep Managed Scans for the project, if relevant.
-
#name ⇒ String
Name of the project.
-
#primary_branch ⇒ String
The primary branch of the project, if known.
-
#tags ⇒ Array[String]
Tags associated to this project.
-
#url ⇒ String
URL of the project, if there is one.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(id:, name:, tags:, created_at: SKIP, default_branch: SKIP, latest_scan_at: SKIP, managed_scan_config: SKIP, primary_branch: SKIP, url: SKIP, additional_properties: nil) ⇒ Project
constructor
A new instance of Project.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
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, managed_scan_config: SKIP, primary_branch: SKIP, url: SKIP, additional_properties: nil) ⇒ Project
Returns a new instance of Project.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/semgrep_web_app/models/project.rb', line 81 def initialize(id:, name:, tags:, created_at: SKIP, default_branch: SKIP, latest_scan_at: SKIP, managed_scan_config: 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 @managed_scan_config = managed_scan_config unless managed_scan_config == SKIP @name = name @primary_branch = primary_branch unless primary_branch == SKIP @tags = @url = url unless url == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#created_at ⇒ String
Time when this project was created.
14 15 16 |
# File 'lib/semgrep_web_app/models/project.rb', line 14 def created_at @created_at end |
#default_branch ⇒ String
The default branch in the SCM.
18 19 20 |
# File 'lib/semgrep_web_app/models/project.rb', line 18 def default_branch @default_branch end |
#id ⇒ Integer
Unique ID of this project.
22 23 24 |
# File 'lib/semgrep_web_app/models/project.rb', line 22 def id @id end |
#latest_scan_at ⇒ String
Time of latest scan, if there is one.
26 27 28 |
# File 'lib/semgrep_web_app/models/project.rb', line 26 def latest_scan_at @latest_scan_at end |
#managed_scan_config ⇒ ManagedScanConfig
[Beta] Configuration of Semgrep Managed Scans for the project, if relevant.
31 32 33 |
# File 'lib/semgrep_web_app/models/project.rb', line 31 def managed_scan_config @managed_scan_config end |
#name ⇒ String
Name of the project.
35 36 37 |
# File 'lib/semgrep_web_app/models/project.rb', line 35 def name @name end |
#primary_branch ⇒ String
The primary branch of the project, if known.
39 40 41 |
# File 'lib/semgrep_web_app/models/project.rb', line 39 def primary_branch @primary_branch end |
#tags ⇒ Array[String]
Tags associated to this project.
43 44 45 |
# File 'lib/semgrep_web_app/models/project.rb', line 43 def @tags end |
#url ⇒ String
URL of the project, if there is one.
47 48 49 |
# File 'lib/semgrep_web_app/models/project.rb', line 47 def url @url end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
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 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/semgrep_web_app/models/project.rb', line 100 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 = 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 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 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. Project.new(id: id, name: name, tags: , created_at: created_at, default_branch: default_branch, latest_scan_at: latest_scan_at, managed_scan_config: managed_scan_config, primary_branch: primary_branch, url: url, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/semgrep_web_app/models/project.rb', line 50 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['managed_scan_config'] = 'managed_scan_config' @_hash['name'] = 'name' @_hash['primary_branch'] = 'primary_branch' @_hash['tags'] = 'tags' @_hash['url'] = 'url' @_hash end |
.nullables ⇒ Object
An array for nullable fields
77 78 79 |
# File 'lib/semgrep_web_app/models/project.rb', line 77 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/semgrep_web_app/models/project.rb', line 65 def self.optionals %w[ created_at default_branch latest_scan_at managed_scan_config primary_branch url ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
148 149 150 151 152 153 154 155 |
# File 'lib/semgrep_web_app/models/project.rb', line 148 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}, managed_scan_config: #{@managed_scan_config.inspect}, name:"\ " #{@name.inspect}, primary_branch: #{@primary_branch.inspect}, tags: #{@tags.inspect}, url:"\ " #{@url.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
139 140 141 142 143 144 145 |
# File 'lib/semgrep_web_app/models/project.rb', line 139 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}, managed_scan_config: #{@managed_scan_config}, name:"\ " #{@name}, primary_branch: #{@primary_branch}, tags: #{@tags}, url: #{@url},"\ " additional_properties: #{@additional_properties}>" end |