Debian Codegraph @

github/apps_manifest.go

raw
1 // Copyright 2019 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 // AppConfig describes the configuration of a GitHub App.
14 type AppConfig struct {
15 ID *int64 `json:"id,omitempty"`
16 Slug *string `json:"slug,omitempty"`
17 NodeID *string `json:"node_id,omitempty"`
18 Owner *User `json:"owner,omitempty"`
19 Name *string `json:"name,omitempty"`
20 Description *string `json:"description,omitempty"`
21 ExternalURL *string `json:"external_url,omitempty"`
22 HTMLURL *string `json:"html_url,omitempty"`
23 CreatedAt *Timestamp `json:"created_at,omitempty"`
24 UpdatedAt *Timestamp `json:"updated_at,omitempty"`
25 ClientID *string `json:"client_id,omitempty"`
26 ClientSecret *string `json:"client_secret,omitempty"`
27 WebhookSecret *string `json:"webhook_secret,omitempty"`
28 PEM *string `json:"pem,omitempty"`
29 }
30
31 // CompleteAppManifest completes the App manifest handshake flow for the given
32 // code.
33 //
34 // GitHub API docs: https://docs.github.com/rest/apps/apps#create-a-github-app-from-a-manifest
35 //
36 //meta:operation POST /app-manifests/{code}/conversions
37 func (s *AppsService) CompleteAppManifest(ctx context.Context, code string) (*AppConfig, *Response, error) {
38 u := fmt.Sprintf("app-manifests/%s/conversions", code)
39 req, err := s.client.NewRequest("POST", u, nil)
40 if err != nil {
41 return nil, nil, err
42 }
43
44 cfg := new(AppConfig)
45 resp, err := s.client.Do(ctx, req, cfg)
46 if err != nil {
47 return nil, resp, err
48 }
49
50 return cfg, resp, nil
51 }