...
1
2
3
4
5
6 package github
7
8 import (
9 "context"
10 "fmt"
11 "net/http"
12 )
13
14
15 type CredentialAuthorization struct {
16
17 Login *string `json:"login,omitempty"`
18
19
20 CredentialID *int64 `json:"credential_id,omitempty"`
21
22
23 CredentialType *string `json:"credential_type,omitempty"`
24
25
26
27 TokenLastEight *string `json:"token_last_eight,omitempty"`
28
29
30 CredentialAuthorizedAt *Timestamp `json:"credential_authorized_at,omitempty"`
31
32
33
34 CredentialAccessedAt *Timestamp `json:"credential_accessed_at,omitempty"`
35
36
37 Scopes []string `json:"scopes,omitempty"`
38
39
40
41 Fingerprint *string `json:"fingerprint,omitempty"`
42
43 AuthorizedCredentialID *int64 `json:"authorized_credential_id,omitempty"`
44
45
46
47 AuthorizedCredentialTitle *string `json:"authorized_credential_title,omitempty"`
48
49
50
51 AuthorizedCredentialNote *string `json:"authorized_credential_note,omitempty"`
52
53
54
55 AuthorizedCredentialExpiresAt *Timestamp `json:"authorized_credential_expires_at,omitempty"`
56 }
57
58
59
60
61
62 func (s *OrganizationsService) ListCredentialAuthorizations(ctx context.Context, org string, opts *ListOptions) ([]*CredentialAuthorization, *Response, error) {
63 u := fmt.Sprintf("orgs/%v/credential-authorizations", org)
64 u, err := addOptions(u, opts)
65 if err != nil {
66 return nil, nil, err
67 }
68
69 req, err := s.client.NewRequest(http.MethodGet, u, nil)
70 if err != nil {
71 return nil, nil, err
72 }
73
74 var creds []*CredentialAuthorization
75 resp, err := s.client.Do(ctx, req, &creds)
76 if err != nil {
77 return nil, resp, err
78 }
79
80 return creds, resp, nil
81 }
82
83
84
85
86
87 func (s *OrganizationsService) RemoveCredentialAuthorization(ctx context.Context, org string, credentialID int64) (*Response, error) {
88 u := fmt.Sprintf("orgs/%v/credential-authorizations/%v", org, credentialID)
89 req, err := s.client.NewRequest(http.MethodDelete, u, nil)
90 if err != nil {
91 return nil, err
92 }
93
94 return s.client.Do(ctx, req, nil)
95 }
96
View as plain text