Class: SemgrepWebApp::PoliciesServiceApi

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

Overview

PoliciesServiceApi

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

#list_policies(deployment_id) ⇒ ApiResponse

TODO: type endpoint description here here

Parameters:

  • deployment_id (String)

    Required parameter: TODO: type description

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/semgrep_web_app/apis/policies_service_api.rb', line 13

def list_policies(deployment_id)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/v1/deployments/{deploymentId}/policies',
                                 Server::SEMGREP)
               .template_param(new_parameter(deployment_id, key: 'deploymentId')
                                .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(ProtosOpenapiV1ListPoliciesResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end

#list_policy_rules(deployment_id, policy_id, cursor: nil, limit: nil) ⇒ ApiResponse

TODO: type endpoint description here here here

Parameters:

  • deployment_id (String)

    Required parameter: TODO: type description

  • policy_id (String)

    Required parameter: TODO: type description

  • cursor (String) (defaults to: nil)

    Optional parameter: TODO: type description here

  • limit (Integer) (defaults to: nil)

    Optional parameter: TODO: type description here

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/semgrep_web_app/apis/policies_service_api.rb', line 38

def list_policy_rules(deployment_id,
                      policy_id,
                      cursor: nil,
                      limit: nil)
  @api_call
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/api/v1/deployments/{deploymentId}/policies/{policyId}',
                                 Server::SEMGREP)
               .template_param(new_parameter(deployment_id, key: 'deploymentId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(policy_id, key: 'policyId')
                                .is_required(true)
                                .should_encode(true))
               .query_param(new_parameter(cursor, key: 'cursor'))
               .query_param(new_parameter(limit, key: 'limit'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('SemgrepWebToken')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(ProtosOpenapiV1ListPolicyRulesResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end

#update_policy(deployment_id, policy_id, body) ⇒ ApiResponse

TODO: type endpoint description here here here description here

Parameters:

  • deployment_id (String)

    Required parameter: TODO: type description

  • policy_id (String)

    Required parameter: TODO: type description

  • body (UpdatePolicyRequest)

    Required parameter: TODO: type

Returns:

  • (ApiResponse)

    Complete http response with raw body and status code.



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

def update_policy(deployment_id,
                  policy_id,
                  body)
  @api_call
    .request(new_request_builder(HttpMethodEnum::PUT,
                                 '/api/v1/deployments/{deploymentId}/policies/{policyId}',
                                 Server::SEMGREP)
               .template_param(new_parameter(deployment_id, key: 'deploymentId')
                                .is_required(true)
                                .should_encode(true))
               .template_param(new_parameter(policy_id, key: 'policyId')
                                .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(ProtosOpenapiV1UpdatePolicyResponse.method(:from_hash))
                .is_api_response(true))
    .execute
end