# 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 Metadata 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 { params(request: Operations::DeleteVersionMetadataRequest).returns(Utils::FieldAugmented) } def delete_version_metadata(request) # delete_version_metadata - Delete metadata for a particular apiID and versionID. base_url = @server_url url = Utils.generate_url( Operations::DeleteVersionMetadataRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/metadata/{metaKey}/{metaValue}', request ) headers = {} headers['Accept'] = 'application/json' headers['user-agent'] = "speakeasy-sdk/#{@language} #{@sdk_version} #{@gen_version} #{@openapi_doc_version}" r = @client.delete(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::DeleteVersionMetadataResponse.new( status_code: r.status, content_type: content_type, raw_response: r ) if r.status == 200 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::GetVersionMetadataRequest).returns(Utils::FieldAugmented) } def get_version_metadata(request) # get_version_metadata - Get all metadata for a particular apiID and versionID. base_url = @server_url url = Utils.generate_url( Operations::GetVersionMetadataRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/metadata', request ) 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::GetVersionMetadataResponse.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::VersionMetadata]) res.version_metadata = 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::InsertVersionMetadataRequest).returns(Utils::FieldAugmented) } def insert_version_metadata(request) # insert_version_metadata - Insert metadata for a particular apiID and versionID. base_url = @server_url url = Utils.generate_url( Operations::InsertVersionMetadataRequest, base_url, '/v1/apis/{apiID}/version/{versionID}/metadata', request ) headers = {} req_content_type, data, form = Utils.serialize_request_body(request, :version_metadata_input, :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.post(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::InsertVersionMetadataResponse.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::VersionMetadata) res.version_metadata = 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