Debian Codegraph @

github/orgs_personal_access_tokens.go

raw
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 "net/http"
12 )
13
14 // ReviewPersonalAccessTokenRequestOptions specifies the parameters to the ReviewPersonalAccessTokenRequest method.
15 type ReviewPersonalAccessTokenRequestOptions struct {
16 Action string `json:"action"`
17 Reason *string `json:"reason,omitempty"`
18 }
19
20 // ReviewPersonalAccessTokenRequest approves or denies a pending request to access organization resources via a fine-grained personal access token.
21 // Only GitHub Apps can call this API, using the `organization_personal_access_token_requests: write` permission.
22 // `action` can be one of `approve` or `deny`.
23 //
24 // GitHub API docs: https://docs.github.com/rest/orgs/personal-access-tokens#review-a-request-to-access-organization-resources-with-a-fine-grained-personal-access-token
25 //
26 //meta:operation POST /orgs/{org}/personal-access-token-requests/{pat_request_id}
27 func (s *OrganizationsService) ReviewPersonalAccessTokenRequest(ctx context.Context, org string, requestID int64, opts ReviewPersonalAccessTokenRequestOptions) (*Response, error) {
28 u := fmt.Sprintf("orgs/%v/personal-access-token-requests/%v", org, requestID)
29
30 req, err := s.client.NewRequest(http.MethodPost, u, &opts)
31 if err != nil {
32 return nil, err
33 }
34
35 return s.client.Do(ctx, req, nil)
36 }