class Github::Client::Repos::Releases::Assets

The Release Assets API

def delete(*args)

Other tags:
    Api: - public
def delete(*args)
  arguments(args, required: [:owner, :repo, :id])
  delete_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}", arguments.params)
end

def edit(*args)

Other tags:
    Api: - public

Parameters:
  • params (Hash) --
def edit(*args)
  arguments(args, required: [:owner, :repo, :id]) do
    permit VALID_ASSET_PARAM_NAMES
  end
  patch_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}", arguments.params)
end

def get(*args)

Other tags:
    Api: - public
def get(*args)
  params = arguments(args, required: [:owner, :repo, :id]).params
  get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}" , arguments.params)
end

def infer_media(filepath)


Infer media type of the asset
def infer_media(filepath)
  require 'mime/types'
  types = MIME::Types.type_for(filepath)
  types.empty? ? 'application/octet-stream' : types.first
rescue LoadError
  raise Github::Error::UnknownMedia.new(filepath)
end

def list(*args)

Other tags:
    Api: - public
def list(*args)
  arguments(args, required: [:owner, :repo, :id]).params
  response = get_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}/assets", arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end

def upload(*args)

Other tags:
    Api: - public

Parameters:
  • params (Hash) --
def upload(*args)
  arguments(args, required: [:owner, :repo, :id, :filepath]) do
    permit VALID_ASSET_PARAM_NAMES
  end
  params = arguments.params
  unless type = params['content_type']
    type = infer_media(arguments.filepath)
  end
  file = Faraday::UploadIO.new(arguments.filepath, type)
  options = {
    headers: { content_type: type },
    endpoint: 'https://uploads.github.com',
    query: {'name' => params['name']}
  }
  params['data']    = file.read
  params['options'] = options
  post_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/#{arguments.id}/assets", params)
ensure
  file.close if file
end