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

More flexible parameter handling in NewRequest and friends #959

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions admin_opa_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (a *adminOPAVersions) Read(ctx context.Context, id string) (*AdminOPAVersio
return nil, ErrInvalidOPAVersionID
}

u := fmt.Sprintf("admin/opa-versions/%s", url.QueryEscape(id))
u := fmt.Sprintf("admin/opa-versions/%s", url.PathEscape(id))
req, err := a.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand Down Expand Up @@ -161,7 +161,7 @@ func (a *adminOPAVersions) Update(ctx context.Context, id string, options AdminO
return nil, ErrInvalidOPAVersionID
}

u := fmt.Sprintf("admin/opa-versions/%s", url.QueryEscape(id))
u := fmt.Sprintf("admin/opa-versions/%s", url.PathEscape(id))
req, err := a.client.NewRequest("PATCH", u, &options)
if err != nil {
return nil, err
Expand All @@ -182,7 +182,7 @@ func (a *adminOPAVersions) Delete(ctx context.Context, id string) error {
return ErrInvalidOPAVersionID
}

u := fmt.Sprintf("admin/opa-versions/%s", url.QueryEscape(id))
u := fmt.Sprintf("admin/opa-versions/%s", url.PathEscape(id))
req, err := a.client.NewRequest("DELETE", u, nil)
if err != nil {
return err
Expand Down
10 changes: 5 additions & 5 deletions admin_organization.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func (s *adminOrganizations) ListModuleConsumers(ctx context.Context, organizati
return nil, ErrInvalidOrg
}

u := fmt.Sprintf("admin/organizations/%s/relationships/module-consumers", url.QueryEscape(organization))
u := fmt.Sprintf("admin/organizations/%s/relationships/module-consumers", url.PathEscape(organization))

req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
Expand All @@ -158,7 +158,7 @@ func (s *adminOrganizations) Read(ctx context.Context, organization string) (*Ad
return nil, ErrInvalidOrg
}

u := fmt.Sprintf("admin/organizations/%s", url.QueryEscape(organization))
u := fmt.Sprintf("admin/organizations/%s", url.PathEscape(organization))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand All @@ -179,7 +179,7 @@ func (s *adminOrganizations) Update(ctx context.Context, organization string, op
return nil, ErrInvalidOrg
}

u := fmt.Sprintf("admin/organizations/%s", url.QueryEscape(organization))
u := fmt.Sprintf("admin/organizations/%s", url.PathEscape(organization))
req, err := s.client.NewRequest("PATCH", u, &options)
if err != nil {
return nil, err
Expand All @@ -200,7 +200,7 @@ func (s *adminOrganizations) UpdateModuleConsumers(ctx context.Context, organiza
return ErrInvalidOrg
}

u := fmt.Sprintf("admin/organizations/%s/relationships/module-consumers", url.QueryEscape(organization))
u := fmt.Sprintf("admin/organizations/%s/relationships/module-consumers", url.PathEscape(organization))

var organizations []*AdminOrganizationID
for _, id := range consumerOrganizationIDs {
Expand Down Expand Up @@ -229,7 +229,7 @@ func (s *adminOrganizations) Delete(ctx context.Context, organization string) er
return ErrInvalidOrg
}

u := fmt.Sprintf("admin/organizations/%s", url.QueryEscape(organization))
u := fmt.Sprintf("admin/organizations/%s", url.PathEscape(organization))
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion admin_run.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ func (s *adminRuns) ForceCancel(ctx context.Context, runID string, options Admin
return ErrInvalidRunID
}

u := fmt.Sprintf("admin/runs/%s/actions/force-cancel", url.QueryEscape(runID))
u := fmt.Sprintf("admin/runs/%s/actions/force-cancel", url.PathEscape(runID))
req, err := s.client.NewRequest("POST", u, &options)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions admin_sentinel_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (a *adminSentinelVersions) Read(ctx context.Context, id string) (*AdminSent
return nil, ErrInvalidSentinelVersionID
}

u := fmt.Sprintf("admin/sentinel-versions/%s", url.QueryEscape(id))
u := fmt.Sprintf("admin/sentinel-versions/%s", url.PathEscape(id))
req, err := a.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand Down Expand Up @@ -161,7 +161,7 @@ func (a *adminSentinelVersions) Update(ctx context.Context, id string, options A
return nil, ErrInvalidSentinelVersionID
}

u := fmt.Sprintf("admin/sentinel-versions/%s", url.QueryEscape(id))
u := fmt.Sprintf("admin/sentinel-versions/%s", url.PathEscape(id))
req, err := a.client.NewRequest("PATCH", u, &options)
if err != nil {
return nil, err
Expand All @@ -182,7 +182,7 @@ func (a *adminSentinelVersions) Delete(ctx context.Context, id string) error {
return ErrInvalidSentinelVersionID
}

u := fmt.Sprintf("admin/sentinel-versions/%s", url.QueryEscape(id))
u := fmt.Sprintf("admin/sentinel-versions/%s", url.PathEscape(id))
req, err := a.client.NewRequest("DELETE", u, nil)
if err != nil {
return err
Expand Down
6 changes: 3 additions & 3 deletions admin_terraform_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (a *adminTerraformVersions) Read(ctx context.Context, id string) (*AdminTer
return nil, ErrInvalidTerraformVersionID
}

u := fmt.Sprintf("admin/terraform-versions/%s", url.QueryEscape(id))
u := fmt.Sprintf("admin/terraform-versions/%s", url.PathEscape(id))
req, err := a.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand Down Expand Up @@ -163,7 +163,7 @@ func (a *adminTerraformVersions) Update(ctx context.Context, id string, options
return nil, ErrInvalidTerraformVersionID
}

u := fmt.Sprintf("admin/terraform-versions/%s", url.QueryEscape(id))
u := fmt.Sprintf("admin/terraform-versions/%s", url.PathEscape(id))
req, err := a.client.NewRequest("PATCH", u, &options)
if err != nil {
return nil, err
Expand All @@ -184,7 +184,7 @@ func (a *adminTerraformVersions) Delete(ctx context.Context, id string) error {
return ErrInvalidTerraformVersionID
}

u := fmt.Sprintf("admin/terraform-versions/%s", url.QueryEscape(id))
u := fmt.Sprintf("admin/terraform-versions/%s", url.PathEscape(id))
req, err := a.client.NewRequest("DELETE", u, nil)
if err != nil {
return err
Expand Down
12 changes: 6 additions & 6 deletions admin_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func (a *adminUsers) Delete(ctx context.Context, userID string) error {
return ErrInvalidUserValue
}

u := fmt.Sprintf("admin/users/%s", url.QueryEscape(userID))
u := fmt.Sprintf("admin/users/%s", url.PathEscape(userID))
req, err := a.client.NewRequest("DELETE", u, nil)
if err != nil {
return err
Expand All @@ -134,7 +134,7 @@ func (a *adminUsers) Suspend(ctx context.Context, userID string) (*AdminUser, er
return nil, ErrInvalidUserValue
}

u := fmt.Sprintf("admin/users/%s/actions/suspend", url.QueryEscape(userID))
u := fmt.Sprintf("admin/users/%s/actions/suspend", url.PathEscape(userID))
req, err := a.client.NewRequest("POST", u, nil)
if err != nil {
return nil, err
Expand All @@ -155,7 +155,7 @@ func (a *adminUsers) Unsuspend(ctx context.Context, userID string) (*AdminUser,
return nil, ErrInvalidUserValue
}

u := fmt.Sprintf("admin/users/%s/actions/unsuspend", url.QueryEscape(userID))
u := fmt.Sprintf("admin/users/%s/actions/unsuspend", url.PathEscape(userID))
req, err := a.client.NewRequest("POST", u, nil)
if err != nil {
return nil, err
Expand All @@ -176,7 +176,7 @@ func (a *adminUsers) GrantAdmin(ctx context.Context, userID string) (*AdminUser,
return nil, ErrInvalidUserValue
}

u := fmt.Sprintf("admin/users/%s/actions/grant_admin", url.QueryEscape(userID))
u := fmt.Sprintf("admin/users/%s/actions/grant_admin", url.PathEscape(userID))
req, err := a.client.NewRequest("POST", u, nil)
if err != nil {
return nil, err
Expand All @@ -197,7 +197,7 @@ func (a *adminUsers) RevokeAdmin(ctx context.Context, userID string) (*AdminUser
return nil, ErrInvalidUserValue
}

u := fmt.Sprintf("admin/users/%s/actions/revoke_admin", url.QueryEscape(userID))
u := fmt.Sprintf("admin/users/%s/actions/revoke_admin", url.PathEscape(userID))
req, err := a.client.NewRequest("POST", u, nil)
if err != nil {
return nil, err
Expand All @@ -219,7 +219,7 @@ func (a *adminUsers) Disable2FA(ctx context.Context, userID string) (*AdminUser,
return nil, ErrInvalidUserValue
}

u := fmt.Sprintf("admin/users/%s/actions/disable_two_factor", url.QueryEscape(userID))
u := fmt.Sprintf("admin/users/%s/actions/disable_two_factor", url.PathEscape(userID))
req, err := a.client.NewRequest("POST", u, nil)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions admin_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (s *adminWorkspaces) Read(ctx context.Context, workspaceID string) (*AdminW
return nil, ErrInvalidWorkspaceValue
}

u := fmt.Sprintf("admin/workspaces/%s", url.QueryEscape(workspaceID))
u := fmt.Sprintf("admin/workspaces/%s", url.PathEscape(workspaceID))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand All @@ -134,7 +134,7 @@ func (s *adminWorkspaces) Delete(ctx context.Context, workspaceID string) error
return ErrInvalidWorkspaceValue
}

u := fmt.Sprintf("admin/workspaces/%s", url.QueryEscape(workspaceID))
u := fmt.Sprintf("admin/workspaces/%s", url.PathEscape(workspaceID))
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *agents) Read(ctx context.Context, agentID string) (*Agent, error) {
return nil, ErrInvalidAgentID
}

u := fmt.Sprintf("agents/%s", url.QueryEscape(agentID))
u := fmt.Sprintf("agents/%s", url.PathEscape(agentID))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand All @@ -78,7 +78,7 @@ func (s *agents) List(ctx context.Context, agentPoolID string, options *AgentLis
return nil, ErrInvalidOrg
}

u := fmt.Sprintf("agent-pools/%s/agents", url.QueryEscape(agentPoolID))
u := fmt.Sprintf("agent-pools/%s/agents", url.PathEscape(agentPoolID))
req, err := s.client.NewRequest("GET", u, options)
if err != nil {
return nil, err
Expand Down
12 changes: 6 additions & 6 deletions agent_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func (s *agentPools) List(ctx context.Context, organization string, options *Age
return nil, err
}

u := fmt.Sprintf("organizations/%s/agent-pools", url.QueryEscape(organization))
u := fmt.Sprintf("organizations/%s/agent-pools", url.PathEscape(organization))
req, err := s.client.NewRequest("GET", u, options)
if err != nil {
return nil, err
Expand All @@ -139,7 +139,7 @@ func (s *agentPools) Create(ctx context.Context, organization string, options Ag
return nil, err
}

u := fmt.Sprintf("organizations/%s/agent-pools", url.QueryEscape(organization))
u := fmt.Sprintf("organizations/%s/agent-pools", url.PathEscape(organization))
req, err := s.client.NewRequest("POST", u, &options)
if err != nil {
return nil, err
Expand Down Expand Up @@ -168,7 +168,7 @@ func (s *agentPools) ReadWithOptions(ctx context.Context, agentpoolID string, op
return nil, err
}

u := fmt.Sprintf("agent-pools/%s", url.QueryEscape(agentpoolID))
u := fmt.Sprintf("agent-pools/%s", url.PathEscape(agentpoolID))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand Down Expand Up @@ -224,7 +224,7 @@ func (s *agentPools) Update(ctx context.Context, agentPoolID string, options Age
return nil, err
}

u := fmt.Sprintf("agent-pools/%s", url.QueryEscape(agentPoolID))
u := fmt.Sprintf("agent-pools/%s", url.PathEscape(agentPoolID))
req, err := s.client.NewRequest("PATCH", u, &options)
if err != nil {
return nil, err
Expand All @@ -244,7 +244,7 @@ func (s *agentPools) UpdateAllowedWorkspaces(ctx context.Context, agentPoolID st
return nil, ErrInvalidAgentPoolID
}

u := fmt.Sprintf("agent-pools/%s", url.QueryEscape(agentPoolID))
u := fmt.Sprintf("agent-pools/%s", url.PathEscape(agentPoolID))
req, err := s.client.NewRequest("PATCH", u, &options)
if err != nil {
return nil, err
Expand All @@ -265,7 +265,7 @@ func (s *agentPools) Delete(ctx context.Context, agentPoolID string) error {
return ErrInvalidAgentPoolID
}

u := fmt.Sprintf("agent-pools/%s", url.QueryEscape(agentPoolID))
u := fmt.Sprintf("agent-pools/%s", url.PathEscape(agentPoolID))
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions agent_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (s *agentTokens) List(ctx context.Context, agentPoolID string) (*AgentToken
return nil, ErrInvalidAgentPoolID
}

u := fmt.Sprintf("agent-pools/%s/authentication-tokens", url.QueryEscape(agentPoolID))
u := fmt.Sprintf("agent-pools/%s/authentication-tokens", url.PathEscape(agentPoolID))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand All @@ -95,7 +95,7 @@ func (s *agentTokens) Create(ctx context.Context, agentPoolID string, options Ag
return nil, ErrAgentTokenDescription
}

u := fmt.Sprintf("agent-pools/%s/authentication-tokens", url.QueryEscape(agentPoolID))
u := fmt.Sprintf("agent-pools/%s/authentication-tokens", url.PathEscape(agentPoolID))
req, err := s.client.NewRequest("POST", u, &options)
if err != nil {
return nil, err
Expand All @@ -116,7 +116,7 @@ func (s *agentTokens) Read(ctx context.Context, agentTokenID string) (*AgentToke
return nil, ErrInvalidAgentTokenID
}

u := fmt.Sprintf("authentication-tokens/%s", url.QueryEscape(agentTokenID))
u := fmt.Sprintf("authentication-tokens/%s", url.PathEscape(agentTokenID))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand All @@ -137,7 +137,7 @@ func (s *agentTokens) Delete(ctx context.Context, agentTokenID string) error {
return ErrInvalidAgentTokenID
}

u := fmt.Sprintf("authentication-tokens/%s", url.QueryEscape(agentTokenID))
u := fmt.Sprintf("authentication-tokens/%s", url.PathEscape(agentTokenID))
req, err := s.client.NewRequest("DELETE", u, nil)
if err != nil {
return err
Expand Down
2 changes: 1 addition & 1 deletion apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (s *applies) Read(ctx context.Context, applyID string) (*Apply, error) {
return nil, ErrInvalidApplyID
}

u := fmt.Sprintf("applies/%s", url.QueryEscape(applyID))
u := fmt.Sprintf("applies/%s", url.PathEscape(applyID))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand Down
6 changes: 3 additions & 3 deletions comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (s *comments) List(ctx context.Context, runID string) (*CommentList, error)
return nil, ErrInvalidRunID
}

u := fmt.Sprintf("runs/%s/comments", url.QueryEscape(runID))
u := fmt.Sprintf("runs/%s/comments", url.PathEscape(runID))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand All @@ -87,7 +87,7 @@ func (s *comments) Create(ctx context.Context, runID string, options CommentCrea
return nil, ErrInvalidRunID
}

u := fmt.Sprintf("runs/%s/comments", url.QueryEscape(runID))
u := fmt.Sprintf("runs/%s/comments", url.PathEscape(runID))
req, err := s.client.NewRequest("POST", u, &options)
if err != nil {
return nil, err
Expand All @@ -108,7 +108,7 @@ func (s *comments) Read(ctx context.Context, commentID string) (*Comment, error)
return nil, ErrInvalidCommentID
}

u := fmt.Sprintf("comments/%s", url.QueryEscape(commentID))
u := fmt.Sprintf("comments/%s", url.PathEscape(commentID))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand Down
10 changes: 5 additions & 5 deletions configuration_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func (s *configurationVersions) List(ctx context.Context, workspaceID string, op
return nil, err
}

u := fmt.Sprintf("workspaces/%s/configuration-versions", url.QueryEscape(workspaceID))
u := fmt.Sprintf("workspaces/%s/configuration-versions", url.PathEscape(workspaceID))
req, err := s.client.NewRequest("GET", u, options)
if err != nil {
return nil, err
Expand All @@ -236,7 +236,7 @@ func (s *configurationVersions) Create(ctx context.Context, workspaceID string,
return nil, ErrInvalidWorkspaceID
}

u := fmt.Sprintf("workspaces/%s/configuration-versions", url.QueryEscape(workspaceID))
u := fmt.Sprintf("workspaces/%s/configuration-versions", url.PathEscape(workspaceID))
req, err := s.client.NewRequest("POST", u, &options)
if err != nil {
return nil, err
Expand Down Expand Up @@ -285,7 +285,7 @@ func (s *configurationVersions) ReadWithOptions(ctx context.Context, cvID string
return nil, err
}

u := fmt.Sprintf("configuration-versions/%s", url.QueryEscape(cvID))
u := fmt.Sprintf("configuration-versions/%s", url.PathEscape(cvID))
req, err := s.client.NewRequest("GET", u, options)
if err != nil {
return nil, err
Expand Down Expand Up @@ -331,7 +331,7 @@ func (s *configurationVersions) Archive(ctx context.Context, cvID string) error

body := bytes.NewBuffer(nil)

u := fmt.Sprintf("configuration-versions/%s/actions/archive", url.QueryEscape(cvID))
u := fmt.Sprintf("configuration-versions/%s/actions/archive", url.PathEscape(cvID))
req, err := s.client.NewRequest("POST", u, body)
if err != nil {
return err
Expand All @@ -354,7 +354,7 @@ func (s *configurationVersions) Download(ctx context.Context, cvID string) ([]by
return nil, ErrInvalidConfigVersionID
}

u := fmt.Sprintf("configuration-versions/%s/download", url.QueryEscape(cvID))
u := fmt.Sprintf("configuration-versions/%s/download", url.PathEscape(cvID))
req, err := s.client.NewRequest("GET", u, nil)
if err != nil {
return nil, err
Expand Down
Loading
Loading