Class: BitBucket::Repos::Webhooks
- Defined in:
- lib/bitbucket_rest_api/repos/webhooks.rb
Constant Summary collapse
- EVENTS =
[ 'repo:push', 'repo:fork', 'repo:commit_comment_created', 'repo:commit_status_created', 'repo:commit_status_updated', 'issue:created', 'issue:updated', 'issue:comment_created', 'pullrequest:created', 'pullrequest:updated', 'pullrequest:approved', 'pullrequest:unapproved', 'pullrequest:fulfilled', 'pullrequest:rejected', 'pullrequest:comment_created', 'pullrequest:comment_updated', 'pullrequest:comment_deleted' ].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
Instance Method Summary collapse
- #create(user_name, repo_name, params = {}) ⇒ Object
- #delete(user_name, repo_name, hook_uuid) ⇒ Object
- #edit(user_name, repo_name, hook_uuid, params = {}) ⇒ Object
- #get(user_name, repo_name, hook_uuid) ⇒ Object
- #list(user_name, repo_name) ⇒ Object
Methods inherited from API
#_merge_mime_type, #_merge_user_into_params!, #_merge_user_repo_into_params!, #_update_user_repo_params, #api_methods_in, inherited, #initialize, #method_missing, #process_basic_auth, #set_api_client, #setup, #update_and_validate_user_repo_params
Methods included from Normalizer
Methods included from ParameterFilter
Methods included from AutoloadHelper
#autoload_all, #lookup_constant, #register_constant
Methods included from Validations::Required
#assert_required_keys, #assert_required_values_present, #parse_values
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
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/bitbucket_rest_api/repos/webhooks.rb', line 24 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 assert_required_keys(%w[description url active events], params) _validate_given_events(params) assert_required_values_present( params, 'description', 'url', 'active', 'events' ) = { headers: { 'Content-Type' => 'application/json' } } post_request("/2.0/repositories/#{user_name}/#{repo_name}/hooks", params, ) end |
#delete(user_name, repo_name, hook_uuid) ⇒ Object
79 80 81 82 83 84 85 86 |
# File 'lib/bitbucket_rest_api/repos/webhooks.rb', line 79 def delete(user_name, repo_name, hook_uuid) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? delete_request( "/2.0/repositories/#{user_name}/#{repo_name}/hooks/#{hook_uuid}" ) end |
#edit(user_name, repo_name, hook_uuid, params = {}) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/bitbucket_rest_api/repos/webhooks.rb', line 58 def edit(user_name, repo_name, hook_uuid, params = {}) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? normalize! params assert_required_keys(%w[description url active events], params) _validate_given_events(params) assert_required_values_present( params, 'description', 'url', 'active', 'events' ) = { headers: { 'Content-Type' => 'application/json' } } put_request( "/2.0/repositories/#{user_name}/#{repo_name}/hooks/#{hook_uuid}", params, ) end |
#get(user_name, repo_name, hook_uuid) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/bitbucket_rest_api/repos/webhooks.rb', line 49 def get(user_name, repo_name, hook_uuid) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? get_request( "/2.0/repositories/#{user_name}/#{repo_name}/hooks/#{hook_uuid}" ) end |
#list(user_name, repo_name) ⇒ Object
42 43 44 45 46 47 |
# File 'lib/bitbucket_rest_api/repos/webhooks.rb', line 42 def list(user_name, repo_name) _update_user_repo_params(user_name, repo_name) _validate_user_repo_params(user, repo) unless user? && repo? get_request("/2.0/repositories/#{user_name}/#{repo_name}/hooks") end |