Files
plexruby/lib/plex_ruby_sdk/server.rb

858 lines
29 KiB
Ruby

# Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
# typed: true
# frozen_string_literal: true
require 'faraday'
require 'faraday/multipart'
require 'faraday/retry'
require 'sorbet-runtime'
require_relative 'sdk_hooks/hooks'
require_relative 'utils/retries'
module PlexRubySDK
extend T::Sig
class Server
extend T::Sig
# Operations against the Plex Media Server System.
#
sig { params(sdk_config: SDKConfiguration).void }
def initialize(sdk_config)
@sdk_configuration = sdk_config
end
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetServerCapabilitiesResponse) }
def get_server_capabilities(timeout_ms = nil)
# get_server_capabilities - Get Server Capabilities
# Get Server Capabilities
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/"
headers = {}
headers['Accept'] = 'application/json'
headers['user-agent'] = @sdk_configuration.user_agent
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
base_url: base_url,
oauth2_scopes: nil,
operation_id: 'getServerCapabilities',
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
r = T.let(nil, T.nilable(Faraday::Response))
begin
r = connection.get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if r.nil? || Utils.error_status?(r.status)
r = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
else
r = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
end
if r.nil?
raise error if !error.nil?
raise 'no response'
end
end
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
res = ::PlexRubySDK::Operations::GetServerCapabilitiesResponse.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 = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerCapabilitiesResponseBody)
res.object = out
end
elsif r.status == 400
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerCapabilitiesBadRequest)
res.bad_request = out
end
elsif r.status == 401
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerCapabilitiesUnauthorized)
res.unauthorized = out
end
end
res
end
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetServerPreferencesResponse) }
def get_server_preferences(timeout_ms = nil)
# get_server_preferences - Get Server Preferences
# Get Server Preferences
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/:/prefs"
headers = {}
headers['Accept'] = 'application/json'
headers['user-agent'] = @sdk_configuration.user_agent
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
base_url: base_url,
oauth2_scopes: nil,
operation_id: 'getServerPreferences',
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
r = T.let(nil, T.nilable(Faraday::Response))
begin
r = connection.get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if r.nil? || Utils.error_status?(r.status)
r = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
else
r = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
end
if r.nil?
raise error if !error.nil?
raise 'no response'
end
end
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
res = ::PlexRubySDK::Operations::GetServerPreferencesResponse.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 = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerPreferencesResponseBody)
res.object = out
end
elsif r.status == 400
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerPreferencesBadRequest)
res.bad_request = out
end
elsif r.status == 401
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerPreferencesUnauthorized)
res.unauthorized = out
end
end
res
end
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetAvailableClientsResponse) }
def get_available_clients(timeout_ms = nil)
# get_available_clients - Get Available Clients
# Get Available Clients
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/clients"
headers = {}
headers['Accept'] = 'application/json'
headers['user-agent'] = @sdk_configuration.user_agent
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
base_url: base_url,
oauth2_scopes: nil,
operation_id: 'getAvailableClients',
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
r = T.let(nil, T.nilable(Faraday::Response))
begin
r = connection.get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if r.nil? || Utils.error_status?(r.status)
r = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
else
r = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
end
if r.nil?
raise error if !error.nil?
raise 'no response'
end
end
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
res = ::PlexRubySDK::Operations::GetAvailableClientsResponse.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 = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetAvailableClientsResponseBody)
res.object = out
end
elsif r.status == 400
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetAvailableClientsBadRequest)
res.bad_request = out
end
elsif r.status == 401
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetAvailableClientsUnauthorized)
res.unauthorized = out
end
end
res
end
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetDevicesResponse) }
def get_devices(timeout_ms = nil)
# get_devices - Get Devices
# Get Devices
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/devices"
headers = {}
headers['Accept'] = 'application/json'
headers['user-agent'] = @sdk_configuration.user_agent
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
base_url: base_url,
oauth2_scopes: nil,
operation_id: 'getDevices',
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
r = T.let(nil, T.nilable(Faraday::Response))
begin
r = connection.get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if r.nil? || Utils.error_status?(r.status)
r = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
else
r = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
end
if r.nil?
raise error if !error.nil?
raise 'no response'
end
end
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
res = ::PlexRubySDK::Operations::GetDevicesResponse.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 = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetDevicesResponseBody)
res.object = out
end
elsif r.status == 400
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetDevicesBadRequest)
res.bad_request = out
end
elsif r.status == 401
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetDevicesUnauthorized)
res.unauthorized = out
end
end
res
end
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetServerIdentityResponse) }
def get_server_identity(timeout_ms = nil)
# get_server_identity - Get Server Identity
# This request is useful to determine if the server is online or offline
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/identity"
headers = {}
headers['Accept'] = 'application/json'
headers['user-agent'] = @sdk_configuration.user_agent
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
base_url: base_url,
oauth2_scopes: nil,
operation_id: 'get-server-identity',
security_source: nil
)
error = T.let(nil, T.nilable(StandardError))
r = T.let(nil, T.nilable(Faraday::Response))
begin
r = connection.get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if r.nil? || Utils.error_status?(r.status)
r = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
else
r = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
end
if r.nil?
raise error if !error.nil?
raise 'no response'
end
end
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
res = ::PlexRubySDK::Operations::GetServerIdentityResponse.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 = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerIdentityResponseBody)
res.object = out
end
elsif r.status == 408
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerIdentityRequestTimeout)
res.request_timeout = out
end
end
res
end
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetMyPlexAccountResponse) }
def get_my_plex_account(timeout_ms = nil)
# get_my_plex_account - Get MyPlex Account
# Returns MyPlex Account Information
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/myplex/account"
headers = {}
headers['Accept'] = 'application/json'
headers['user-agent'] = @sdk_configuration.user_agent
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
base_url: base_url,
oauth2_scopes: nil,
operation_id: 'getMyPlexAccount',
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
r = T.let(nil, T.nilable(Faraday::Response))
begin
r = connection.get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if r.nil? || Utils.error_status?(r.status)
r = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
else
r = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
end
if r.nil?
raise error if !error.nil?
raise 'no response'
end
end
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
res = ::PlexRubySDK::Operations::GetMyPlexAccountResponse.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 = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetMyPlexAccountResponseBody)
res.object = out
end
elsif r.status == 400
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetMyPlexAccountBadRequest)
res.bad_request = out
end
elsif r.status == 401
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetMyPlexAccountUnauthorized)
res.unauthorized = out
end
end
res
end
sig { params(request: T.nilable(::PlexRubySDK::Operations::GetResizedPhotoRequest), timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetResizedPhotoResponse) }
def get_resized_photo(request, timeout_ms = nil)
# get_resized_photo - Get a Resized Photo
# Plex's Photo transcoder is used throughout the service to serve images at specified sizes.
#
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/photo/:/transcode"
headers = {}
query_params = Utils.get_query_params(::PlexRubySDK::Operations::GetResizedPhotoRequest, request)
headers['Accept'] = 'application/json'
headers['user-agent'] = @sdk_configuration.user_agent
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
base_url: base_url,
oauth2_scopes: nil,
operation_id: 'getResizedPhoto',
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
r = T.let(nil, T.nilable(Faraday::Response))
begin
r = connection.get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
req.params = query_params
Utils.configure_request_security(req, security)
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if r.nil? || Utils.error_status?(r.status)
r = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
else
r = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
end
if r.nil?
raise error if !error.nil?
raise 'no response'
end
end
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
res = ::PlexRubySDK::Operations::GetResizedPhotoResponse.new(
status_code: r.status, content_type: content_type, raw_response: r
)
if r.status == 200
elsif r.status == 400
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetResizedPhotoBadRequest)
res.bad_request = out
end
elsif r.status == 401
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetResizedPhotoUnauthorized)
res.unauthorized = out
end
end
res
end
sig { params(x_plex_token: ::String, timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetMediaProvidersResponse) }
def get_media_providers(x_plex_token, timeout_ms = nil)
# get_media_providers - Get Media Providers
# Retrieves media providers and their features from the Plex server.
request = ::PlexRubySDK::Operations::GetMediaProvidersRequest.new(
x_plex_token: x_plex_token
)
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/media/providers"
headers = Utils.get_headers(request)
headers['Accept'] = 'application/json'
headers['user-agent'] = @sdk_configuration.user_agent
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
base_url: base_url,
oauth2_scopes: nil,
operation_id: 'get-media-providers',
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
r = T.let(nil, T.nilable(Faraday::Response))
begin
r = connection.get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if r.nil? || Utils.error_status?(r.status)
r = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
else
r = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
end
if r.nil?
raise error if !error.nil?
raise 'no response'
end
end
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
res = ::PlexRubySDK::Operations::GetMediaProvidersResponse.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 = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetMediaProvidersResponseBody)
res.object = out
end
elsif r.status == 400
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetMediaProvidersBadRequest)
res.bad_request = out
end
elsif r.status == 401
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetMediaProvidersUnauthorized)
res.unauthorized = out
end
end
res
end
sig { params(timeout_ms: T.nilable(Integer)).returns(::PlexRubySDK::Operations::GetServerListResponse) }
def get_server_list(timeout_ms = nil)
# get_server_list - Get Server List
# Get Server List
url, params = @sdk_configuration.get_server_details
base_url = Utils.template_url(url, params)
url = "#{base_url}/servers"
headers = {}
headers['Accept'] = 'application/json'
headers['user-agent'] = @sdk_configuration.user_agent
security = !@sdk_configuration.nil? && !@sdk_configuration.security_source.nil? ? @sdk_configuration.security_source.call : nil
timeout = (timeout_ms.to_f / 1000) unless timeout_ms.nil?
timeout ||= @sdk_configuration.timeout
connection = @sdk_configuration.client
hook_ctx = SDKHooks::HookContext.new(
base_url: base_url,
oauth2_scopes: nil,
operation_id: 'getServerList',
security_source: @sdk_configuration.security_source
)
error = T.let(nil, T.nilable(StandardError))
r = T.let(nil, T.nilable(Faraday::Response))
begin
r = connection.get(url) do |req|
req.headers.merge!(headers)
req.options.timeout = timeout unless timeout.nil?
Utils.configure_request_security(req, security)
@sdk_configuration.hooks.before_request(
hook_ctx: SDKHooks::BeforeRequestHookContext.new(
hook_ctx: hook_ctx
),
request: req
)
end
rescue StandardError => e
error = e
ensure
if r.nil? || Utils.error_status?(r.status)
r = @sdk_configuration.hooks.after_error(
error: error,
hook_ctx: SDKHooks::AfterErrorHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
else
r = @sdk_configuration.hooks.after_success(
hook_ctx: SDKHooks::AfterSuccessHookContext.new(
hook_ctx: hook_ctx
),
response: r
)
end
if r.nil?
raise error if !error.nil?
raise 'no response'
end
end
content_type = r.headers.fetch('Content-Type', 'application/octet-stream')
res = ::PlexRubySDK::Operations::GetServerListResponse.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 = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerListResponseBody)
res.object = out
end
elsif r.status == 400
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerListBadRequest)
res.bad_request = out
end
elsif r.status == 401
if Utils.match_content_type(content_type, 'application/json')
out = Crystalline.unmarshal_json(JSON.parse(r.env.response_body), ::PlexRubySDK::Operations::GetServerListUnauthorized)
res.unauthorized = out
end
end
res
end
end
end