class Github::Client::Repos::Releases::Assets
Public Instance Methods
delete(*args)
click to toggle source
Delete a release asset
@example
github = Github.new github.repos.releases.assets.delete 'owner', 'repo', 'id'
@api public
# File lib/github_api/client/repos/releases/assets.rb, line 127 def delete(*args) arguments(args, required: [:owner, :repo, :id]) delete_request("/repos/#{arguments.owner}/#{arguments.repo}/releases/assets/#{arguments.id}", arguments.params) end
edit(*args)
click to toggle source
Edit a release asset
Users with push access to the repository can edit a release asset.
@param [Hash] params @input params [String] :name
Required. The file name of the asset.
@input params [String] :label
An alternate short description of the asset. Used in place of the filename.
@example
github = Github.new github.repos.releases.assets.edit 'owner', 'repo', 'id', name: "foo-1.0.0-osx.zip", label: "Mac binary"
@api public
# File lib/github_api/client/repos/releases/assets.rb, line 111 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
Also aliased as: update
get(*args)
click to toggle source
Get a single release asset
@example
github = Github.new github.repos.releases.assets.get 'owner', 'repo', 'id'
@api public
# File lib/github_api/client/repos/releases/assets.rb, line 36 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
Also aliased as: find
infer_media(filepath)
click to toggle source
Infer media type of the asset
# File lib/github_api/client/repos/releases/assets.rb, line 85 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
list(*args) { |el| ... }
click to toggle source
List assets for a release
@example
github = Github.new github.repos.releases.assets.list 'owner', 'repo', 'id' github.repos.releases.assets.list 'owner', 'repo', 'id' { |asset| ... }
@api public
# File lib/github_api/client/repos/releases/assets.rb, line 20 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
Also aliased as: all
upload(*args)
click to toggle source
Upload a release asset
@param [Hash] params @input params [String] :name
Required string. The file name of the asset
@input params [String] :content_type
Required string. The content type of the asset. Example: “application/zip”.
@example
github = Github.new github.repos.releases.assets.upload 'owner', 'repo', 'id', 'file-path' name: "batman.jpg", content_type: "application/octet-stream"
@api public
# File lib/github_api/client/repos/releases/assets.rb, line 59 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: upload_endpoint, 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