Class: SemgrepWebApp::TicketingServiceApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/semgrep_web_app/apis/ticketing_service_api.rb

Overview

TicketingServiceApi

Constant Summary

Constants inherited from BaseApi

BaseApi::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#initialize, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from SemgrepWebApp::BaseApi

Instance Method Details

#ticketing_service_create_ticket(deployment_slug, body) ⇒ ApiResponse

Create Jira tickets for your findings. You can create tickets by passing in a list of issue_ids or by passing in filter query parameters to dynamically select findings. If passing in filters, Semgrep will skip already ticketed findings. This endpoint is synchronous, so it may take some time for your request to resolve. Unlike creating tickets in-app, if ticket creation fails we won't automatically retry. This endpoint accepts a limit parameter (defaulting to 20) to limit the number of tickets created per request. If you specify a list of issue_ids greater than this limit, or your selected filters match on a number of issues greater than this limit, issues that were not ticketed are included in the Failed part of the response object. You can send another request to create tickets for these skipped issues. By default, findings belonging to the same repository and the same rule will be grouped together into a single Jira ticket. You can override this using the group_issues query parameter. Up to 50 issues can be grouped into a single ticket. You can optionally override the Jira project you create tickets in by passing in a Jira project ID as jira_project_id (the numeric ID rather than the project key). You can fetch this ID using the Jira API. here description here

Parameters:

  • deployment_slug (String)

    Required parameter: TODO: type description

  • body (CreateTicketRequest)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
# File 'lib/semgrep_web_app/apis/ticketing_service_api.rb', line 122

def ticketing_service_create_ticket(deployment_slug,
                                    body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/v1/deployments/{deploymentSlug}/tickets',
                                 Server::SEMGREP)
               .template_param(new_parameter(deployment_slug, key: 'deploymentSlug')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('SemgrepWebToken')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ProtosOpenapiV1CreateTicketResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end

#ticketing_service_delete_ticket(deployment_id, external_ticket_id) ⇒ ApiResponse

Unlink a Jira ticket by its ID here description here

Parameters:

  • deployment_id (String)

    Required parameter: TODO: type description

  • external_ticket_id (Integer)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/semgrep_web_app/apis/ticketing_service_api.rb', line 15

def ticketing_service_delete_ticket(deployment_id,
                                    external_ticket_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::DELETE,
                                 '/api/v1/deployments/{deploymentId}/ticketing/v2/tickets/{externalTicketId}',
                                 Server::SEMGREP)
               .template_param(new_parameter(deployment_id, key: 'deploymentId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(external_ticket_id, key: 'externalTicketId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('SemgrepWebToken')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ProtosOpenapiV1DeleteTicketResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end

Link an existing external ticket (e.g. Jira) to one or more Semgrep findings by providing the ticket URL and a list of finding IDs. This does not create a ticket in your issue tracker — it only records the association in Semgrep. If a finding is already linked to a different ticket, the existing link is replaced. Requires a configured ticketing integration. here here

Parameters:

  • deployment_id (String)

    Required parameter: TODO: type description

  • body (LinkTicketRequest)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/semgrep_web_app/apis/ticketing_service_api.rb', line 47

def ticketing_service_link_ticket(deployment_id,
                                  body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/v1/deployments/{deploymentId}/tickets/link',
                                 Server::SEMGREP)
               .template_param(new_parameter(deployment_id, key: 'deploymentId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('SemgrepWebToken')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ProtosOpenapiV1LinkTicketResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end

Remove the ticket association from one or more Semgrep findings by providing a list of finding IDs. This does not delete the ticket in your issue tracker — it only removes the association in Semgrep. here description here

Parameters:

  • deployment_id (String)

    Required parameter: TODO: type description

  • body (UnlinkTicketRequest)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/semgrep_web_app/apis/ticketing_service_api.rb', line 77

def ticketing_service_unlink_ticket(deployment_id,
                                    body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/api/v1/deployments/{deploymentId}/tickets/unlink',
                                 Server::SEMGREP)
               .template_param(new_parameter(deployment_id, key: 'deploymentId')
                                .is_required(true)
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .body_param(new_parameter(body)
                            .is_required(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('SemgrepWebToken')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ProtosOpenapiV1UnlinkTicketResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end