Class: BitBucket::Repos::Keys
- Defined in:
- lib/bitbucket_rest_api/repos/keys.rb
Constant Summary collapse
- VALID_KEY_PARAM_NAMES =
%w[ label key ].freeze
Constants included from Validations
Constants included from Validations::Token
Validations::Token::TOKEN_REQUIRED, Validations::Token::TOKEN_REQUIRED_REGEXP
Constants included from BitBucket::Request
BitBucket::Request::METHODS, BitBucket::Request::METHODS_WITH_BODIES
Constants included from Connection
Constants included from Constants
Constants::ACCEPT, Constants::ACCEPT_CHARSET, Constants::CACHE_CONTROL, Constants::CONTENT_LENGTH, Constants::CONTENT_TYPE, Constants::DATE, Constants::ETAG, Constants::HEADER_LAST, Constants::HEADER_LINK, Constants::HEADER_NEXT, Constants::LOCATION, Constants::META_FIRST, Constants::META_LAST, Constants::META_NEXT, Constants::META_PREV, Constants::META_REL, Constants::PARAM_PAGE, Constants::PARAM_PER_PAGE, Constants::PARAM_START_PAGE, Constants::QUERY_STR_SEP, Constants::RATELIMIT_LIMIT, Constants::RATELIMIT_REMAINING, Constants::SERVER, Constants::USER_AGENT
Instance Method Summary collapse
-
#create(user_name, repo_name, params = {}) ⇒ Object
Create a key.
-
#delete(user_name, repo_name, key_id, params = {}) ⇒ Object
Delete key.
-
#edit(user_name, repo_name, key_id, params = {}) ⇒ Object
Edit a key.
-
#list(user_name, repo_name, params = {}) ⇒ Object
(also: #all)
List deploy keys.
Methods inherited from API
#_hash_traverse, #_merge_mime_type, #_merge_user_into_params!, #_merge_user_repo_into_params!, #_update_user_repo_params, #api_methods_in, #append_arguments, inherited, #initialize, #method_missing, #process_basic_auth, #set_api_client, #setup
Methods included from Normalizer
Methods included from ParameterFilter
Methods included from AutoloadHelper
#autoload_all, #lookup_constant, #register_constant
Methods included from Validations::Required
Methods included from Validations::Token
Methods included from Validations::Format
Methods included from Validations::Presence
#_validate_presence_of, #_validate_user_repo_params
Methods included from BitBucket::Request
#delete_request, #get_request, #patch_request, #post_request, #put_request, #request
Methods included from Connection
#caching?, #clear_cache, #connection, #default_middleware, #default_options, #stack
Methods included from Authorization
#authenticated?, #authentication, #basic_authed?
Constructor Details
This class inherits a constructor from BitBucket::API
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class BitBucket::API
Instance Method Details
#create(user_name, repo_name, params = {}) ⇒ Object
Create a key
Inputs
-
:title
- Required string. -
:key
- Required string.
Examples
bitbucket = BitBucket.new
bitbucket.repos.keys.create 'user-name', 'repo-name',
"label" => "octocat@octomac",
"key" => "ssh-rsa AAA..."
38 39 40 41 42 43 44 45 46 |
# File 'lib/bitbucket_rest_api/repos/keys.rb', line 38 def create(user_name, repo_name, params={}) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? normalize! params filter! VALID_KEY_PARAM_NAMES, params assert_required_keys(VALID_KEY_PARAM_NAMES, params) post_request("/1.0/repositories/#{user}/#{repo.downcase}/deploy-keys/", params) end |
#delete(user_name, repo_name, key_id, params = {}) ⇒ Object
Delete key
Examples
@bitbucket = BitBucket.new
@bitbucket.repos.keys.delete 'user-name', 'repo-name', 'key-id'
77 78 79 80 81 82 83 84 |
# File 'lib/bitbucket_rest_api/repos/keys.rb', line 77 def delete(user_name, repo_name, key_id, params={}) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? _validate_presence_of key_id normalize! params delete_request("/1.0/repositories/#{user}/#{repo.downcase}/deploy-keys/#{key_id}", params) end |
#edit(user_name, repo_name, key_id, params = {}) ⇒ Object
Edit a key
Inputs
-
:title
- Required string. -
:key
- Required string.
Examples
bitbucket = BitBucket.new
bitbucket.repos.keys.edit 'user-name', 'repo-name',
"label" => "octocat@octomac",
"key" => "ssh-rsa AAA..."
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/bitbucket_rest_api/repos/keys.rb', line 60 def edit(user_name, repo_name, key_id, params={}) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? _validate_presence_of key_id normalize! params filter! VALID_KEY_PARAM_NAMES, params put_request("/1.0/repositories/#{user}/#{repo.downcase}/deploy-keys/#{key_id}", params) end |
#list(user_name, repo_name, params = {}) ⇒ Object Also known as: all
List deploy keys
Examples
bitbucket = BitBucket.new
bitbucket.repos.keys.list 'user-name', 'repo-name'
bitbucket.repos.keys.list 'user-name', 'repo-name' { |key| ... }
15 16 17 18 19 20 21 22 23 |
# File 'lib/bitbucket_rest_api/repos/keys.rb', line 15 def list(user_name, repo_name, params={}) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? normalize! params response = get_request("/1.0/repositories/#{user}/#{repo.downcase}/deploy-keys/", params) return response unless block_given? response.each { |el| yield el } end |