# Code generated by Speakeasy (https://speakeasyapi.dev). DO NOT EDIT. # typed: true # frozen_string_literal: true require 'faraday' require 'faraday/multipart' require 'sorbet-runtime' module SpeakeasyClientSDK extend T::Sig class Plugins extend T::Sig sig { params(sdk: SpeakeasyClientSDK::SDK, client: Faraday::Connection, server_url: String, language: String, sdk_version: String, gen_version: String, openapi_doc_version: String).void } def initialize(sdk, client, server_url, language, sdk_version, gen_version, openapi_doc_version) @sdk = sdk @client = client @server_url = server_url @language = language @sdk_version = sdk_version @gen_version = gen_version @openapi_doc_version = openapi_doc_version end sig { returns(Utils::FieldAugmented) } def get_plugins # get_plugins - Get all plugins for the current workspace. base_url = @server_url url = "#{base_url.delete_suffix('/')}/v1/plugins" headers = {} headers['Accept'] = 'application/json;q=1, application/json;q=0' headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version} #{@openapi_doc_version}" r = @client.get(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = Operations::GetPluginsResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, T::Array[Shared::Plugin]) res.plugins = out end else if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, Shared::Error) res.error = out end end res end sig { params(request: Operations::RunPluginRequest).returns(Utils::FieldAugmented) } def run_plugin(request) # run_plugin - Run a plugin base_url = @server_url url = Utils.generate_url( Operations::RunPluginRequest, base_url, '/v1/plugins/{pluginID}', request ) headers = {} query_params = Utils.get_query_params(Operations::RunPluginRequest, request) headers['Accept'] = 'application/json;q=1, application/json;q=0' headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version} #{@openapi_doc_version}" r = @client.post(url) do |req| req.headers = headers req.params = query_params Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil? end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = Operations::RunPluginResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, T::Array[Shared::BoundedRequest]) res.bounded_requests = out end else if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, Shared::Error) res.error = out end end res end sig { params(request: Shared::Plugin).returns(Utils::FieldAugmented) } def upsert_plugin(request) # upsert_plugin - Upsert a plugin base_url = @server_url url = "#{base_url.delete_suffix('/')}/v1/plugins" headers = {} req_content_type, data, form = Utils.serialize_request_body(request, :request, :json) headers['content-type'] = req_content_type raise StandardError, 'request body is required' if data.nil? && form.nil? headers['Accept'] = 'application/json;q=1, application/json;q=0' headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version} #{@openapi_doc_version}" r = @client.put(url) do |req| req.headers = headers Utils.configure_request_security(req, @sdk.security) if !@sdk.nil? && !@sdk.security.nil? if form req.body = Utils.encode_form(form) elsif Utils.match_content_type(req_content_type, 'application/x-www-form-urlencoded') req.body = URI.encode_www_form(data) else req.body = data end end content_type = r.headers.fetch('Content-Type', 'application/octet-stream') res = Operations::UpsertPluginResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, Shared::Plugin) res.plugin = out end else if Utils.match_content_type(content_type, 'application/json') out = Utils.unmarshal_complex(r.env.response_body, Shared::Error) res.error = out end end res end end end