...

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

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

     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/en/rest/orgs/webhooks?apiVersion=2022-11-28#get-a-webhook-configuration-for-an-organization
    16  func (s *OrganizationsService) GetHookConfiguration(ctx context.Context, org string, id int64) (*HookConfig, *Response, error) {
    17  	u := fmt.Sprintf("orgs/%v/hooks/%v/config", org, id)
    18  	req, err := s.client.NewRequest("GET", u, nil)
    19  	if err != nil {
    20  		return nil, nil, err
    21  	}
    22  
    23  	config := new(HookConfig)
    24  	resp, err := s.client.Do(ctx, req, config)
    25  	if err != nil {
    26  		return nil, resp, err
    27  	}
    28  
    29  	return config, resp, nil
    30  }
    31  
    32  // EditHookConfiguration updates the configuration for the specified organization webhook.
    33  //
    34  // GitHub API docs: https://docs.github.com/en/rest/orgs/webhooks?apiVersion=2022-11-28#update-a-webhook-configuration-for-an-organization
    35  func (s *OrganizationsService) EditHookConfiguration(ctx context.Context, org string, id int64, config *HookConfig) (*HookConfig, *Response, error) {
    36  	u := fmt.Sprintf("orgs/%v/hooks/%v/config", org, id)
    37  	req, err := s.client.NewRequest("PATCH", u, config)
    38  	if err != nil {
    39  		return nil, nil, err
    40  	}
    41  
    42  	c := new(HookConfig)
    43  	resp, err := s.client.Do(ctx, req, c)
    44  	if err != nil {
    45  		return nil, resp, err
    46  	}
    47  
    48  	return c, resp, nil
    49  }
    50  

View as plain text