github.com/google/go-github/v57@v57.0.0/github/repos_hooks_configuration.go (about) 1 // Copyright 2023 The go-github AUTHORS. All rights reserved. 2 // 3 // Use of this source code is governed by a BSD-style 4 // license that can be found in the LICENSE file. 5 6 package github 7 8 import ( 9 "context" 10 "fmt" 11 ) 12 13 // GetHookConfiguration returns the configuration for the specified repository webhook. 14 // 15 // GitHub API docs: https://docs.github.com/rest/webhooks/repo-config#get-a-webhook-configuration-for-a-repository 16 // 17 //meta:operation GET /repos/{owner}/{repo}/hooks/{hook_id}/config 18 func (s *RepositoriesService) GetHookConfiguration(ctx context.Context, owner, repo string, id int64) (*HookConfig, *Response, error) { 19 u := fmt.Sprintf("repos/%v/%v/hooks/%v/config", owner, repo, id) 20 req, err := s.client.NewRequest("GET", u, nil) 21 if err != nil { 22 return nil, nil, err 23 } 24 25 config := new(HookConfig) 26 resp, err := s.client.Do(ctx, req, config) 27 if err != nil { 28 return nil, resp, err 29 } 30 31 return config, resp, nil 32 } 33 34 // EditHookConfiguration updates the configuration for the specified repository webhook. 35 // 36 // GitHub API docs: https://docs.github.com/rest/webhooks/repo-config#update-a-webhook-configuration-for-a-repository 37 // 38 //meta:operation PATCH /repos/{owner}/{repo}/hooks/{hook_id}/config 39 func (s *RepositoriesService) EditHookConfiguration(ctx context.Context, owner, repo string, id int64, config *HookConfig) (*HookConfig, *Response, error) { 40 u := fmt.Sprintf("repos/%v/%v/hooks/%v/config", owner, repo, id) 41 req, err := s.client.NewRequest("PATCH", u, config) 42 if err != nil { 43 return nil, nil, err 44 } 45 46 c := new(HookConfig) 47 resp, err := s.client.Do(ctx, req, c) 48 if err != nil { 49 return nil, resp, err 50 } 51 52 return c, resp, nil 53 }