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

Change create/update options in resources to match JSON:API Type field #190

Merged
merged 2 commits into from Mar 11, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 10 additions & 10 deletions agent_pool.go
Expand Up @@ -78,8 +78,11 @@ func (s *agentPools) List(ctx context.Context, organization string, options Agen

// AgentPoolCreateOptions represents the options for creating an agent pool.
type AgentPoolCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,agent-pools"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,agent-pools"`

// A name to identify the agent pool.
Name *string `jsonapi:"attr,name"`
Expand All @@ -105,9 +108,6 @@ func (s *agentPools) Create(ctx context.Context, organization string, options Ag
return nil, err
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("organizations/%s/agent-pools", url.QueryEscape(organization))
req, err := s.client.newRequest("POST", u, &options)
if err != nil {
Expand Down Expand Up @@ -146,8 +146,11 @@ func (s *agentPools) Read(ctx context.Context, agentpoolID string) (*AgentPool,

// AgentPoolUpdateOptions represents the options for updating an agent pool.
type AgentPoolUpdateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,agent-pools"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,agent-pools"`

// A new name to identify the agent pool.
Name *string `jsonapi:"attr,name"`
Expand All @@ -170,9 +173,6 @@ func (s *agentPools) Update(ctx context.Context, agentPoolID string, options Age
return nil, err
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("agent-pools/%s", url.QueryEscape(agentPoolID))
req, err := s.client.newRequest("PATCH", u, &options)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions agent_token.go
Expand Up @@ -72,8 +72,11 @@ func (s *agentTokens) List(ctx context.Context, agentPoolID string) (*AgentToken

// AgentTokenGenerateOptions represents the options for creating an agent token.
type AgentTokenGenerateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,agent-tokens"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,agent-tokens"`

// Description of the token
Description *string `jsonapi:"attr,description"`
Expand All @@ -89,9 +92,6 @@ func (s *agentTokens) Generate(ctx context.Context, agentPoolID string, options
return nil, ErrAgentTokenDescription
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("agent-pools/%s/authentication-tokens", url.QueryEscape(agentPoolID))
req, err := s.client.newRequest("POST", u, &options)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions configuration_version.go
Expand Up @@ -122,8 +122,11 @@ func (s *configurationVersions) List(ctx context.Context, workspaceID string, op
// ConfigurationVersionCreateOptions represents the options for creating a
// configuration version.
type ConfigurationVersionCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,configuration-versions"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,configuration-versions"`

// When true, runs are queued automatically when the configuration version
// is uploaded.
Expand All @@ -140,9 +143,6 @@ func (s *configurationVersions) Create(ctx context.Context, workspaceID string,
return nil, ErrInvalidWorkspaceID
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("workspaces/%s/configuration-versions", url.QueryEscape(workspaceID))
req, err := s.client.newRequest("POST", u, &options)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions notification_configuration.go
Expand Up @@ -131,8 +131,11 @@ func (s *notificationConfigurations) List(ctx context.Context, workspaceID strin
// NotificationConfigurationCreateOptions represents the options for
// creating a new notification configuration.
type NotificationConfigurationCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,notification-configurations"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,notification-configurations"`

// The destination type of the notification configuration
DestinationType *NotificationDestinationType `jsonapi:"attr,destination-type"`
Expand Down Expand Up @@ -188,9 +191,6 @@ func (s *notificationConfigurations) Create(ctx context.Context, workspaceID str
return nil, err
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("workspaces/%s/notification-configurations", url.QueryEscape(workspaceID))
req, err := s.client.newRequest("POST", u, &options)
if err != nil {
Expand Down Expand Up @@ -230,8 +230,11 @@ func (s *notificationConfigurations) Read(ctx context.Context, notificationConfi
// NotificationConfigurationUpdateOptions represents the options for
// updating a existing notification configuration.
type NotificationConfigurationUpdateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,notification-configurations"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,notification-configurations"`

// Whether the notification configuration should be enabled or not
Enabled *bool `jsonapi:"attr,enabled,omitempty"`
Expand Down Expand Up @@ -262,9 +265,6 @@ func (s *notificationConfigurations) Update(ctx context.Context, notificationCon
return nil, errors.New("invalid value for notification configuration ID")
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("notification-configurations/%s", url.QueryEscape(notificationConfigurationID))
req, err := s.client.newRequest("PATCH", u, &options)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions oauth_client.go
Expand Up @@ -108,8 +108,11 @@ func (s *oAuthClients) List(ctx context.Context, organization string, options OA

// OAuthClientCreateOptions represents the options for creating an OAuth client.
type OAuthClientCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,oauth-clients"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,oauth-clients"`

// The base URL of your VCS provider's API.
APIURL *string `jsonapi:"attr,api-url"`
Expand Down Expand Up @@ -155,9 +158,6 @@ func (s *oAuthClients) Create(ctx context.Context, organization string, options
return nil, err
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("organizations/%s/oauth-clients", url.QueryEscape(organization))
req, err := s.client.newRequest("POST", u, &options)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions oauth_token.go
Expand Up @@ -103,8 +103,11 @@ func (s *oAuthTokens) Read(ctx context.Context, oAuthTokenID string) (*OAuthToke

// OAuthTokenUpdateOptions represents the options for updating an OAuth token.
type OAuthTokenUpdateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,oauth-tokens"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,oauth-tokens"`

// A private SSH key to be used for git clone operations.
PrivateSSHKey *string `jsonapi:"attr,ssh-key"`
Expand All @@ -116,9 +119,6 @@ func (s *oAuthTokens) Update(ctx context.Context, oAuthTokenID string, options O
return nil, errors.New("invalid value for OAuth token ID")
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("oauth-tokens/%s", url.QueryEscape(oAuthTokenID))
req, err := s.client.newRequest("PATCH", u, &options)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions organization.go
Expand Up @@ -155,8 +155,11 @@ func (s *organizations) List(ctx context.Context, options OrganizationListOption

// OrganizationCreateOptions represents the options for creating an organization.
type OrganizationCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,organizations"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,organizations"`

// Name of the organization.
Name *string `jsonapi:"attr,name"`
Expand Down Expand Up @@ -199,9 +202,6 @@ func (s *organizations) Create(ctx context.Context, options OrganizationCreateOp
return nil, err
}

// Make sure we don't send a user provided ID.
options.ID = ""

req, err := s.client.newRequest("POST", "organizations", &options)
if err != nil {
return nil, err
Expand Down Expand Up @@ -239,8 +239,11 @@ func (s *organizations) Read(ctx context.Context, organization string) (*Organiz

// OrganizationUpdateOptions represents the options for updating an organization.
type OrganizationUpdateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,organizations"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,organizations"`

// New name for the organization.
Name *string `jsonapi:"attr,name,omitempty"`
Expand Down Expand Up @@ -270,9 +273,6 @@ func (s *organizations) Update(ctx context.Context, organization string, options
return nil, ErrInvalidOrg
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("organizations/%s", url.QueryEscape(organization))
req, err := s.client.newRequest("PATCH", u, &options)
if err != nil {
Expand Down
9 changes: 5 additions & 4 deletions organization_membership.go
Expand Up @@ -94,8 +94,11 @@ func (s *organizationMemberships) List(ctx context.Context, organization string,

// OrganizationMembershipCreateOptions represents the options for creating an organization membership.
type OrganizationMembershipCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,organization-memberships"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,organization-memberships"`

// User's email address.
Email *string `jsonapi:"attr,email"`
Expand All @@ -117,8 +120,6 @@ func (s *organizationMemberships) Create(ctx context.Context, organization strin
return nil, err
}

options.ID = ""

u := fmt.Sprintf("organizations/%s/organization-memberships", url.QueryEscape(organization))
req, err := s.client.newRequest("POST", u, &options)
if err != nil {
Expand Down
10 changes: 5 additions & 5 deletions plan_export.go
Expand Up @@ -75,8 +75,11 @@ type PlanExport struct {

// PlanExportCreateOptions represents the options for exporting data from a plan.
type PlanExportCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,plan-exports"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,plan-exports"`

// The plan to export.
Plan *Plan `jsonapi:"relation,plan"`
Expand All @@ -100,9 +103,6 @@ func (s *planExports) Create(ctx context.Context, options PlanExportCreateOption
return nil, err
}

// Make sure we don't send a user provided ID.
options.ID = ""

req, err := s.client.newRequest("POST", "plan-exports", &options)
if err != nil {
return nil, err
Expand Down
20 changes: 10 additions & 10 deletions policy.go
Expand Up @@ -110,8 +110,11 @@ func (s *policies) List(ctx context.Context, organization string, options Policy

// PolicyCreateOptions represents the options for creating a new policy.
type PolicyCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,policies"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,policies"`

// The name of the policy.
Name *string `jsonapi:"attr,name"`
Expand Down Expand Up @@ -159,9 +162,6 @@ func (s *policies) Create(ctx context.Context, organization string, options Poli
return nil, err
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("organizations/%s/policies", url.QueryEscape(organization))
req, err := s.client.newRequest("POST", u, &options)
if err != nil {
Expand Down Expand Up @@ -200,8 +200,11 @@ func (s *policies) Read(ctx context.Context, policyID string) (*Policy, error) {

// PolicyUpdateOptions represents the options for updating a policy.
type PolicyUpdateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,policies"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,policies"`

// A description of the policy's purpose.
Description *string `jsonapi:"attr,description,omitempty"`
Expand All @@ -216,9 +219,6 @@ func (s *policies) Update(ctx context.Context, policyID string, options PolicyUp
return nil, errors.New("invalid value for policy ID")
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("policies/%s", url.QueryEscape(policyID))
req, err := s.client.newRequest("PATCH", u, &options)
if err != nil {
Expand Down
20 changes: 10 additions & 10 deletions policy_set.go
Expand Up @@ -107,8 +107,11 @@ func (s *policySets) List(ctx context.Context, organization string, options Poli

// PolicySetCreateOptions represents the options for creating a new policy set.
type PolicySetCreateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,policy-sets"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,policy-sets"`

// The name of the policy set.
Name *string `jsonapi:"attr,name"`
Expand Down Expand Up @@ -157,9 +160,6 @@ func (s *policySets) Create(ctx context.Context, organization string, options Po
return nil, err
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("organizations/%s/policy-sets", url.QueryEscape(organization))
req, err := s.client.newRequest("POST", u, &options)
if err != nil {
Expand Down Expand Up @@ -198,8 +198,11 @@ func (s *policySets) Read(ctx context.Context, policySetID string) (*PolicySet,

// PolicySetUpdateOptions represents the options for updating a policy set.
type PolicySetUpdateOptions struct {
// For internal use only!
ID string `jsonapi:"primary,policy-sets"`
// Type is a public field utilized by JSON:API to
// set the resource type via the field tag.
// It is not a user-defined value and does not need to be set.
// https://jsonapi.org/format/#crud-creating
Type string `jsonapi:"primary,policy-sets"`

/// The name of the policy set.
Name *string `jsonapi:"attr,name,omitempty"`
Expand Down Expand Up @@ -240,9 +243,6 @@ func (s *policySets) Update(ctx context.Context, policySetID string, options Pol
return nil, err
}

// Make sure we don't send a user provided ID.
options.ID = ""

u := fmt.Sprintf("policy-sets/%s", url.QueryEscape(policySetID))
req, err := s.client.newRequest("PATCH", u, &options)
if err != nil {
Expand Down