Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: Update deprecated endpoints in github/action_variables.go #3104

Merged
merged 7 commits into from
Mar 28, 2024
10 changes: 5 additions & 5 deletions github/actions_secrets.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *ActionsService) GetOrgPublicKey(ctx context.Context, org string) (*Publ

// GetEnvPublicKey gets a public key that should be used for secret encryption.
//
// GitHub API docs: https://docs.github.com/rest/actions/secrets#get-an-environment-public-key
// GitHub API docs: https://docs.github.com/enterprise-server@3.7/rest/actions/secrets#get-an-environment-public-key
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/secrets/public-key
func (s *ActionsService) GetEnvPublicKey(ctx context.Context, repoID int, env string) (*PublicKey, *Response, error) {
Expand Down Expand Up @@ -162,7 +162,7 @@ func (s *ActionsService) ListOrgSecrets(ctx context.Context, org string, opts *L

// ListEnvSecrets lists all secrets available in an environment.
//
// GitHub API docs: https://docs.github.com/rest/actions/secrets#list-environment-secrets
// GitHub API docs: https://docs.github.com/enterprise-server@3.7/rest/actions/secrets#list-environment-secrets
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/secrets
func (s *ActionsService) ListEnvSecrets(ctx context.Context, repoID int, env string, opts *ListOptions) (*Secrets, *Response, error) {
Expand Down Expand Up @@ -207,7 +207,7 @@ func (s *ActionsService) GetOrgSecret(ctx context.Context, org, name string) (*S

// GetEnvSecret gets a single environment secret without revealing its encrypted value.
//
// GitHub API docs: https://docs.github.com/rest/actions/secrets#get-an-environment-secret
// GitHub API docs: https://docs.github.com/enterprise-server@3.7/rest/actions/secrets#get-an-environment-secret
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}
func (s *ActionsService) GetEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Secret, *Response, error) {
Expand Down Expand Up @@ -262,7 +262,7 @@ func (s *ActionsService) CreateOrUpdateOrgSecret(ctx context.Context, org string

// CreateOrUpdateEnvSecret creates or updates a single environment secret with an encrypted value.
//
// GitHub API docs: https://docs.github.com/rest/actions/secrets#create-or-update-an-environment-secret
// GitHub API docs: https://docs.github.com/enterprise-server@3.7/rest/actions/secrets#create-or-update-an-environment-secret
//
//meta:operation PUT /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}
func (s *ActionsService) CreateOrUpdateEnvSecret(ctx context.Context, repoID int, env string, eSecret *EncryptedSecret) (*Response, error) {
Expand Down Expand Up @@ -301,7 +301,7 @@ func (s *ActionsService) DeleteOrgSecret(ctx context.Context, org, name string)

// DeleteEnvSecret deletes a secret in an environment using the secret name.
//
// GitHub API docs: https://docs.github.com/rest/actions/secrets#delete-an-environment-secret
// GitHub API docs: https://docs.github.com/enterprise-server@3.7/rest/actions/secrets#delete-an-environment-secret
//
//meta:operation DELETE /repositories/{repository_id}/environments/{environment_name}/secrets/{secret_name}
func (s *ActionsService) DeleteEnvSecret(ctx context.Context, repoID int, env, secretName string) (*Response, error) {
Expand Down
30 changes: 15 additions & 15 deletions github/actions_variables.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ func (s *ActionsService) ListOrgVariables(ctx context.Context, org string, opts
//
// GitHub API docs: https://docs.github.com/rest/actions/variables#list-environment-variables
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/variables
func (s *ActionsService) ListEnvVariables(ctx context.Context, repoID int, env string, opts *ListOptions) (*ActionsVariables, *Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables", repoID, env)
//meta:operation GET /repos/{owner}/{repo}/environments/{environment_name}/variables
func (s *ActionsService) ListEnvVariables(ctx context.Context, owner, repo, env string, opts *ListOptions) (*ActionsVariables, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/environments/%v/variables", owner, repo, env)
return s.listVariables(ctx, url, opts)
}

Expand Down Expand Up @@ -128,9 +128,9 @@ func (s *ActionsService) GetOrgVariable(ctx context.Context, org, name string) (
//
// GitHub API docs: https://docs.github.com/rest/actions/variables#get-an-environment-variable
//
//meta:operation GET /repositories/{repository_id}/environments/{environment_name}/variables/{name}
func (s *ActionsService) GetEnvVariable(ctx context.Context, repoID int, env, variableName string) (*ActionsVariable, *Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables/%v", repoID, env, variableName)
//meta:operation GET /repos/{owner}/{repo}/environments/{environment_name}/variables/{name}
func (s *ActionsService) GetEnvVariable(ctx context.Context, owner, repo, env, variableName string) (*ActionsVariable, *Response, error) {
url := fmt.Sprintf("repos/%v/%v/environments/%v/variables/%v", owner, repo, env, variableName)
return s.getVariable(ctx, url)
}

Expand Down Expand Up @@ -166,9 +166,9 @@ func (s *ActionsService) CreateOrgVariable(ctx context.Context, org string, vari
//
// GitHub API docs: https://docs.github.com/rest/actions/variables#create-an-environment-variable
//
//meta:operation POST /repositories/{repository_id}/environments/{environment_name}/variables
func (s *ActionsService) CreateEnvVariable(ctx context.Context, repoID int, env string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables", repoID, env)
//meta:operation POST /repos/{owner}/{repo}/environments/{environment_name}/variables
func (s *ActionsService) CreateEnvVariable(ctx context.Context, owner, repo, env string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("repos/%v/%v/environments/%v/variables", owner, repo, env)
return s.postVariable(ctx, url, variable)
}

Expand Down Expand Up @@ -204,9 +204,9 @@ func (s *ActionsService) UpdateOrgVariable(ctx context.Context, org string, vari
//
// GitHub API docs: https://docs.github.com/rest/actions/variables#update-an-environment-variable
//
//meta:operation PATCH /repositories/{repository_id}/environments/{environment_name}/variables/{name}
func (s *ActionsService) UpdateEnvVariable(ctx context.Context, repoID int, env string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables/%v", repoID, env, variable.Name)
//meta:operation PATCH /repos/{owner}/{repo}/environments/{environment_name}/variables/{name}
func (s *ActionsService) UpdateEnvVariable(ctx context.Context, owner, repo, env string, variable *ActionsVariable) (*Response, error) {
url := fmt.Sprintf("repos/%v/%v/environments/%v/variables/%v", owner, repo, env, variable.Name)
return s.patchVariable(ctx, url, variable)
}

Expand Down Expand Up @@ -243,9 +243,9 @@ func (s *ActionsService) DeleteOrgVariable(ctx context.Context, org, name string
//
// GitHub API docs: https://docs.github.com/rest/actions/variables#delete-an-environment-variable
//
//meta:operation DELETE /repositories/{repository_id}/environments/{environment_name}/variables/{name}
func (s *ActionsService) DeleteEnvVariable(ctx context.Context, repoID int, env, variableName string) (*Response, error) {
url := fmt.Sprintf("repositories/%v/environments/%v/variables/%v", repoID, env, variableName)
//meta:operation DELETE /repos/{owner}/{repo}/environments/{environment_name}/variables/{name}
func (s *ActionsService) DeleteEnvVariable(ctx context.Context, owner, repo, env, variableName string) (*Response, error) {
url := fmt.Sprintf("repos/%v/%v/environments/%v/variables/%v", owner, repo, env, variableName)
return s.deleteVariable(ctx, url)
}

Expand Down
40 changes: 20 additions & 20 deletions github/actions_variables_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,15 +533,15 @@ func TestActionsService_ListEnvVariables(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repositories/1/environments/e/variables", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/usr/1/environments/e/variables", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
testFormValues(t, r, values{"per_page": "2", "page": "2"})
fmt.Fprint(w, `{"total_count":4,"variables":[{"name":"A","value":"AA","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"},{"name":"B","value":"BB","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}]}`)
})

opts := &ListOptions{Page: 2, PerPage: 2}
ctx := context.Background()
variables, _, err := client.Actions.ListEnvVariables(ctx, 1, "e", opts)
variables, _, err := client.Actions.ListEnvVariables(ctx, "usr", "1", "e", opts)
if err != nil {
t.Errorf("Actions.ListEnvVariables returned error: %v", err)
}
Expand All @@ -559,12 +559,12 @@ func TestActionsService_ListEnvVariables(t *testing.T) {

const methodName = "ListEnvVariables"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.ListEnvVariables(ctx, 0.0, "\n", opts)
_, _, err = client.Actions.ListEnvVariables(ctx, "usr", "0", "\n", opts)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Actions.ListEnvVariables(ctx, 1, "e", opts)
got, resp, err := client.Actions.ListEnvVariables(ctx, "usr", "1", "e", opts)
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
Expand All @@ -576,13 +576,13 @@ func TestActionsService_GetEnvVariable(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repositories/1/environments/e/variables/variable", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/usr/1/environments/e/variables/variable", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "GET")
fmt.Fprint(w, `{"name":"variable","value":"VAR","created_at":"2019-01-02T15:04:05Z","updated_at":"2020-01-02T15:04:05Z"}`)
})

ctx := context.Background()
variable, _, err := client.Actions.GetEnvVariable(ctx, 1, "e", "variable")
variable, _, err := client.Actions.GetEnvVariable(ctx, "usr", "1", "e", "variable")
if err != nil {
t.Errorf("Actions.GetEnvVariable returned error: %v", err)
}
Expand All @@ -599,12 +599,12 @@ func TestActionsService_GetEnvVariable(t *testing.T) {

const methodName = "GetEnvVariable"
testBadOptions(t, methodName, func() (err error) {
_, _, err = client.Actions.GetEnvVariable(ctx, 0.0, "\n", "\n")
_, _, err = client.Actions.GetEnvVariable(ctx, "usr", "0", "\n", "\n")
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
got, resp, err := client.Actions.GetEnvVariable(ctx, 1, "e", "variable")
got, resp, err := client.Actions.GetEnvVariable(ctx, "usr", "1", "e", "variable")
if got != nil {
t.Errorf("testNewRequestAndDoFailure %v = %#v, want nil", methodName, got)
}
Expand All @@ -616,7 +616,7 @@ func TestActionsService_CreateEnvVariable(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repositories/1/environments/e/variables", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/usr/1/environments/e/variables", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "POST")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{"name":"variable","value":"VAR"}`+"\n")
Expand All @@ -628,27 +628,27 @@ func TestActionsService_CreateEnvVariable(t *testing.T) {
Value: "VAR",
}
ctx := context.Background()
_, err := client.Actions.CreateEnvVariable(ctx, 1, "e", input)
_, err := client.Actions.CreateEnvVariable(ctx, "usr", "1", "e", input)
if err != nil {
t.Errorf("Actions.CreateEnvVariable returned error: %v", err)
}

const methodName = "CreateEnvVariable"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Actions.CreateEnvVariable(ctx, 0.0, "\n", input)
_, err = client.Actions.CreateEnvVariable(ctx, "usr", "0", "\n", input)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
return client.Actions.CreateEnvVariable(ctx, 1, "e", input)
return client.Actions.CreateEnvVariable(ctx, "usr", "1", "e", input)
})
}

func TestActionsService_UpdateEnvVariable(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repositories/1/environments/e/variables/variable", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/usr/1/environments/e/variables/variable", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "PATCH")
testHeader(t, r, "Content-Type", "application/json")
testBody(t, r, `{"name":"variable","value":"VAR"}`+"\n")
Expand All @@ -660,44 +660,44 @@ func TestActionsService_UpdateEnvVariable(t *testing.T) {
Value: "VAR",
}
ctx := context.Background()
_, err := client.Actions.UpdateEnvVariable(ctx, 1, "e", input)
_, err := client.Actions.UpdateEnvVariable(ctx, "usr", "1", "e", input)
if err != nil {
t.Errorf("Actions.UpdateEnvVariable returned error: %v", err)
}

const methodName = "UpdateEnvVariable"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Actions.UpdateEnvVariable(ctx, 0.0, "\n", input)
_, err = client.Actions.UpdateEnvVariable(ctx, "usr", "1", "\n", input)
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
return client.Actions.UpdateEnvVariable(ctx, 1, "e", input)
return client.Actions.UpdateEnvVariable(ctx, "usr", "1", "e", input)
})
}

func TestActionsService_DeleteEnvVariable(t *testing.T) {
client, mux, _, teardown := setup()
defer teardown()

mux.HandleFunc("/repositories/1/environments/e/variables/variable", func(w http.ResponseWriter, r *http.Request) {
mux.HandleFunc("/repos/usr/1/environments/e/variables/variable", func(w http.ResponseWriter, r *http.Request) {
testMethod(t, r, "DELETE")
})

ctx := context.Background()
_, err := client.Actions.DeleteEnvVariable(ctx, 1, "e", "variable")
_, err := client.Actions.DeleteEnvVariable(ctx, "usr", "1", "e", "variable")
if err != nil {
t.Errorf("Actions.DeleteEnvVariable returned error: %v", err)
}

const methodName = "DeleteEnvVariable"
testBadOptions(t, methodName, func() (err error) {
_, err = client.Actions.DeleteEnvVariable(ctx, 0.0, "\n", "\n")
_, err = client.Actions.DeleteEnvVariable(ctx, "usr", "0", "\n", "\n")
return err
})

testNewRequestAndDoFailure(t, methodName, client, func() (*Response, error) {
return client.Actions.DeleteEnvVariable(ctx, 1, "r", "variable")
return client.Actions.DeleteEnvVariable(ctx, "usr", "1", "r", "variable")
})
}

Expand Down
4 changes: 2 additions & 2 deletions github/admin.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ func (m Enterprise) String() string {

// UpdateUserLDAPMapping updates the mapping between a GitHub user and an LDAP user.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-user
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-user
//
//meta:operation PATCH /admin/ldap/users/{username}/mapping
func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, mapping *UserLDAPMapping) (*UserLDAPMapping, *Response, error) {
Expand All @@ -103,7 +103,7 @@ func (s *AdminService) UpdateUserLDAPMapping(ctx context.Context, user string, m

// UpdateTeamLDAPMapping updates the mapping between a GitHub team and an LDAP group.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-team
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/ldap#update-ldap-mapping-for-a-team
//
//meta:operation PATCH /admin/ldap/teams/{team_id}/mapping
func (s *AdminService) UpdateTeamLDAPMapping(ctx context.Context, team int64, mapping *TeamLDAPMapping) (*TeamLDAPMapping, *Response, error) {
Expand Down
6 changes: 3 additions & 3 deletions github/admin_orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type createOrgRequest struct {
// Note that only a subset of the org fields are used and org must
// not be nil.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/orgs#create-an-organization
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/orgs#create-an-organization
//
//meta:operation POST /admin/organizations
func (s *AdminService) CreateOrg(ctx context.Context, org *Organization, admin string) (*Organization, *Response, error) {
Expand Down Expand Up @@ -61,7 +61,7 @@ type RenameOrgResponse struct {

// RenameOrg renames an organization in GitHub Enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/orgs#update-an-organization-name
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/orgs#update-an-organization-name
//
//meta:operation PATCH /admin/organizations/{org}
func (s *AdminService) RenameOrg(ctx context.Context, org *Organization, newName string) (*RenameOrgResponse, *Response, error) {
Expand All @@ -70,7 +70,7 @@ func (s *AdminService) RenameOrg(ctx context.Context, org *Organization, newName

// RenameOrgByName renames an organization in GitHub Enterprise using its current name.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/orgs#update-an-organization-name
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/orgs#update-an-organization-name
//
//meta:operation PATCH /admin/organizations/{org}
func (s *AdminService) RenameOrgByName(ctx context.Context, org, newName string) (*RenameOrgResponse, *Response, error) {
Expand Down
2 changes: 1 addition & 1 deletion github/admin_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (s RepoStats) String() string {
// Please note that this is only available to site administrators,
// otherwise it will error with a 404 not found (instead of 401 or 403).
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/admin-stats#get-all-statistics
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/admin-stats#get-all-statistics
//
//meta:operation GET /enterprise/stats/all
func (s *AdminService) GetAdminStats(ctx context.Context) (*AdminStats, *Response, error) {
Expand Down
8 changes: 4 additions & 4 deletions github/admin_users.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type CreateUserRequest struct {

// CreateUser creates a new user in GitHub Enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/users#create-a-user
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#create-a-user
//
//meta:operation POST /admin/users
func (s *AdminService) CreateUser(ctx context.Context, userReq CreateUserRequest) (*User, *Response, error) {
Expand All @@ -42,7 +42,7 @@ func (s *AdminService) CreateUser(ctx context.Context, userReq CreateUserRequest

// DeleteUser deletes a user in GitHub Enterprise.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/users#delete-a-user
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#delete-a-user
//
//meta:operation DELETE /admin/users/{username}
func (s *AdminService) DeleteUser(ctx context.Context, username string) (*Response, error) {
Expand Down Expand Up @@ -95,7 +95,7 @@ type UserAuthorization struct {

// CreateUserImpersonation creates an impersonation OAuth token.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/users#create-an-impersonation-oauth-token
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#create-an-impersonation-oauth-token
//
//meta:operation POST /admin/users/{username}/authorizations
func (s *AdminService) CreateUserImpersonation(ctx context.Context, username string, opts *ImpersonateUserOptions) (*UserAuthorization, *Response, error) {
Expand All @@ -117,7 +117,7 @@ func (s *AdminService) CreateUserImpersonation(ctx context.Context, username str

// DeleteUserImpersonation deletes an impersonation OAuth token.
//
// GitHub API docs: https://docs.github.com/enterprise-server@3.11/rest/enterprise-admin/users#delete-an-impersonation-oauth-token
// GitHub API docs: https://docs.github.com/enterprise-server@3.12/rest/enterprise-admin/users#delete-an-impersonation-oauth-token
//
//meta:operation DELETE /admin/users/{username}/authorizations
func (s *AdminService) DeleteUserImpersonation(ctx context.Context, username string) (*Response, error) {
Expand Down
Loading
Loading