Class: SemgrepWebApp::Client
- Inherits:
-
Object
- Object
- SemgrepWebApp::Client
- Includes:
- CoreLibrary
- Defined in:
- lib/semgrep_web_app/client.rb
Overview
semgrep_web_app client class.
Instance Attribute Summary collapse
-
#auth_managers ⇒ Object
readonly
Returns the value of attribute auth_managers.
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Class Method Summary collapse
-
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
Instance Method Summary collapse
-
#deployments_service ⇒ DeploymentsServiceApi
Access to deployments_service controller.
-
#findings_service ⇒ FindingsServiceApi
Access to findings_service controller.
-
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, semgrep_admin_jwt_credentials: nil, semgrep_jwt_credentials: nil, semgrep_web_token_credentials: nil, config: nil) ⇒ Client
constructor
A new instance of Client.
-
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
-
#misc_service ⇒ MiscServiceApi
Access to misc_service controller.
-
#policies_service ⇒ PoliciesServiceApi
Access to policies_service controller.
-
#projects_service ⇒ ProjectsServiceApi
Access to projects_service controller.
-
#scans_service ⇒ ScansServiceApi
Access to scans_service controller.
-
#secrets_service ⇒ SecretsServiceApi
Access to secrets_service controller.
-
#supply_chain_service ⇒ SupplyChainServiceApi
Access to supply_chain_service controller.
-
#ticketing_service ⇒ TicketingServiceApi
Access to ticketing_service controller.
-
#triage_service ⇒ TriageServiceApi
Access to triage_service controller.
- #user_agent_detail ⇒ Object
Constructor Details
#initialize(connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put],, http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, semgrep_admin_jwt_credentials: nil, semgrep_jwt_credentials: nil, semgrep_web_token_credentials: nil, config: nil) ⇒ Client
Returns a new instance of Client.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/semgrep_web_app/client.rb', line 76 def initialize( connection: nil, adapter: :net_http_persistent, timeout: 30, max_retries: 0, retry_interval: 1, backoff_factor: 2, retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524], retry_methods: %i[get put], http_callback: nil, proxy_settings: nil, logging_configuration: nil, environment: Environment::PRODUCTION, semgrep_admin_jwt_credentials: nil, semgrep_jwt_credentials: nil, semgrep_web_token_credentials: nil, config: nil ) @config = if config.nil? Configuration.new( connection: connection, adapter: adapter, timeout: timeout, max_retries: max_retries, retry_interval: retry_interval, backoff_factor: backoff_factor, retry_statuses: retry_statuses, retry_methods: retry_methods, http_callback: http_callback, proxy_settings: proxy_settings, logging_configuration: logging_configuration, environment: environment, semgrep_admin_jwt_credentials: semgrep_admin_jwt_credentials, semgrep_jwt_credentials: semgrep_jwt_credentials, semgrep_web_token_credentials: semgrep_web_token_credentials ) else config end user_agent_params = BaseApi.user_agent_parameters @global_configuration = GlobalConfiguration.new(client_configuration: @config) .base_uri_executor(@config.method(:get_base_uri)) .global_errors(BaseApi::GLOBAL_ERRORS) .user_agent(BaseApi.user_agent, agent_parameters: user_agent_params) initialize_auth_managers(@global_configuration) @global_configuration = @global_configuration.auth_managers(@auth_managers) end |
Instance Attribute Details
#auth_managers ⇒ Object (readonly)
Returns the value of attribute auth_managers.
10 11 12 |
# File 'lib/semgrep_web_app/client.rb', line 10 def auth_managers @auth_managers end |
#config ⇒ Object (readonly)
Returns the value of attribute config.
10 11 12 |
# File 'lib/semgrep_web_app/client.rb', line 10 def config @config end |
Class Method Details
.from_env(**overrides) ⇒ Object
Creates a client directly from environment variables.
130 131 132 133 134 |
# File 'lib/semgrep_web_app/client.rb', line 130 def self.from_env(**overrides) default_config = Configuration.build_default_config_from_env new_config = default_config.clone_with(**overrides) new(config: new_config) end |
Instance Method Details
#deployments_service ⇒ DeploymentsServiceApi
Access to deployments_service controller.
18 19 20 |
# File 'lib/semgrep_web_app/client.rb', line 18 def deployments_service @deployments_service ||= DeploymentsServiceApi.new @global_configuration end |
#findings_service ⇒ FindingsServiceApi
Access to findings_service controller.
24 25 26 |
# File 'lib/semgrep_web_app/client.rb', line 24 def findings_service @findings_service ||= FindingsServiceApi.new @global_configuration end |
#initialize_auth_managers(global_config) ⇒ Object
Initializes the auth managers hash used for authenticating API calls.
116 117 118 119 120 121 122 123 124 125 126 127 |
# File 'lib/semgrep_web_app/client.rb', line 116 def initialize_auth_managers(global_config) @auth_managers = {} http_client_config = global_config.client_configuration %w[SemgrepAdminJWT SemgrepJWT SemgrepWebToken].each { |auth| @auth_managers[auth] = nil } @auth_managers['SemgrepAdminJWT'] = SemgrepAdminJwt.new( http_client_config.semgrep_admin_jwt_credentials ) @auth_managers['SemgrepJWT'] = SemgrepJwt.new(http_client_config.semgrep_jwt_credentials) @auth_managers['SemgrepWebToken'] = SemgrepWebToken.new( http_client_config.semgrep_web_token_credentials ) end |
#misc_service ⇒ MiscServiceApi
Access to misc_service controller.
30 31 32 |
# File 'lib/semgrep_web_app/client.rb', line 30 def misc_service @misc_service ||= MiscServiceApi.new @global_configuration end |
#policies_service ⇒ PoliciesServiceApi
Access to policies_service controller.
36 37 38 |
# File 'lib/semgrep_web_app/client.rb', line 36 def policies_service @policies_service ||= PoliciesServiceApi.new @global_configuration end |
#projects_service ⇒ ProjectsServiceApi
Access to projects_service controller.
42 43 44 |
# File 'lib/semgrep_web_app/client.rb', line 42 def projects_service @projects_service ||= ProjectsServiceApi.new @global_configuration end |
#scans_service ⇒ ScansServiceApi
Access to scans_service controller.
48 49 50 |
# File 'lib/semgrep_web_app/client.rb', line 48 def scans_service @scans_service ||= ScansServiceApi.new @global_configuration end |
#secrets_service ⇒ SecretsServiceApi
Access to secrets_service controller.
54 55 56 |
# File 'lib/semgrep_web_app/client.rb', line 54 def secrets_service @secrets_service ||= SecretsServiceApi.new @global_configuration end |
#supply_chain_service ⇒ SupplyChainServiceApi
Access to supply_chain_service controller.
60 61 62 |
# File 'lib/semgrep_web_app/client.rb', line 60 def supply_chain_service @supply_chain_service ||= SupplyChainServiceApi.new @global_configuration end |
#ticketing_service ⇒ TicketingServiceApi
Access to ticketing_service controller.
66 67 68 |
# File 'lib/semgrep_web_app/client.rb', line 66 def ticketing_service @ticketing_service ||= TicketingServiceApi.new @global_configuration end |
#triage_service ⇒ TriageServiceApi
Access to triage_service controller.
72 73 74 |
# File 'lib/semgrep_web_app/client.rb', line 72 def triage_service @triage_service ||= TriageServiceApi.new @global_configuration end |
#user_agent_detail ⇒ Object
12 13 14 |
# File 'lib/semgrep_web_app/client.rb', line 12 def user_agent_detail config.user_agent_detail end |