Class: SemgrepWebApp::ProtosScaV1RepositoryDependencySummary

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

Overview

ProtosScaV1RepositoryDependencySummary 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(has_dependency_path_scan: SKIP, id: SKIP, name: SKIP, num_dependencies: SKIP, additional_properties: nil) ⇒ ProtosScaV1RepositoryDependencySummary

Returns a new instance of ProtosScaV1RepositoryDependencySummary.



56
57
58
59
60
61
62
63
64
65
66
# File 'lib/semgrep_web_app/models/protos_sca_v1_repository_dependency_summary.rb', line 56

def initialize(has_dependency_path_scan: SKIP, id: SKIP, name: SKIP,
               num_dependencies: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @has_dependency_path_scan = has_dependency_path_scan unless has_dependency_path_scan == SKIP
  @id = id unless id == SKIP
  @name = name unless name == SKIP
  @num_dependencies = num_dependencies unless num_dependencies == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#has_dependency_path_scanTrueClass | FalseClass

True if the repository has been scanned with the hasPathToTransitivityInScans feature flag which means it will have dependency graph data in DGraph available to query

Returns:

  • (TrueClass | FalseClass)


17
18
19
# File 'lib/semgrep_web_app/models/protos_sca_v1_repository_dependency_summary.rb', line 17

def has_dependency_path_scan
  @has_dependency_path_scan
end

#idInteger

ID of repository.

Returns:

  • (Integer)


21
22
23
# File 'lib/semgrep_web_app/models/protos_sca_v1_repository_dependency_summary.rb', line 21

def id
  @id
end

#nameString

Name of repository.

Returns:

  • (String)


25
26
27
# File 'lib/semgrep_web_app/models/protos_sca_v1_repository_dependency_summary.rb', line 25

def name
  @name
end

#num_dependenciesInteger

Total number of dependencies in the repository.

Returns:

  • (Integer)


29
30
31
# File 'lib/semgrep_web_app/models/protos_sca_v1_repository_dependency_summary.rb', line 29

def num_dependencies
  @num_dependencies
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



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

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  has_dependency_path_scan =
    hash.key?('hasDependencyPathScan') ? hash['hasDependencyPathScan'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  num_dependencies =
    hash.key?('numDependencies') ? hash['numDependencies'] : 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.
  ProtosScaV1RepositoryDependencySummary.new(has_dependency_path_scan: has_dependency_path_scan,
                                             id: id,
                                             name: name,
                                             num_dependencies: num_dependencies,
                                             additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



32
33
34
35
36
37
38
39
# File 'lib/semgrep_web_app/models/protos_sca_v1_repository_dependency_summary.rb', line 32

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['has_dependency_path_scan'] = 'hasDependencyPathScan'
  @_hash['id'] = 'id'
  @_hash['name'] = 'name'
  @_hash['num_dependencies'] = 'numDependencies'
  @_hash
end

.nullablesObject

An array for nullable fields



52
53
54
# File 'lib/semgrep_web_app/models/protos_sca_v1_repository_dependency_summary.rb', line 52

def self.nullables
  []
end

.optionalsObject

An array for optional fields



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

def self.optionals
  %w[
    has_dependency_path_scan
    id
    name
    num_dependencies
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



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

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} has_dependency_path_scan: #{@has_dependency_path_scan.inspect}, id:"\
  " #{@id.inspect}, name: #{@name.inspect}, num_dependencies: #{@num_dependencies.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



96
97
98
99
100
101
# File 'lib/semgrep_web_app/models/protos_sca_v1_repository_dependency_summary.rb', line 96

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} has_dependency_path_scan: #{@has_dependency_path_scan}, id: #{@id}, name:"\
  " #{@name}, num_dependencies: #{@num_dependencies}, additional_properties:"\
  " #{@additional_properties}>"
end