Repository navigation
Expand file tree
/
Copy pathactions_oidc.go
More file actions
201 lines (172 loc) · 9.36 KB
/
Copy pathactions_oidc.go
File metadata and controls
201 lines (172 loc) · 9.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
// Copyright 2023 The go-github AUTHORS. All rights reserved.
//
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package github
import (
"context"
"fmt"
)
// OIDCSubjectClaimCustomTemplate represents an OIDC subject claim customization template.
type OIDCSubjectClaimCustomTemplate struct {
UseDefault *bool `json:"use_default,omitempty"`
IncludeClaimKeys []string `json:"include_claim_keys,omitempty"`
UseImmutableSubject *bool `json:"use_immutable_subject,omitempty"`
SubClaimPrefix *string `json:"sub_claim_prefix,omitempty"`
}
// GetOrgOIDCSubjectClaimCustomTemplate gets the subject claim customization template for an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#get-the-customization-template-for-an-oidc-subject-claim-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/oidc/customization/sub
func (s *ActionsService) GetOrgOIDCSubjectClaimCustomTemplate(ctx context.Context, org string) (*OIDCSubjectClaimCustomTemplate, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/oidc/customization/sub", org)
return s.getOIDCSubjectClaimCustomTemplate(ctx, u)
}
// GetRepoOIDCSubjectClaimCustomTemplate gets the subject claim customization template for a repository.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#get-the-customization-template-for-an-oidc-subject-claim-for-a-repository
//
//meta:operation GET /repos/{owner}/{repo}/actions/oidc/customization/sub
func (s *ActionsService) GetRepoOIDCSubjectClaimCustomTemplate(ctx context.Context, owner, repo string) (*OIDCSubjectClaimCustomTemplate, *Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/oidc/customization/sub", owner, repo)
return s.getOIDCSubjectClaimCustomTemplate(ctx, u)
}
func (s *ActionsService) getOIDCSubjectClaimCustomTemplate(ctx context.Context, url string) (*OIDCSubjectClaimCustomTemplate, *Response, error) {
req, err := s.client.NewRequest(ctx, "GET", url, nil)
if err != nil {
return nil, nil, err
}
var tmpl *OIDCSubjectClaimCustomTemplate
resp, err := s.client.Do(req, &tmpl)
if err != nil {
return nil, resp, err
}
return tmpl, resp, nil
}
// SetOrgOIDCSubjectClaimCustomTemplate sets the subject claim customization for an organization.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#set-the-customization-template-for-an-oidc-subject-claim-for-an-organization
//
//meta:operation PUT /orgs/{org}/actions/oidc/customization/sub
func (s *ActionsService) SetOrgOIDCSubjectClaimCustomTemplate(ctx context.Context, org string, body OIDCSubjectClaimCustomTemplate) (*Response, error) {
u := fmt.Sprintf("orgs/%v/actions/oidc/customization/sub", org)
return s.setOIDCSubjectClaimCustomTemplate(ctx, u, body)
}
// SetRepoOIDCSubjectClaimCustomTemplate sets the subject claim customization for a repository.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#set-the-customization-template-for-an-oidc-subject-claim-for-a-repository
//
//meta:operation PUT /repos/{owner}/{repo}/actions/oidc/customization/sub
func (s *ActionsService) SetRepoOIDCSubjectClaimCustomTemplate(ctx context.Context, owner, repo string, body OIDCSubjectClaimCustomTemplate) (*Response, error) {
u := fmt.Sprintf("repos/%v/%v/actions/oidc/customization/sub", owner, repo)
return s.setOIDCSubjectClaimCustomTemplate(ctx, u, body)
}
func (s *ActionsService) setOIDCSubjectClaimCustomTemplate(ctx context.Context, url string, body OIDCSubjectClaimCustomTemplate) (*Response, error) {
req, err := s.client.NewRequest(ctx, "PUT", url, body)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}
// InclusionSource represents whether the custom oidc property claim was defined at the organization or enterprise level.
type InclusionSource string
// InclusionSource constants represent whether the inclusion was defined at the organization or enterprise level.
const (
InclusionSourceEnterprise InclusionSource = "enterprise"
InclusionSourceOrganization InclusionSource = "organization"
)
// OIDCCustomPropertyClaim represents an OIDC custom property claim for GitHub Actions.
type OIDCCustomPropertyClaim struct {
CustomPropertyName string `json:"custom_property_name"`
}
// OIDCCustomPropertyClaimResponse represents the OIDC custom property claim along with the inclusion source (enterprise or organization) for GitHub Actions.
type OIDCCustomPropertyClaimResponse struct {
OIDCCustomPropertyClaim
InclusionSource InclusionSource `json:"inclusion_source"`
}
// ListEnterpriseOIDCCustomPropertyClaims lists the custom property claims in oidc for enterprise actions.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#list-oidc-custom-property-inclusions-for-an-enterprise
//
//meta:operation GET /enterprises/{enterprise}/actions/oidc/customization/properties/repo
func (s *ActionsService) ListEnterpriseOIDCCustomPropertyClaims(ctx context.Context, enterprise string) ([]*OIDCCustomPropertyClaimResponse, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/oidc/customization/properties/repo", enterprise)
return s.listOIDCCustomPropertyClaims(ctx, u)
}
// ListOrgOIDCCustomPropertyClaims lists the custom property claims in oidc for organization actions.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#list-oidc-custom-property-inclusions-for-an-organization
//
//meta:operation GET /orgs/{org}/actions/oidc/customization/properties/repo
func (s *ActionsService) ListOrgOIDCCustomPropertyClaims(ctx context.Context, org string) ([]*OIDCCustomPropertyClaimResponse, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/oidc/customization/properties/repo", org)
return s.listOIDCCustomPropertyClaims(ctx, u)
}
func (s *ActionsService) listOIDCCustomPropertyClaims(ctx context.Context, url string) ([]*OIDCCustomPropertyClaimResponse, *Response, error) {
req, err := s.client.NewRequest(ctx, "GET", url, nil)
if err != nil {
return nil, nil, err
}
var props []*OIDCCustomPropertyClaimResponse
resp, err := s.client.Do(req, &props)
if err != nil {
return nil, resp, err
}
return props, resp, nil
}
// SetEnterpriseOIDCCustomPropertyClaim sets a new custom property claim in oidc for enterprise actions.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#create-an-oidc-custom-property-inclusion-for-an-enterprise
//
//meta:operation POST /enterprises/{enterprise}/actions/oidc/customization/properties/repo
func (s *ActionsService) SetEnterpriseOIDCCustomPropertyClaim(ctx context.Context, enterprise string, body OIDCCustomPropertyClaim) (*OIDCCustomPropertyClaim, *Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/oidc/customization/properties/repo", enterprise)
return s.setOIDCCustomPropertyClaim(ctx, u, body)
}
// SetOrgOIDCCustomPropertyClaim sets a new custom property claim in oidc for organization actions.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#create-an-oidc-custom-property-inclusion-for-an-organization
//
//meta:operation POST /orgs/{org}/actions/oidc/customization/properties/repo
func (s *ActionsService) SetOrgOIDCCustomPropertyClaim(ctx context.Context, org string, body OIDCCustomPropertyClaim) (*OIDCCustomPropertyClaim, *Response, error) {
u := fmt.Sprintf("orgs/%v/actions/oidc/customization/properties/repo", org)
return s.setOIDCCustomPropertyClaim(ctx, u, body)
}
func (s *ActionsService) setOIDCCustomPropertyClaim(ctx context.Context, url string, body OIDCCustomPropertyClaim) (*OIDCCustomPropertyClaim, *Response, error) {
req, err := s.client.NewRequest(ctx, "POST", url, body)
if err != nil {
return nil, nil, err
}
var customProperty *OIDCCustomPropertyClaim
resp, err := s.client.Do(req, &customProperty)
if err != nil {
return nil, resp, err
}
return customProperty, resp, err
}
// DeleteEnterpriseOIDCCustomPropertyClaim deletes a custom property claim in oidc for enterprise actions.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#delete-an-oidc-custom-property-inclusion-for-an-enterprise
//
//meta:operation DELETE /enterprises/{enterprise}/actions/oidc/customization/properties/repo/{custom_property_name}
func (s *ActionsService) DeleteEnterpriseOIDCCustomPropertyClaim(ctx context.Context, enterprise, customProperty string) (*Response, error) {
u := fmt.Sprintf("enterprises/%v/actions/oidc/customization/properties/repo/%v", enterprise, customProperty)
return s.deleteOIDCCustomPropertyClaim(ctx, u)
}
// DeleteOrgOIDCCustomPropertyClaim deletes a custom property claim in oidc for organization actions.
//
// GitHub API docs: https://docs.github.com/rest/actions/oidc?apiVersion=2022-11-28#delete-an-oidc-custom-property-inclusion-for-an-organization
//
//meta:operation DELETE /orgs/{org}/actions/oidc/customization/properties/repo/{custom_property_name}
func (s *ActionsService) DeleteOrgOIDCCustomPropertyClaim(ctx context.Context, enterprise, customProperty string) (*Response, error) {
u := fmt.Sprintf("orgs/%v/actions/oidc/customization/properties/repo/%v", enterprise, customProperty)
return s.deleteOIDCCustomPropertyClaim(ctx, u)
}
func (s *ActionsService) deleteOIDCCustomPropertyClaim(ctx context.Context, url string) (*Response, error) {
req, err := s.client.NewRequest(ctx, "DELETE", url, nil)
if err != nil {
return nil, err
}
return s.client.Do(req, nil)
}