From 0703f4cf32c07354ea2607e9b8b3025f21f64eb7 Mon Sep 17 00:00:00 2001 From: Omar Ismail Date: Wed, 10 Mar 2021 15:07:59 -0500 Subject: [PATCH 1/2] Update create/update options to match JSON:API Type field --- agent_pool.go | 16 ++++++---------- agent_token.go | 8 +++----- configuration_version.go | 8 +++----- notification_configuration.go | 16 ++++++---------- oauth_client.go | 8 +++----- oauth_token.go | 8 +++----- organization.go | 16 ++++++---------- organization_membership.go | 7 +++---- plan_export.go | 8 +++----- policy.go | 16 ++++++---------- policy_set.go | 16 ++++++---------- policy_set_parameter.go | 16 ++++++---------- registry_module.go | 16 ++++++---------- run.go | 8 +++----- run_trigger.go | 8 +++----- ssh_key.go | 8 +++----- state_version.go | 8 +++----- team.go | 16 ++++++---------- team_access.go | 16 ++++++---------- user.go | 8 +++----- variable.go | 16 ++++++---------- workspace.go | 32 ++++++++++++-------------------- 22 files changed, 105 insertions(+), 174 deletions(-) diff --git a/agent_pool.go b/agent_pool.go index 45523f02d..ec2425b67 100644 --- a/agent_pool.go +++ b/agent_pool.go @@ -78,8 +78,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,agent-pools"` // A name to identify the agent pool. Name *string `jsonapi:"attr,name"` @@ -105,9 +106,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 { @@ -146,8 +144,9 @@ 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 the required field as part of JSON:API. + // 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"` @@ -170,9 +169,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 { diff --git a/agent_token.go b/agent_token.go index b39fec608..b20a73620 100644 --- a/agent_token.go +++ b/agent_token.go @@ -72,8 +72,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,agent-tokens"` // Description of the token Description *string `jsonapi:"attr,description"` @@ -89,9 +90,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 { diff --git a/configuration_version.go b/configuration_version.go index 96e16548d..452ecf338 100644 --- a/configuration_version.go +++ b/configuration_version.go @@ -122,8 +122,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,configuration-versions"` // When true, runs are queued automatically when the configuration version // is uploaded. @@ -140,9 +141,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 { diff --git a/notification_configuration.go b/notification_configuration.go index 2bd642a94..dd8fea95b 100644 --- a/notification_configuration.go +++ b/notification_configuration.go @@ -131,8 +131,9 @@ 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 the required field as part of JSON:API. + // 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"` @@ -188,9 +189,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 { @@ -230,8 +228,9 @@ 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 the required field as part of JSON:API. + // 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"` @@ -262,9 +261,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 { diff --git a/oauth_client.go b/oauth_client.go index 69791cc4e..d03fc44b6 100644 --- a/oauth_client.go +++ b/oauth_client.go @@ -108,8 +108,9 @@ 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 the required field as part of JSON:API. + // 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"` @@ -155,9 +156,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 { diff --git a/oauth_token.go b/oauth_token.go index 248fc2528..4bcaf8619 100644 --- a/oauth_token.go +++ b/oauth_token.go @@ -103,8 +103,9 @@ 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 the required field as part of JSON:API. + // 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"` @@ -116,9 +117,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 { diff --git a/organization.go b/organization.go index d3a3983f4..0ece63363 100644 --- a/organization.go +++ b/organization.go @@ -155,8 +155,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,organizations"` // Name of the organization. Name *string `jsonapi:"attr,name"` @@ -199,9 +200,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 @@ -239,8 +237,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,organizations"` // New name for the organization. Name *string `jsonapi:"attr,name,omitempty"` @@ -270,9 +269,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 { diff --git a/organization_membership.go b/organization_membership.go index c9756d089..1850a511e 100644 --- a/organization_membership.go +++ b/organization_membership.go @@ -94,8 +94,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,organization-memberships"` // User's email address. Email *string `jsonapi:"attr,email"` @@ -117,8 +118,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 { diff --git a/plan_export.go b/plan_export.go index cf9e9ced8..b8270d5bb 100644 --- a/plan_export.go +++ b/plan_export.go @@ -75,8 +75,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,plan-exports"` // The plan to export. Plan *Plan `jsonapi:"relation,plan"` @@ -100,9 +101,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 diff --git a/policy.go b/policy.go index 322fc927c..3fd6db7ba 100644 --- a/policy.go +++ b/policy.go @@ -110,8 +110,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,policies"` // The name of the policy. Name *string `jsonapi:"attr,name"` @@ -159,9 +160,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 { @@ -200,8 +198,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,policies"` // A description of the policy's purpose. Description *string `jsonapi:"attr,description,omitempty"` @@ -216,9 +215,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 { diff --git a/policy_set.go b/policy_set.go index 81c78a017..a96ce9865 100644 --- a/policy_set.go +++ b/policy_set.go @@ -107,8 +107,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,policy-sets"` // The name of the policy set. Name *string `jsonapi:"attr,name"` @@ -157,9 +158,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 { @@ -198,8 +196,9 @@ 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 the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,policy-sets"` /// The name of the policy set. Name *string `jsonapi:"attr,name,omitempty"` @@ -240,9 +239,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 { diff --git a/policy_set_parameter.go b/policy_set_parameter.go index 6e2587b90..3c6d45609 100644 --- a/policy_set_parameter.go +++ b/policy_set_parameter.go @@ -89,8 +89,9 @@ func (s *policySetParameters) List(ctx context.Context, policySetID string, opti // PolicySetParameterCreateOptions represents the options for creating a new parameter. type PolicySetParameterCreateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,vars"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,vars"` // The name of the parameter. Key *string `jsonapi:"attr,key"` @@ -127,9 +128,6 @@ func (s *policySetParameters) Create(ctx context.Context, policySetID string, op return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("policy-sets/%s/parameters", url.QueryEscape(policySetID)) req, err := s.client.newRequest("POST", u, &options) if err != nil { @@ -171,8 +169,9 @@ func (s *policySetParameters) Read(ctx context.Context, policySetID string, para // PolicySetParameterUpdateOptions represents the options for updating a parameter. type PolicySetParameterUpdateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,vars"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,vars"` // The name of the parameter. Key *string `jsonapi:"attr,key,omitempty"` @@ -193,9 +192,6 @@ func (s *policySetParameters) Update(ctx context.Context, policySetID string, pa return nil, errors.New("invalid value for parameter ID") } - // Make sure we don't send a user provided ID. - options.ID = parameterID - u := fmt.Sprintf("policy-sets/%s/parameters/%s", url.QueryEscape(policySetID), url.QueryEscape(parameterID)) req, err := s.client.newRequest("PATCH", u, &options) if err != nil { diff --git a/registry_module.go b/registry_module.go index 0616a066f..0411a3646 100644 --- a/registry_module.go +++ b/registry_module.go @@ -110,8 +110,9 @@ type RegistryModuleVersionStatuses struct { // RegistryModuleCreateOptions is used when creating a registry module without a VCS repo type RegistryModuleCreateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,registry-modules"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,registry-modules"` Name *string `jsonapi:"attr,name"` Provider *string `jsonapi:"attr,provider"` @@ -142,9 +143,6 @@ func (r *registryModules) Create(ctx context.Context, organization string, optio return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf( "organizations/%s/registry-modules", url.QueryEscape(organization), @@ -165,8 +163,9 @@ func (r *registryModules) Create(ctx context.Context, organization string, optio // RegistryModuleCreateVersionOptions is used when creating a registry module version type RegistryModuleCreateVersionOptions struct { - // For internal use only! - ID string `jsonapi:"primary,registry-module-versions"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,registry-module-versions"` Version *string `jsonapi:"attr,version"` } @@ -202,9 +201,6 @@ func (r *registryModules) CreateVersion(ctx context.Context, organization string return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf( "registry-modules/%s/%s/%s/versions", url.QueryEscape(organization), diff --git a/run.go b/run.go index 245a8fa67..a397940f1 100644 --- a/run.go +++ b/run.go @@ -176,8 +176,9 @@ func (s *runs) List(ctx context.Context, workspaceID string, options RunListOpti // RunCreateOptions represents the options for creating a new run. type RunCreateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,runs"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,runs"` // Specifies if this plan is a destroy plan, which will destroy all // provisioned resources. @@ -221,9 +222,6 @@ func (s *runs) Create(ctx context.Context, options RunCreateOptions) (*Run, erro return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - req, err := s.client.newRequest("POST", "runs", &options) if err != nil { return nil, err diff --git a/run_trigger.go b/run_trigger.go index 5402e670a..1c985593c 100644 --- a/run_trigger.go +++ b/run_trigger.go @@ -99,8 +99,9 @@ func (s *runTriggers) List(ctx context.Context, workspaceID string, options RunT // RunTriggerCreateOptions represents the options for // creating a new run trigger. type RunTriggerCreateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,run-triggers"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,run-triggers"` // The source workspace Sourceable *Workspace `jsonapi:"relation,sourceable"` @@ -122,9 +123,6 @@ func (s *runTriggers) Create(ctx context.Context, workspaceID string, options Ru return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("workspaces/%s/run-triggers", url.QueryEscape(workspaceID)) req, err := s.client.newRequest("POST", u, &options) if err != nil { diff --git a/ssh_key.go b/ssh_key.go index 334e88bc4..621199572 100644 --- a/ssh_key.go +++ b/ssh_key.go @@ -77,8 +77,9 @@ func (s *sshKeys) List(ctx context.Context, organization string, options SSHKeyL // SSHKeyCreateOptions represents the options for creating an SSH key. type SSHKeyCreateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,ssh-keys"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,ssh-keys"` // A name to identify the SSH key. Name *string `jsonapi:"attr,name"` @@ -107,9 +108,6 @@ func (s *sshKeys) Create(ctx context.Context, organization string, options SSHKe return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("organizations/%s/ssh-keys", url.QueryEscape(organization)) req, err := s.client.newRequest("POST", u, &options) if err != nil { diff --git a/state_version.go b/state_version.go index 4ba52eee9..2a0eacd9f 100644 --- a/state_version.go +++ b/state_version.go @@ -104,8 +104,9 @@ func (s *stateVersions) List(ctx context.Context, options StateVersionListOption // StateVersionCreateOptions represents the options for creating a state version. type StateVersionCreateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,state-versions"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,state-versions"` // The lineage of the state. Lineage *string `jsonapi:"attr,lineage,omitempty"` @@ -149,9 +150,6 @@ func (s *stateVersions) Create(ctx context.Context, workspaceID string, options return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("workspaces/%s/state-versions", url.QueryEscape(workspaceID)) req, err := s.client.newRequest("POST", u, &options) if err != nil { diff --git a/team.go b/team.go index b2b47cb62..3ed2e1cc1 100644 --- a/team.go +++ b/team.go @@ -99,8 +99,9 @@ func (s *teams) List(ctx context.Context, organization string, options TeamListO // TeamCreateOptions represents the options for creating a team. type TeamCreateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,teams"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,teams"` // Name of the team. Name *string `jsonapi:"attr,name"` @@ -135,9 +136,6 @@ func (s *teams) Create(ctx context.Context, organization string, options TeamCre return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("organizations/%s/teams", url.QueryEscape(organization)) req, err := s.client.newRequest("POST", u, &options) if err != nil { @@ -176,8 +174,9 @@ func (s *teams) Read(ctx context.Context, teamID string) (*Team, error) { // TeamUpdateOptions represents the options for updating a team. type TeamUpdateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,teams"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,teams"` // New name for the team Name *string `jsonapi:"attr,name,omitempty"` @@ -195,9 +194,6 @@ func (s *teams) Update(ctx context.Context, teamID string, options TeamUpdateOpt return nil, errors.New("invalid value for team ID") } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("teams/%s", url.QueryEscape(teamID)) req, err := s.client.newRequest("PATCH", u, &options) if err != nil { diff --git a/team_access.go b/team_access.go index 7226eeb45..fd8734f38 100644 --- a/team_access.go +++ b/team_access.go @@ -139,8 +139,9 @@ func (s *teamAccesses) List(ctx context.Context, options TeamAccessListOptions) // TeamAccessAddOptions represents the options for adding team access. type TeamAccessAddOptions struct { - // For internal use only! - ID string `jsonapi:"primary,team-workspaces"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,team-workspaces"` // The type of access to grant. Access *AccessType `jsonapi:"attr,access"` @@ -179,9 +180,6 @@ func (s *teamAccesses) Add(ctx context.Context, options TeamAccessAddOptions) (* return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - req, err := s.client.newRequest("POST", "team-workspaces", &options) if err != nil { return nil, err @@ -219,8 +217,9 @@ func (s *teamAccesses) Read(ctx context.Context, teamAccessID string) (*TeamAcce // TeamAccessUpdateOptions represents the options for updating team access. type TeamAccessUpdateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,team-workspaces"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,team-workspaces"` // The type of access to grant. Access *AccessType `jsonapi:"attr,access,omitempty"` @@ -240,9 +239,6 @@ func (s *teamAccesses) Update(ctx context.Context, teamAccessID string, options return nil, errors.New("invalid value for team access ID") } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("team-workspaces/%s", url.QueryEscape(teamAccessID)) req, err := s.client.newRequest("PATCH", u, &options) if err != nil { diff --git a/user.go b/user.go index f0ca28ee3..e6dedca65 100644 --- a/user.go +++ b/user.go @@ -63,8 +63,9 @@ func (s *users) ReadCurrent(ctx context.Context) (*User, error) { // UserUpdateOptions represents the options for updating a user. type UserUpdateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,users"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,users"` // New username. Username *string `jsonapi:"attr,username,omitempty"` @@ -75,9 +76,6 @@ type UserUpdateOptions struct { // Update attributes of the currently authenticated user. func (s *users) Update(ctx context.Context, options UserUpdateOptions) (*User, error) { - // Make sure we don't send a user provided ID. - options.ID = "" - req, err := s.client.newRequest("PATCH", "account/update", &options) if err != nil { return nil, err diff --git a/variable.go b/variable.go index b68b2954a..a70ac8028 100644 --- a/variable.go +++ b/variable.go @@ -94,8 +94,9 @@ func (s *variables) List(ctx context.Context, workspaceID string, options Variab // VariableCreateOptions represents the options for creating a new variable. type VariableCreateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,vars"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,vars"` // The name of the variable. Key *string `jsonapi:"attr,key"` @@ -135,9 +136,6 @@ func (s *variables) Create(ctx context.Context, workspaceID string, options Vari return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("workspaces/%s/vars", url.QueryEscape(workspaceID)) req, err := s.client.newRequest("POST", u, &options) if err != nil { @@ -179,8 +177,9 @@ func (s *variables) Read(ctx context.Context, workspaceID string, variableID str // VariableUpdateOptions represents the options for updating a variable. type VariableUpdateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,vars"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,vars"` // The name of the variable. Key *string `jsonapi:"attr,key,omitempty"` @@ -207,9 +206,6 @@ func (s *variables) Update(ctx context.Context, workspaceID string, variableID s return nil, errors.New("invalid value for variable ID") } - // Make sure we don't send a user provided ID. - options.ID = variableID - u := fmt.Sprintf("workspaces/%s/vars/%s", url.QueryEscape(workspaceID), url.QueryEscape(variableID)) req, err := s.client.newRequest("PATCH", u, &options) if err != nil { diff --git a/workspace.go b/workspace.go index 06ac13be3..69f80aee3 100644 --- a/workspace.go +++ b/workspace.go @@ -167,8 +167,9 @@ func (s *workspaces) List(ctx context.Context, organization string, options Work // WorkspaceCreateOptions represents the options for creating a new workspace. type WorkspaceCreateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,workspaces"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,workspaces"` // Required when execution-mode is set to agent. The ID of the agent pool // belonging to the workspace's organization. This value must not be specified @@ -277,9 +278,6 @@ func (s *workspaces) Create(ctx context.Context, organization string, options Wo return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("organizations/%s/workspaces", url.QueryEscape(organization)) req, err := s.client.newRequest("POST", u, &options) if err != nil { @@ -346,8 +344,9 @@ func (s *workspaces) ReadByID(ctx context.Context, workspaceID string) (*Workspa // WorkspaceUpdateOptions represents the options for updating a workspace. type WorkspaceUpdateOptions struct { - // For internal use only! - ID string `jsonapi:"primary,workspaces"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,workspaces"` // Required when execution-mode is set to agent. The ID of the agent pool // belonging to the workspace's organization. This value must not be specified @@ -442,9 +441,6 @@ func (s *workspaces) Update(ctx context.Context, organization, workspace string, return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf( "organizations/%s/workspaces/%s", url.QueryEscape(organization), @@ -470,9 +466,6 @@ func (s *workspaces) UpdateByID(ctx context.Context, workspaceID string, options return nil, ErrInvalidWorkspaceID } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("workspaces/%s", url.QueryEscape(workspaceID)) req, err := s.client.newRequest("PATCH", u, &options) if err != nil { @@ -654,8 +647,9 @@ func (s *workspaces) ForceUnlock(ctx context.Context, workspaceID string) (*Work // WorkspaceAssignSSHKeyOptions represents the options to assign an SSH key to // a workspace. type WorkspaceAssignSSHKeyOptions struct { - // For internal use only! - ID string `jsonapi:"primary,workspaces"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,workspaces"` // The SSH key ID to assign. SSHKeyID *string `jsonapi:"attr,id"` @@ -680,9 +674,6 @@ func (s *workspaces) AssignSSHKey(ctx context.Context, workspaceID string, optio return nil, err } - // Make sure we don't send a user provided ID. - options.ID = "" - u := fmt.Sprintf("workspaces/%s/relationships/ssh-key", url.QueryEscape(workspaceID)) req, err := s.client.newRequest("PATCH", u, &options) if err != nil { @@ -701,8 +692,9 @@ func (s *workspaces) AssignSSHKey(ctx context.Context, workspaceID string, optio // workspaceUnassignSSHKeyOptions represents the options to unassign an SSH key // to a workspace. type workspaceUnassignSSHKeyOptions struct { - // For internal use only! - ID string `jsonapi:"primary,workspaces"` + // Type is the required field as part of JSON:API. + // https://jsonapi.org/format/#crud-creating + Type string `jsonapi:"primary,workspaces"` // Must be nil to unset the currently assigned SSH key. SSHKeyID *string `jsonapi:"attr,id"` From f8d54c0929986cfb73e728f2cd7e50d8d044b156 Mon Sep 17 00:00:00 2001 From: Omar Ismail Date: Wed, 10 Mar 2021 18:28:52 -0500 Subject: [PATCH 2/2] updated wording --- agent_pool.go | 8 ++++++-- agent_token.go | 4 +++- configuration_version.go | 4 +++- notification_configuration.go | 8 ++++++-- oauth_client.go | 4 +++- oauth_token.go | 4 +++- organization.go | 8 ++++++-- organization_membership.go | 4 +++- plan_export.go | 4 +++- policy.go | 8 ++++++-- policy_set.go | 8 ++++++-- policy_set_parameter.go | 8 ++++++-- registry_module.go | 8 ++++++-- run.go | 4 +++- run_trigger.go | 4 +++- ssh_key.go | 4 +++- state_version.go | 4 +++- team.go | 8 ++++++-- team_access.go | 8 ++++++-- user.go | 4 +++- variable.go | 8 ++++++-- workspace.go | 16 ++++++++++++---- 22 files changed, 105 insertions(+), 35 deletions(-) diff --git a/agent_pool.go b/agent_pool.go index ec2425b67..f1021f0b6 100644 --- a/agent_pool.go +++ b/agent_pool.go @@ -78,7 +78,9 @@ func (s *agentPools) List(ctx context.Context, organization string, options Agen // AgentPoolCreateOptions represents the options for creating an agent pool. type AgentPoolCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` @@ -144,7 +146,9 @@ func (s *agentPools) Read(ctx context.Context, agentpoolID string) (*AgentPool, // AgentPoolUpdateOptions represents the options for updating an agent pool. type AgentPoolUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/agent_token.go b/agent_token.go index b20a73620..0c9c655c0 100644 --- a/agent_token.go +++ b/agent_token.go @@ -72,7 +72,9 @@ func (s *agentTokens) List(ctx context.Context, agentPoolID string) (*AgentToken // AgentTokenGenerateOptions represents the options for creating an agent token. type AgentTokenGenerateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/configuration_version.go b/configuration_version.go index 452ecf338..92e214a71 100644 --- a/configuration_version.go +++ b/configuration_version.go @@ -122,7 +122,9 @@ func (s *configurationVersions) List(ctx context.Context, workspaceID string, op // ConfigurationVersionCreateOptions represents the options for creating a // configuration version. type ConfigurationVersionCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/notification_configuration.go b/notification_configuration.go index dd8fea95b..77b03b753 100644 --- a/notification_configuration.go +++ b/notification_configuration.go @@ -131,7 +131,9 @@ func (s *notificationConfigurations) List(ctx context.Context, workspaceID strin // NotificationConfigurationCreateOptions represents the options for // creating a new notification configuration. type NotificationConfigurationCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` @@ -228,7 +230,9 @@ func (s *notificationConfigurations) Read(ctx context.Context, notificationConfi // NotificationConfigurationUpdateOptions represents the options for // updating a existing notification configuration. type NotificationConfigurationUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/oauth_client.go b/oauth_client.go index d03fc44b6..9b3ddcfca 100644 --- a/oauth_client.go +++ b/oauth_client.go @@ -108,7 +108,9 @@ func (s *oAuthClients) List(ctx context.Context, organization string, options OA // OAuthClientCreateOptions represents the options for creating an OAuth client. type OAuthClientCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/oauth_token.go b/oauth_token.go index 4bcaf8619..95283ea10 100644 --- a/oauth_token.go +++ b/oauth_token.go @@ -103,7 +103,9 @@ func (s *oAuthTokens) Read(ctx context.Context, oAuthTokenID string) (*OAuthToke // OAuthTokenUpdateOptions represents the options for updating an OAuth token. type OAuthTokenUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/organization.go b/organization.go index 0ece63363..f36e77c75 100644 --- a/organization.go +++ b/organization.go @@ -155,7 +155,9 @@ func (s *organizations) List(ctx context.Context, options OrganizationListOption // OrganizationCreateOptions represents the options for creating an organization. type OrganizationCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` @@ -237,7 +239,9 @@ func (s *organizations) Read(ctx context.Context, organization string) (*Organiz // OrganizationUpdateOptions represents the options for updating an organization. type OrganizationUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/organization_membership.go b/organization_membership.go index 1850a511e..79ea8aee4 100644 --- a/organization_membership.go +++ b/organization_membership.go @@ -94,7 +94,9 @@ func (s *organizationMemberships) List(ctx context.Context, organization string, // OrganizationMembershipCreateOptions represents the options for creating an organization membership. type OrganizationMembershipCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/plan_export.go b/plan_export.go index b8270d5bb..ff895e521 100644 --- a/plan_export.go +++ b/plan_export.go @@ -75,7 +75,9 @@ type PlanExport struct { // PlanExportCreateOptions represents the options for exporting data from a plan. type PlanExportCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/policy.go b/policy.go index 3fd6db7ba..5118ab9b0 100644 --- a/policy.go +++ b/policy.go @@ -110,7 +110,9 @@ func (s *policies) List(ctx context.Context, organization string, options Policy // PolicyCreateOptions represents the options for creating a new policy. type PolicyCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` @@ -198,7 +200,9 @@ func (s *policies) Read(ctx context.Context, policyID string) (*Policy, error) { // PolicyUpdateOptions represents the options for updating a policy. type PolicyUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/policy_set.go b/policy_set.go index a96ce9865..d86568628 100644 --- a/policy_set.go +++ b/policy_set.go @@ -107,7 +107,9 @@ func (s *policySets) List(ctx context.Context, organization string, options Poli // PolicySetCreateOptions represents the options for creating a new policy set. type PolicySetCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` @@ -196,7 +198,9 @@ func (s *policySets) Read(ctx context.Context, policySetID string) (*PolicySet, // PolicySetUpdateOptions represents the options for updating a policy set. type PolicySetUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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"` diff --git a/policy_set_parameter.go b/policy_set_parameter.go index 3c6d45609..5c229bede 100644 --- a/policy_set_parameter.go +++ b/policy_set_parameter.go @@ -89,7 +89,9 @@ func (s *policySetParameters) List(ctx context.Context, policySetID string, opti // PolicySetParameterCreateOptions represents the options for creating a new parameter. type PolicySetParameterCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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,vars"` @@ -169,7 +171,9 @@ func (s *policySetParameters) Read(ctx context.Context, policySetID string, para // PolicySetParameterUpdateOptions represents the options for updating a parameter. type PolicySetParameterUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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,vars"` diff --git a/registry_module.go b/registry_module.go index 0411a3646..750eb2da6 100644 --- a/registry_module.go +++ b/registry_module.go @@ -110,7 +110,9 @@ type RegistryModuleVersionStatuses struct { // RegistryModuleCreateOptions is used when creating a registry module without a VCS repo type RegistryModuleCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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,registry-modules"` @@ -163,7 +165,9 @@ func (r *registryModules) Create(ctx context.Context, organization string, optio // RegistryModuleCreateVersionOptions is used when creating a registry module version type RegistryModuleCreateVersionOptions struct { - // Type is the required field as part of JSON:API. + // 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,registry-module-versions"` diff --git a/run.go b/run.go index a397940f1..dcb2aa508 100644 --- a/run.go +++ b/run.go @@ -176,7 +176,9 @@ func (s *runs) List(ctx context.Context, workspaceID string, options RunListOpti // RunCreateOptions represents the options for creating a new run. type RunCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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,runs"` diff --git a/run_trigger.go b/run_trigger.go index 1c985593c..eb8005a1c 100644 --- a/run_trigger.go +++ b/run_trigger.go @@ -99,7 +99,9 @@ func (s *runTriggers) List(ctx context.Context, workspaceID string, options RunT // RunTriggerCreateOptions represents the options for // creating a new run trigger. type RunTriggerCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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,run-triggers"` diff --git a/ssh_key.go b/ssh_key.go index 621199572..55f500b64 100644 --- a/ssh_key.go +++ b/ssh_key.go @@ -77,7 +77,9 @@ func (s *sshKeys) List(ctx context.Context, organization string, options SSHKeyL // SSHKeyCreateOptions represents the options for creating an SSH key. type SSHKeyCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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,ssh-keys"` diff --git a/state_version.go b/state_version.go index 2a0eacd9f..8b4e6dec8 100644 --- a/state_version.go +++ b/state_version.go @@ -104,7 +104,9 @@ func (s *stateVersions) List(ctx context.Context, options StateVersionListOption // StateVersionCreateOptions represents the options for creating a state version. type StateVersionCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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,state-versions"` diff --git a/team.go b/team.go index 3ed2e1cc1..8a59790df 100644 --- a/team.go +++ b/team.go @@ -99,7 +99,9 @@ func (s *teams) List(ctx context.Context, organization string, options TeamListO // TeamCreateOptions represents the options for creating a team. type TeamCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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,teams"` @@ -174,7 +176,9 @@ func (s *teams) Read(ctx context.Context, teamID string) (*Team, error) { // TeamUpdateOptions represents the options for updating a team. type TeamUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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,teams"` diff --git a/team_access.go b/team_access.go index fd8734f38..5be3ef18b 100644 --- a/team_access.go +++ b/team_access.go @@ -139,7 +139,9 @@ func (s *teamAccesses) List(ctx context.Context, options TeamAccessListOptions) // TeamAccessAddOptions represents the options for adding team access. type TeamAccessAddOptions struct { - // Type is the required field as part of JSON:API. + // 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,team-workspaces"` @@ -217,7 +219,9 @@ func (s *teamAccesses) Read(ctx context.Context, teamAccessID string) (*TeamAcce // TeamAccessUpdateOptions represents the options for updating team access. type TeamAccessUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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,team-workspaces"` diff --git a/user.go b/user.go index e6dedca65..96b64c8b4 100644 --- a/user.go +++ b/user.go @@ -63,7 +63,9 @@ func (s *users) ReadCurrent(ctx context.Context) (*User, error) { // UserUpdateOptions represents the options for updating a user. type UserUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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,users"` diff --git a/variable.go b/variable.go index a70ac8028..60b52ca37 100644 --- a/variable.go +++ b/variable.go @@ -94,7 +94,9 @@ func (s *variables) List(ctx context.Context, workspaceID string, options Variab // VariableCreateOptions represents the options for creating a new variable. type VariableCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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,vars"` @@ -177,7 +179,9 @@ func (s *variables) Read(ctx context.Context, workspaceID string, variableID str // VariableUpdateOptions represents the options for updating a variable. type VariableUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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,vars"` diff --git a/workspace.go b/workspace.go index 69f80aee3..867400739 100644 --- a/workspace.go +++ b/workspace.go @@ -167,7 +167,9 @@ func (s *workspaces) List(ctx context.Context, organization string, options Work // WorkspaceCreateOptions represents the options for creating a new workspace. type WorkspaceCreateOptions struct { - // Type is the required field as part of JSON:API. + // 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,workspaces"` @@ -344,7 +346,9 @@ func (s *workspaces) ReadByID(ctx context.Context, workspaceID string) (*Workspa // WorkspaceUpdateOptions represents the options for updating a workspace. type WorkspaceUpdateOptions struct { - // Type is the required field as part of JSON:API. + // 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,workspaces"` @@ -647,7 +651,9 @@ func (s *workspaces) ForceUnlock(ctx context.Context, workspaceID string) (*Work // WorkspaceAssignSSHKeyOptions represents the options to assign an SSH key to // a workspace. type WorkspaceAssignSSHKeyOptions struct { - // Type is the required field as part of JSON:API. + // 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,workspaces"` @@ -692,7 +698,9 @@ func (s *workspaces) AssignSSHKey(ctx context.Context, workspaceID string, optio // workspaceUnassignSSHKeyOptions represents the options to unassign an SSH key // to a workspace. type workspaceUnassignSSHKeyOptions struct { - // Type is the required field as part of JSON:API. + // 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,workspaces"`