Files
go-github/github/orgs_hooks_configuration.go
Jam Balaya d669a4dba6 refactor!: Pass HookConfig by value and rename EditHookConfiguration to UpdateHookConfiguration (#4360)
BREAKING CHANGE: `EditHookConfiguration` is renamed to `UpdateHookConfiguration` on `RepositoriesService` and `OrganizationsService`; these methods and `AppsService.UpdateHookConfig` now take `HookConfig` by value.
2026-07-03 12:20:16 -04:00

54 lines
1.6 KiB
Go

// Copyright 2023 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"context"
"fmt"
)
// GetHookConfiguration returns the configuration for the specified organization webhook.
//
// GitHub API docs: https://docs.github.com/rest/orgs/webhooks?apiVersion=2022-11-28#get-a-webhook-configuration-for-an-organization
//
//meta:operation GET /orgs/{org}/hooks/{hook_id}/config
func (s *OrganizationsService) GetHookConfiguration(ctx context.Context, org string, id int64) (*HookConfig, *Response, error) {
u := fmt.Sprintf("orgs/%v/hooks/%v/config", org, id)
req, err := s.client.NewRequest(ctx, "GET", u, nil)
if err != nil {
return nil, nil, err
}
var config *HookConfig
resp, err := s.client.Do(req, &config)
if err != nil {
return nil, resp, err
}
return config, resp, nil
}
// UpdateHookConfiguration updates the configuration for the specified organization webhook.
//
// GitHub API docs: https://docs.github.com/rest/orgs/webhooks?apiVersion=2022-11-28#update-a-webhook-configuration-for-an-organization
//
//meta:operation PATCH /orgs/{org}/hooks/{hook_id}/config
func (s *OrganizationsService) UpdateHookConfiguration(ctx context.Context, org string, id int64, body HookConfig) (*HookConfig, *Response, error) {
u := fmt.Sprintf("orgs/%v/hooks/%v/config", org, id)
req, err := s.client.NewRequest(ctx, "PATCH", u, body)
if err != nil {
return nil, nil, err
}
var c *HookConfig
resp, err := s.client.Do(req, &c)
if err != nil {
return nil, resp, err
}
return c, resp, nil
}