github.com/google/go-github/v70@v70.0.0/github/orgs_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 organization webhook. 14 // 15 // GitHub API docs: https://docs.github.com/rest/orgs/webhooks#get-a-webhook-configuration-for-an-organization 16 // 17 //meta:operation GET /orgs/{org}/hooks/{hook_id}/config 18 func (s *OrganizationsService) GetHookConfiguration(ctx context.Context, org string, id int64) (*HookConfig, *Response, error) { 19 u := fmt.Sprintf("orgs/%v/hooks/%v/config", org, 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 organization webhook. 35 // 36 // GitHub API docs: https://docs.github.com/rest/orgs/webhooks#update-a-webhook-configuration-for-an-organization 37 // 38 //meta:operation PATCH /orgs/{org}/hooks/{hook_id}/config 39 func (s *OrganizationsService) EditHookConfiguration(ctx context.Context, org string, id int64, config *HookConfig) (*HookConfig, *Response, error) { 40 u := fmt.Sprintf("orgs/%v/hooks/%v/config", org, 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 }