Class: SemgrepWebApp::CreateSbomExportRequest

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

Overview

CreateSbomExportRequest 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:, format_version: SKIP, metadata_component_type: MetadataComponentType::SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_APPLICATION, metadata_supplier: SKIP, ref: SKIP, repository_id: SKIP, sbom_output_format: SKIP, additional_properties: nil) ⇒ CreateSbomExportRequest

Returns a new instance of CreateSbomExportRequest.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 103

def initialize(
  deployment_id:, format_version: SKIP,
  metadata_component_type: MetadataComponentType::SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_APPLICATION,
  metadata_supplier: SKIP, ref: SKIP, repository_id: SKIP,
  sbom_output_format: SKIP, additional_properties: nil
)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @deployment_id = deployment_id
  @format_version = format_version unless format_version == SKIP
  @metadata_component_type =  unless  == SKIP
  @metadata_supplier =  unless  == SKIP
  @ref = ref unless ref == SKIP
  @repository_id = repository_id unless repository_id == SKIP
  @sbom_output_format = sbom_output_format unless sbom_output_format == SKIP
  @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/create_sbom_export_request.rb', line 15

def deployment_id
  @deployment_id
end

#format_versionProtosScaV1SbomFormatVersion

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



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

def format_version
  @format_version
end

#metadata_component_typeMetadataComponentType

Metadata component type for the SBOM export.

value description
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_APPLICATION
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_FRAMEWORK
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_LIBRARY
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_CONTAINER
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_PLATFORM
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_OPERATING_SYSTEM
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_DEVICE
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_DEVICE_DRIVER
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_FIRMWARE
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_FILE
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_MACHINE_LEARNING_MODEL
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_DATA


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

def 
  @metadata_component_type
end

#metadata_supplierProtosScaV1SbomMetadataSupplier

Metadata component type for the SBOM export.

value description
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_APPLICATION
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_FRAMEWORK
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_LIBRARY
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_CONTAINER
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_PLATFORM
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_OPERATING_SYSTEM
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_DEVICE
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_DEVICE_DRIVER
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_FIRMWARE
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_FILE
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_MACHINE_LEARNING_MODEL
SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_DATA


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

def 
  @metadata_supplier
end

#refString

Branch to export SBOM for (Ex. ref=refs/pull/1234/merge).

Returns:

  • (String)


60
61
62
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 60

def ref
  @ref
end

#repository_idString

Repository ID to export SBOM for.

Returns:

  • (String)


64
65
66
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 64

def repository_id
  @repository_id
end

#sbom_output_formatSbomOutputFormat

SBOM output format for the SBOM export.

value description
SBOM_OUTPUT_FORMAT_JSON

Returns:



71
72
73
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 71

def sbom_output_format
  @sbom_output_format
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 123

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  deployment_id = hash.key?('deploymentId') ? hash['deploymentId'] : nil
  format_version = ProtosScaV1SbomFormatVersion.from_hash(hash['formatVersion']) if
    hash['formatVersion']
   =
    hash['metadataComponentType'] ||= MetadataComponentType::SBOM_METADATA_COMPONENT_TYPE_CYCLONE_DX_V15_APPLICATION
   = ProtosScaV1SbomMetadataSupplier.from_hash(hash['metadataSupplier']) if
    hash['metadataSupplier']
  ref = hash.key?('ref') ? hash['ref'] : SKIP
  repository_id = hash.key?('repositoryId') ? hash['repositoryId'] : SKIP
  sbom_output_format =
    hash.key?('sbomOutputFormat') ? hash['sbomOutputFormat'] : 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.
  CreateSbomExportRequest.new(deployment_id: deployment_id,
                              format_version: format_version,
                              metadata_component_type: ,
                              metadata_supplier: ,
                              ref: ref,
                              repository_id: repository_id,
                              sbom_output_format: sbom_output_format,
                              additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



74
75
76
77
78
79
80
81
82
83
84
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 74

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['deployment_id'] = 'deploymentId'
  @_hash['format_version'] = 'formatVersion'
  @_hash['metadata_component_type'] = 'metadataComponentType'
  @_hash['metadata_supplier'] = 'metadataSupplier'
  @_hash['ref'] = 'ref'
  @_hash['repository_id'] = 'repositoryId'
  @_hash['sbom_output_format'] = 'sbomOutputFormat'
  @_hash
end

.nullablesObject

An array for nullable fields



99
100
101
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 99

def self.nullables
  []
end

.optionalsObject

An array for optional fields



87
88
89
90
91
92
93
94
95
96
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 87

def self.optionals
  %w[
    format_version
    metadata_component_type
    metadata_supplier
    ref
    repository_id
    sbom_output_format
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



167
168
169
170
171
172
173
174
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 167

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} deployment_id: #{@deployment_id.inspect}, format_version:"\
  " #{@format_version.inspect}, metadata_component_type: #{@metadata_component_type.inspect},"\
  " metadata_supplier: #{@metadata_supplier.inspect}, ref: #{@ref.inspect}, repository_id:"\
  " #{@repository_id.inspect}, sbom_output_format: #{@sbom_output_format.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



158
159
160
161
162
163
164
# File 'lib/semgrep_web_app/models/create_sbom_export_request.rb', line 158

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} deployment_id: #{@deployment_id}, format_version: #{@format_version},"\
  " metadata_component_type: #{@metadata_component_type}, metadata_supplier:"\
  " #{@metadata_supplier}, ref: #{@ref}, repository_id: #{@repository_id}, sbom_output_format:"\
  " #{@sbom_output_format}, additional_properties: #{@additional_properties}>"
end