...

Source file src/github.com/google/go-github/v55/github/apps_hooks.go

Documentation: github.com/google/go-github/v55/github

     1  // Copyright 2021 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  )
    11  
    12  // GetHookConfig returns the webhook configuration for a GitHub App.
    13  // The underlying transport must be authenticated as an app.
    14  //
    15  // GitHub API docs: https://docs.github.com/en/rest/apps#get-a-webhook-configuration-for-an-app
    16  func (s *AppsService) GetHookConfig(ctx context.Context) (*HookConfig, *Response, error) {
    17  	req, err := s.client.NewRequest("GET", "app/hook/config", nil)
    18  	if err != nil {
    19  		return nil, nil, err
    20  	}
    21  
    22  	config := new(HookConfig)
    23  	resp, err := s.client.Do(ctx, req, &config)
    24  	if err != nil {
    25  		return nil, resp, err
    26  	}
    27  
    28  	return config, resp, nil
    29  }
    30  
    31  // UpdateHookConfig updates the webhook configuration for a GitHub App.
    32  // The underlying transport must be authenticated as an app.
    33  //
    34  // GitHub API docs: https://docs.github.com/en/rest/apps#update-a-webhook-configuration-for-an-app
    35  func (s *AppsService) UpdateHookConfig(ctx context.Context, config *HookConfig) (*HookConfig, *Response, error) {
    36  	req, err := s.client.NewRequest("PATCH", "app/hook/config", config)
    37  	if err != nil {
    38  		return nil, nil, err
    39  	}
    40  
    41  	c := new(HookConfig)
    42  	resp, err := s.client.Do(ctx, req, c)
    43  	if err != nil {
    44  		return nil, resp, err
    45  	}
    46  
    47  	return c, resp, nil
    48  }
    49  

View as plain text