File: apps_hooks.go

package info (click to toggle)
golang-github-google-go-github 60.0.0-1
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 6,700 kB
  • sloc: sh: 111; makefile: 5
file content (52 lines) | stat: -rw-r--r-- 1,470 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2021 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"
)

// GetHookConfig returns the webhook configuration for a GitHub App.
// The underlying transport must be authenticated as an app.
//
// GitHub API docs: https://docs.github.com/rest/apps/webhooks#get-a-webhook-configuration-for-an-app
//
//meta:operation GET /app/hook/config
func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response, error) {
	req, err := s.client.NewRequest("GET", "app/hook/config", nil)
	if err != nil {
		return nil, nil, err
	}

	config := new(HookConfig)
	resp, err := s.client.Do(ctx, req, &config)
	if err != nil {
		return nil, resp, err
	}

	return config, resp, nil
}

// UpdateHookConfig updates the webhook configuration for a GitHub App.
// The underlying transport must be authenticated as an app.
//
// GitHub API docs: https://docs.github.com/rest/apps/webhooks#update-a-webhook-configuration-for-an-app
//
//meta:operation PATCH /app/hook/config
func (s *AppsService) UpdateHookConfig(ctx context.Context, config *HookConfig) (*HookConfig, *Response, error) {
	req, err := s.client.NewRequest("PATCH", "app/hook/config", config)
	if err != nil {
		return nil, nil, err
	}

	c := new(HookConfig)
	resp, err := s.client.Do(ctx, req, c)
	if err != nil {
		return nil, resp, err
	}

	return c, resp, nil
}