diff --git a/client/api.go b/client/api.go index 45542eda..4ce53e0e 100644 --- a/client/api.go +++ b/client/api.go @@ -1233,35 +1233,35 @@ func (c *Client) GetFiledrop(ctx context.Context, id string) (*meta.Filedrop, er return c.Meta.GetFiledrop(ctx, id) } -func (c *Client) GetSnowflakeShareOutbound(ctx context.Context, id string) (*meta.SnowflakeShareOutbound, error) { - return c.Meta.GetSnowflakeShareOutbound(ctx, id) +func (c *Client) GetSnowflakeOutboundShare(ctx context.Context, id string) (*meta.SnowflakeOutboundShare, error) { + return c.Meta.GetSnowflakeOutboundShare(ctx, id) } -func (c *Client) CreateSnowflakeShareOutbound(ctx context.Context, workspaceId string, input *meta.SnowflakeShareOutboundInput) (*meta.SnowflakeShareOutbound, error) { +func (c *Client) CreateSnowflakeOutboundShare(ctx context.Context, workspaceId string, input *meta.SnowflakeOutboundShareInput) (*meta.SnowflakeOutboundShare, error) { if !c.Flags[flagObs2110] { c.obs2110.Lock() defer c.obs2110.Unlock() } - return c.Meta.CreateSnowflakeShareOutbound(ctx, workspaceId, input) + return c.Meta.CreateSnowflakeOutboundShare(ctx, workspaceId, input) } -func (c *Client) UpdateSnowflakeShareOutbound(ctx context.Context, id string, input *meta.SnowflakeShareOutboundInput) (*meta.SnowflakeShareOutbound, error) { +func (c *Client) UpdateSnowflakeOutboundShare(ctx context.Context, id string, input *meta.SnowflakeOutboundShareInput) (*meta.SnowflakeOutboundShare, error) { if !c.Flags[flagObs2110] { c.obs2110.Lock() defer c.obs2110.Unlock() } - return c.Meta.UpdateSnowflakeShareOutbound(ctx, id, input) + return c.Meta.UpdateSnowflakeOutboundShare(ctx, id, input) } -func (c *Client) DeleteSnowflakeShareOutbound(ctx context.Context, id string) error { +func (c *Client) DeleteSnowflakeOutboundShare(ctx context.Context, id string) error { if !c.Flags[flagObs2110] { c.obs2110.Lock() defer c.obs2110.Unlock() } - return c.Meta.DeleteSnowflakeShareOutbound(ctx, id) + return c.Meta.DeleteSnowflakeOutboundShare(ctx, id) } func (c *Client) GetDatasetOutboundShare(ctx context.Context, id string) (*meta.DatasetOutboundShare, error) { diff --git a/client/internal/meta/operation/snowflakeoutboundshare.graphql b/client/internal/meta/operation/snowflakeoutboundshare.graphql new file mode 100644 index 00000000..2efae756 --- /dev/null +++ b/client/internal/meta/operation/snowflakeoutboundshare.graphql @@ -0,0 +1,55 @@ +fragment SnowflakeOutboundShare on SnowflakeOutboundShare { + id + name + description + workspaceId + + shareName + + # @genqlient(flatten: true) + accounts { + ...SnowflakeAccount + } +} + +fragment SnowflakeAccount on SnowflakeAccount { + organization + account +} + +query getSnowflakeOutboundShare($id: ObjectId!) { + # @genqlient(flatten: true) + share: snowflakeOutboundShare(id: $id) { + ...SnowflakeOutboundShare + } +} + +query lookupSnowflakeOutboundShare($name: String!, $workspaceId: ObjectId!) { + shares: searchSnowflakeOutboundShare(nameExact: $name, workspaceId: $workspaceId) { + # @genqlient(flatten: true) + results { + ...SnowflakeOutboundShare + } + } +} + +mutation createSnowflakeOutboundShare($workspaceId: ObjectId!, $input: SnowflakeOutboundShareInput!) { + # @genqlient(flatten: true) + share: createSnowflakeOutboundShare(workspaceId: $workspaceId, input: $input) { + ...SnowflakeOutboundShare + } +} + +mutation updateSnowflakeOutboundShare($id: ObjectId!, $input: SnowflakeOutboundShareInput!) { + # @genqlient(flatten: true) + share: updateSnowflakeOutboundShare(id: $id, input: $input) { + ...SnowflakeOutboundShare + } +} + +mutation deleteSnowflakeOutboundShare($id: ObjectId!) { + # @genqlient(flatten: true) + resultStatus: deleteSnowflakeOutboundShare(id: $id) { + ...ResultStatus + } +} diff --git a/client/internal/meta/operation/snowflakeshareoutbound.graphql b/client/internal/meta/operation/snowflakeshareoutbound.graphql deleted file mode 100644 index 6d847721..00000000 --- a/client/internal/meta/operation/snowflakeshareoutbound.graphql +++ /dev/null @@ -1,55 +0,0 @@ -fragment SnowflakeShareOutbound on SnowflakeShareOutbound { - id - name - description - workspaceId - - shareName - - # @genqlient(flatten: true) - accounts { - ...SnowflakeAccount - } -} - -fragment SnowflakeAccount on SnowflakeAccount { - organization - account -} - -query getSnowflakeShareOutbound($id: ObjectId!) { - # @genqlient(flatten: true) - share: snowflakeShareOutbound(id: $id) { - ...SnowflakeShareOutbound - } -} - -query lookupSnowflakeShareOutbound($name: String!, $workspaceId: ObjectId!) { - shares: searchSnowflakeShareOutbound(nameExact: $name, workspaceId: $workspaceId) { - # @genqlient(flatten: true) - results { - ...SnowflakeShareOutbound - } - } -} - -mutation createSnowflakeShareOutbound($workspaceId: ObjectId!, $input: SnowflakeShareOutboundInput!) { - # @genqlient(flatten: true) - share: createSnowflakeShareOutbound(workspaceId: $workspaceId, input: $input) { - ...SnowflakeShareOutbound - } -} - -mutation updateSnowflakeShareOutbound($id: ObjectId!, $input: SnowflakeShareOutboundInput!) { - # @genqlient(flatten: true) - share: updateSnowflakeShareOutbound(id: $id, input: $input) { - ...SnowflakeShareOutbound - } -} - -mutation deleteSnowflakeShareOutbound($id: ObjectId!) { - # @genqlient(flatten: true) - resultStatus: deleteSnowflakeShareOutbound(id: $id) { - ...ResultStatus - } -} diff --git a/client/internal/meta/schema/snowflakeshareoutbound.graphql b/client/internal/meta/schema/snowflakeoutboundshare.graphql similarity index 66% rename from client/internal/meta/schema/snowflakeshareoutbound.graphql rename to client/internal/meta/schema/snowflakeoutboundshare.graphql index 489dcf9a..afe28b1a 100644 --- a/client/internal/meta/schema/snowflakeshareoutbound.graphql +++ b/client/internal/meta/schema/snowflakeoutboundshare.graphql @@ -1,16 +1,17 @@ # this file is auto-generated, do not edit extend type Query { - snowflakeShareOutbound(id: ObjectId!): SnowflakeShareOutbound! - searchSnowflakeShareOutbound(workspaceId: ObjectId, folderId: ObjectId, nameExact: String, nameSubstring: String): SnowflakeShareOutboundSearchResult! + snowflakeOutboundShare(id: ObjectId!): SnowflakeOutboundShare! + searchSnowflakeOutboundShare(workspaceId: ObjectId, folderId: ObjectId, nameExact: String, nameSubstring: String): SnowflakeOutboundShareSearchResult! } extend type Mutation { - createSnowflakeShareOutbound(workspaceId: ObjectId!, input: SnowflakeShareOutboundInput!): SnowflakeShareOutbound! - updateSnowflakeShareOutbound(id: ObjectId!, input: SnowflakeShareOutboundInput!): SnowflakeShareOutbound! - deleteSnowflakeShareOutbound(id: ObjectId!): ResultStatus! + createSnowflakeOutboundShare(workspaceId: ObjectId!, input: SnowflakeOutboundShareInput!): SnowflakeOutboundShare! + updateSnowflakeOutboundShare(id: ObjectId!, input: SnowflakeOutboundShareInput!): SnowflakeOutboundShare! + deleteSnowflakeOutboundShare(id: ObjectId!): ResultStatus! } -type SnowflakeShareOutbound implements WorkspaceObject & AuditedObject & FolderObject @goModel(model: "observe/meta/metatypes.SnowflakeShareOutbound") { +# Represents a Snowflake share from Observe to a customer-managed Snowflake account. All share mutations require the Manager role rather than the typical Editor role. By default, only administrators have this access for all workspace objects. However, administrators can grant other users access to sharing mutations via RBAC. +type SnowflakeOutboundShare implements WorkspaceObject & AuditedObject & FolderObject @goModel(model: "observe/meta/metatypes.SnowflakeOutboundShare") { # payload """ The fully qualified name of the Snowflake share, for use in a consumer account. @@ -48,7 +49,7 @@ type SnowflakeShareOutbound implements WorkspaceObject & AuditedObject & FolderO updatedByInfo: UserInfo! @goField(forceResolver: true) } -input SnowflakeShareOutboundInput @goModel(model: "observe/meta/metatypes.SnowflakeShareOutboundInput") { +input SnowflakeOutboundShareInput @goModel(model: "observe/meta/metatypes.SnowflakeOutboundShareInput") { # payload # not in input: shareName: String! accounts: [SnowflakeAccountInput!]! @@ -69,8 +70,8 @@ input SnowflakeShareOutboundInput @goModel(model: "observe/meta/metatypes.Snowfl folderId: ObjectId } -type SnowflakeShareOutboundSearchResult @goModel(model: "observe/meta/metatypes.SnowflakeShareOutboundSearchResult") { - results: [SnowflakeShareOutbound!]! +type SnowflakeOutboundShareSearchResult @goModel(model: "observe/meta/metatypes.SnowflakeOutboundShareSearchResult") { + results: [SnowflakeOutboundShare!]! } type SnowflakeAccount @goModel(model: "observe/meta/metatypes.SnowflakeAccount") { # payload diff --git a/client/meta/genqlient.generated.go b/client/meta/genqlient.generated.go index fa5ee168..6927d76b 100644 --- a/client/meta/genqlient.generated.go +++ b/client/meta/genqlient.generated.go @@ -5954,8 +5954,8 @@ func (v *SnowflakeAccountInput) GetAccount() string { return v.Account } // GetOrganization returns SnowflakeAccountInput.Organization, and is useful for accessing the field via an interface. func (v *SnowflakeAccountInput) GetOrganization() string { return v.Organization } -// SnowflakeShareOutbound includes the GraphQL fields of SnowflakeShareOutbound requested by the fragment SnowflakeShareOutbound. -type SnowflakeShareOutbound struct { +// SnowflakeOutboundShare includes the GraphQL fields of SnowflakeOutboundShare requested by the fragment SnowflakeOutboundShare. +type SnowflakeOutboundShare struct { Id string `json:"id"` Name string `json:"name"` Description *string `json:"description"` @@ -5966,25 +5966,25 @@ type SnowflakeShareOutbound struct { Accounts []SnowflakeAccount `json:"accounts"` } -// GetId returns SnowflakeShareOutbound.Id, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutbound) GetId() string { return v.Id } +// GetId returns SnowflakeOutboundShare.Id, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShare) GetId() string { return v.Id } -// GetName returns SnowflakeShareOutbound.Name, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutbound) GetName() string { return v.Name } +// GetName returns SnowflakeOutboundShare.Name, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShare) GetName() string { return v.Name } -// GetDescription returns SnowflakeShareOutbound.Description, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutbound) GetDescription() *string { return v.Description } +// GetDescription returns SnowflakeOutboundShare.Description, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShare) GetDescription() *string { return v.Description } -// GetWorkspaceId returns SnowflakeShareOutbound.WorkspaceId, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutbound) GetWorkspaceId() string { return v.WorkspaceId } +// GetWorkspaceId returns SnowflakeOutboundShare.WorkspaceId, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShare) GetWorkspaceId() string { return v.WorkspaceId } -// GetShareName returns SnowflakeShareOutbound.ShareName, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutbound) GetShareName() string { return v.ShareName } +// GetShareName returns SnowflakeOutboundShare.ShareName, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShare) GetShareName() string { return v.ShareName } -// GetAccounts returns SnowflakeShareOutbound.Accounts, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutbound) GetAccounts() []SnowflakeAccount { return v.Accounts } +// GetAccounts returns SnowflakeOutboundShare.Accounts, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShare) GetAccounts() []SnowflakeAccount { return v.Accounts } -type SnowflakeShareOutboundInput struct { +type SnowflakeOutboundShareInput struct { Accounts []SnowflakeAccountInput `json:"accounts"` Name string `json:"name"` IconUrl *string `json:"iconUrl"` @@ -5993,23 +5993,23 @@ type SnowflakeShareOutboundInput struct { FolderId *string `json:"folderId"` } -// GetAccounts returns SnowflakeShareOutboundInput.Accounts, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutboundInput) GetAccounts() []SnowflakeAccountInput { return v.Accounts } +// GetAccounts returns SnowflakeOutboundShareInput.Accounts, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShareInput) GetAccounts() []SnowflakeAccountInput { return v.Accounts } -// GetName returns SnowflakeShareOutboundInput.Name, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutboundInput) GetName() string { return v.Name } +// GetName returns SnowflakeOutboundShareInput.Name, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShareInput) GetName() string { return v.Name } -// GetIconUrl returns SnowflakeShareOutboundInput.IconUrl, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutboundInput) GetIconUrl() *string { return v.IconUrl } +// GetIconUrl returns SnowflakeOutboundShareInput.IconUrl, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShareInput) GetIconUrl() *string { return v.IconUrl } -// GetDescription returns SnowflakeShareOutboundInput.Description, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutboundInput) GetDescription() *string { return v.Description } +// GetDescription returns SnowflakeOutboundShareInput.Description, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShareInput) GetDescription() *string { return v.Description } -// GetManagedById returns SnowflakeShareOutboundInput.ManagedById, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutboundInput) GetManagedById() *string { return v.ManagedById } +// GetManagedById returns SnowflakeOutboundShareInput.ManagedById, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShareInput) GetManagedById() *string { return v.ManagedById } -// GetFolderId returns SnowflakeShareOutboundInput.FolderId, and is useful for accessing the field via an interface. -func (v *SnowflakeShareOutboundInput) GetFolderId() *string { return v.FolderId } +// GetFolderId returns SnowflakeOutboundShareInput.FolderId, and is useful for accessing the field via an interface. +func (v *SnowflakeOutboundShareInput) GetFolderId() *string { return v.FolderId } type SourceLocInput struct { Row types.Int64Scalar `json:"row"` @@ -6919,17 +6919,17 @@ type __createRbacStatementInput struct { // GetConfig returns __createRbacStatementInput.Config, and is useful for accessing the field via an interface. func (v *__createRbacStatementInput) GetConfig() RbacStatementInput { return v.Config } -// __createSnowflakeShareOutboundInput is used internally by genqlient -type __createSnowflakeShareOutboundInput struct { +// __createSnowflakeOutboundShareInput is used internally by genqlient +type __createSnowflakeOutboundShareInput struct { WorkspaceId string `json:"workspaceId"` - Input SnowflakeShareOutboundInput `json:"input"` + Input SnowflakeOutboundShareInput `json:"input"` } -// GetWorkspaceId returns __createSnowflakeShareOutboundInput.WorkspaceId, and is useful for accessing the field via an interface. -func (v *__createSnowflakeShareOutboundInput) GetWorkspaceId() string { return v.WorkspaceId } +// GetWorkspaceId returns __createSnowflakeOutboundShareInput.WorkspaceId, and is useful for accessing the field via an interface. +func (v *__createSnowflakeOutboundShareInput) GetWorkspaceId() string { return v.WorkspaceId } -// GetInput returns __createSnowflakeShareOutboundInput.Input, and is useful for accessing the field via an interface. -func (v *__createSnowflakeShareOutboundInput) GetInput() SnowflakeShareOutboundInput { return v.Input } +// GetInput returns __createSnowflakeOutboundShareInput.Input, and is useful for accessing the field via an interface. +func (v *__createSnowflakeOutboundShareInput) GetInput() SnowflakeOutboundShareInput { return v.Input } // __createWorkspaceInput is used internally by genqlient type __createWorkspaceInput struct { @@ -7143,13 +7143,13 @@ type __deleteRbacStatementInput struct { // GetId returns __deleteRbacStatementInput.Id, and is useful for accessing the field via an interface. func (v *__deleteRbacStatementInput) GetId() string { return v.Id } -// __deleteSnowflakeShareOutboundInput is used internally by genqlient -type __deleteSnowflakeShareOutboundInput struct { +// __deleteSnowflakeOutboundShareInput is used internally by genqlient +type __deleteSnowflakeOutboundShareInput struct { Id string `json:"id"` } -// GetId returns __deleteSnowflakeShareOutboundInput.Id, and is useful for accessing the field via an interface. -func (v *__deleteSnowflakeShareOutboundInput) GetId() string { return v.Id } +// GetId returns __deleteSnowflakeOutboundShareInput.Id, and is useful for accessing the field via an interface. +func (v *__deleteSnowflakeOutboundShareInput) GetId() string { return v.Id } // __deleteWorksheetInput is used internally by genqlient type __deleteWorksheetInput struct { @@ -7387,13 +7387,13 @@ type __getRbacStatementInput struct { // GetId returns __getRbacStatementInput.Id, and is useful for accessing the field via an interface. func (v *__getRbacStatementInput) GetId() string { return v.Id } -// __getSnowflakeShareOutboundInput is used internally by genqlient -type __getSnowflakeShareOutboundInput struct { +// __getSnowflakeOutboundShareInput is used internally by genqlient +type __getSnowflakeOutboundShareInput struct { Id string `json:"id"` } -// GetId returns __getSnowflakeShareOutboundInput.Id, and is useful for accessing the field via an interface. -func (v *__getSnowflakeShareOutboundInput) GetId() string { return v.Id } +// GetId returns __getSnowflakeOutboundShareInput.Id, and is useful for accessing the field via an interface. +func (v *__getSnowflakeOutboundShareInput) GetId() string { return v.Id } // __getTerraformInput is used internally by genqlient type __getTerraformInput struct { @@ -7499,17 +7499,17 @@ func (v *__lookupMonitorInput) GetWorkspaceId() string { return v.WorkspaceId } // GetName returns __lookupMonitorInput.Name, and is useful for accessing the field via an interface. func (v *__lookupMonitorInput) GetName() string { return v.Name } -// __lookupSnowflakeShareOutboundInput is used internally by genqlient -type __lookupSnowflakeShareOutboundInput struct { +// __lookupSnowflakeOutboundShareInput is used internally by genqlient +type __lookupSnowflakeOutboundShareInput struct { Name string `json:"name"` WorkspaceId string `json:"workspaceId"` } -// GetName returns __lookupSnowflakeShareOutboundInput.Name, and is useful for accessing the field via an interface. -func (v *__lookupSnowflakeShareOutboundInput) GetName() string { return v.Name } +// GetName returns __lookupSnowflakeOutboundShareInput.Name, and is useful for accessing the field via an interface. +func (v *__lookupSnowflakeOutboundShareInput) GetName() string { return v.Name } -// GetWorkspaceId returns __lookupSnowflakeShareOutboundInput.WorkspaceId, and is useful for accessing the field via an interface. -func (v *__lookupSnowflakeShareOutboundInput) GetWorkspaceId() string { return v.WorkspaceId } +// GetWorkspaceId returns __lookupSnowflakeOutboundShareInput.WorkspaceId, and is useful for accessing the field via an interface. +func (v *__lookupSnowflakeOutboundShareInput) GetWorkspaceId() string { return v.WorkspaceId } // __lookupWorkspaceInput is used internally by genqlient type __lookupWorkspaceInput struct { @@ -7873,17 +7873,17 @@ func (v *__updateRbacStatementInput) GetId() string { return v.Id } // GetConfig returns __updateRbacStatementInput.Config, and is useful for accessing the field via an interface. func (v *__updateRbacStatementInput) GetConfig() RbacStatementInput { return v.Config } -// __updateSnowflakeShareOutboundInput is used internally by genqlient -type __updateSnowflakeShareOutboundInput struct { +// __updateSnowflakeOutboundShareInput is used internally by genqlient +type __updateSnowflakeOutboundShareInput struct { Id string `json:"id"` - Input SnowflakeShareOutboundInput `json:"input"` + Input SnowflakeOutboundShareInput `json:"input"` } -// GetId returns __updateSnowflakeShareOutboundInput.Id, and is useful for accessing the field via an interface. -func (v *__updateSnowflakeShareOutboundInput) GetId() string { return v.Id } +// GetId returns __updateSnowflakeOutboundShareInput.Id, and is useful for accessing the field via an interface. +func (v *__updateSnowflakeOutboundShareInput) GetId() string { return v.Id } -// GetInput returns __updateSnowflakeShareOutboundInput.Input, and is useful for accessing the field via an interface. -func (v *__updateSnowflakeShareOutboundInput) GetInput() SnowflakeShareOutboundInput { return v.Input } +// GetInput returns __updateSnowflakeOutboundShareInput.Input, and is useful for accessing the field via an interface. +func (v *__updateSnowflakeOutboundShareInput) GetInput() SnowflakeOutboundShareInput { return v.Input } // __updateWorkspaceInput is used internally by genqlient type __updateWorkspaceInput struct { @@ -8253,13 +8253,13 @@ type createRbacStatementResponse struct { // GetRbacStatement returns createRbacStatementResponse.RbacStatement, and is useful for accessing the field via an interface. func (v *createRbacStatementResponse) GetRbacStatement() RbacStatement { return v.RbacStatement } -// createSnowflakeShareOutboundResponse is returned by createSnowflakeShareOutbound on success. -type createSnowflakeShareOutboundResponse struct { - Share SnowflakeShareOutbound `json:"share"` +// createSnowflakeOutboundShareResponse is returned by createSnowflakeOutboundShare on success. +type createSnowflakeOutboundShareResponse struct { + Share SnowflakeOutboundShare `json:"share"` } -// GetShare returns createSnowflakeShareOutboundResponse.Share, and is useful for accessing the field via an interface. -func (v *createSnowflakeShareOutboundResponse) GetShare() SnowflakeShareOutbound { return v.Share } +// GetShare returns createSnowflakeOutboundShareResponse.Share, and is useful for accessing the field via an interface. +func (v *createSnowflakeOutboundShareResponse) GetShare() SnowflakeOutboundShare { return v.Share } // createWorkspaceResponse is returned by createWorkspace on success. type createWorkspaceResponse struct { @@ -8487,13 +8487,13 @@ type deleteRbacStatementResponse struct { // GetResultStatus returns deleteRbacStatementResponse.ResultStatus, and is useful for accessing the field via an interface. func (v *deleteRbacStatementResponse) GetResultStatus() ResultStatus { return v.ResultStatus } -// deleteSnowflakeShareOutboundResponse is returned by deleteSnowflakeShareOutbound on success. -type deleteSnowflakeShareOutboundResponse struct { +// deleteSnowflakeOutboundShareResponse is returned by deleteSnowflakeOutboundShare on success. +type deleteSnowflakeOutboundShareResponse struct { ResultStatus ResultStatus `json:"resultStatus"` } -// GetResultStatus returns deleteSnowflakeShareOutboundResponse.ResultStatus, and is useful for accessing the field via an interface. -func (v *deleteSnowflakeShareOutboundResponse) GetResultStatus() ResultStatus { return v.ResultStatus } +// GetResultStatus returns deleteSnowflakeOutboundShareResponse.ResultStatus, and is useful for accessing the field via an interface. +func (v *deleteSnowflakeOutboundShareResponse) GetResultStatus() ResultStatus { return v.ResultStatus } // deleteWorksheetResponse is returned by deleteWorksheet on success. type deleteWorksheetResponse struct { @@ -8913,13 +8913,13 @@ type getRbacStatementResponse struct { // GetRbacStatement returns getRbacStatementResponse.RbacStatement, and is useful for accessing the field via an interface. func (v *getRbacStatementResponse) GetRbacStatement() RbacStatement { return v.RbacStatement } -// getSnowflakeShareOutboundResponse is returned by getSnowflakeShareOutbound on success. -type getSnowflakeShareOutboundResponse struct { - Share SnowflakeShareOutbound `json:"share"` +// getSnowflakeOutboundShareResponse is returned by getSnowflakeOutboundShare on success. +type getSnowflakeOutboundShareResponse struct { + Share SnowflakeOutboundShare `json:"share"` } -// GetShare returns getSnowflakeShareOutboundResponse.Share, and is useful for accessing the field via an interface. -func (v *getSnowflakeShareOutboundResponse) GetShare() SnowflakeShareOutbound { return v.Share } +// GetShare returns getSnowflakeOutboundShareResponse.Share, and is useful for accessing the field via an interface. +func (v *getSnowflakeOutboundShareResponse) GetShare() SnowflakeOutboundShare { return v.Share } // getTerraformResponse is returned by getTerraform on success. type getTerraformResponse struct { @@ -9084,23 +9084,23 @@ type lookupMonitorResponse struct { // GetMonitor returns lookupMonitorResponse.Monitor, and is useful for accessing the field via an interface. func (v *lookupMonitorResponse) GetMonitor() *lookupMonitorMonitorProject { return v.Monitor } -// lookupSnowflakeShareOutboundResponse is returned by lookupSnowflakeShareOutbound on success. -type lookupSnowflakeShareOutboundResponse struct { - Shares lookupSnowflakeShareOutboundSharesSnowflakeShareOutboundSearchResult `json:"shares"` +// lookupSnowflakeOutboundShareResponse is returned by lookupSnowflakeOutboundShare on success. +type lookupSnowflakeOutboundShareResponse struct { + Shares lookupSnowflakeOutboundShareSharesSnowflakeOutboundShareSearchResult `json:"shares"` } -// GetShares returns lookupSnowflakeShareOutboundResponse.Shares, and is useful for accessing the field via an interface. -func (v *lookupSnowflakeShareOutboundResponse) GetShares() lookupSnowflakeShareOutboundSharesSnowflakeShareOutboundSearchResult { +// GetShares returns lookupSnowflakeOutboundShareResponse.Shares, and is useful for accessing the field via an interface. +func (v *lookupSnowflakeOutboundShareResponse) GetShares() lookupSnowflakeOutboundShareSharesSnowflakeOutboundShareSearchResult { return v.Shares } -// lookupSnowflakeShareOutboundSharesSnowflakeShareOutboundSearchResult includes the requested fields of the GraphQL type SnowflakeShareOutboundSearchResult. -type lookupSnowflakeShareOutboundSharesSnowflakeShareOutboundSearchResult struct { - Results []SnowflakeShareOutbound `json:"results"` +// lookupSnowflakeOutboundShareSharesSnowflakeOutboundShareSearchResult includes the requested fields of the GraphQL type SnowflakeOutboundShareSearchResult. +type lookupSnowflakeOutboundShareSharesSnowflakeOutboundShareSearchResult struct { + Results []SnowflakeOutboundShare `json:"results"` } -// GetResults returns lookupSnowflakeShareOutboundSharesSnowflakeShareOutboundSearchResult.Results, and is useful for accessing the field via an interface. -func (v *lookupSnowflakeShareOutboundSharesSnowflakeShareOutboundSearchResult) GetResults() []SnowflakeShareOutbound { +// GetResults returns lookupSnowflakeOutboundShareSharesSnowflakeOutboundShareSearchResult.Results, and is useful for accessing the field via an interface. +func (v *lookupSnowflakeOutboundShareSharesSnowflakeOutboundShareSearchResult) GetResults() []SnowflakeOutboundShare { return v.Results } @@ -9538,13 +9538,13 @@ type updateRbacStatementResponse struct { // GetRbacStatement returns updateRbacStatementResponse.RbacStatement, and is useful for accessing the field via an interface. func (v *updateRbacStatementResponse) GetRbacStatement() RbacStatement { return v.RbacStatement } -// updateSnowflakeShareOutboundResponse is returned by updateSnowflakeShareOutbound on success. -type updateSnowflakeShareOutboundResponse struct { - Share SnowflakeShareOutbound `json:"share"` +// updateSnowflakeOutboundShareResponse is returned by updateSnowflakeOutboundShare on success. +type updateSnowflakeOutboundShareResponse struct { + Share SnowflakeOutboundShare `json:"share"` } -// GetShare returns updateSnowflakeShareOutboundResponse.Share, and is useful for accessing the field via an interface. -func (v *updateSnowflakeShareOutboundResponse) GetShare() SnowflakeShareOutbound { return v.Share } +// GetShare returns updateSnowflakeOutboundShareResponse.Share, and is useful for accessing the field via an interface. +func (v *updateSnowflakeOutboundShareResponse) GetShare() SnowflakeOutboundShare { return v.Share } // updateWorkspaceResponse is returned by updateWorkspace on success. type updateWorkspaceResponse struct { @@ -10834,21 +10834,21 @@ fragment RbacStatement on RbacStatement { return &data, err } -func createSnowflakeShareOutbound( +func createSnowflakeOutboundShare( ctx context.Context, client graphql.Client, workspaceId string, - input SnowflakeShareOutboundInput, -) (*createSnowflakeShareOutboundResponse, error) { + input SnowflakeOutboundShareInput, +) (*createSnowflakeOutboundShareResponse, error) { req := &graphql.Request{ - OpName: "createSnowflakeShareOutbound", + OpName: "createSnowflakeOutboundShare", Query: ` -mutation createSnowflakeShareOutbound ($workspaceId: ObjectId!, $input: SnowflakeShareOutboundInput!) { - share: createSnowflakeShareOutbound(workspaceId: $workspaceId, input: $input) { - ... SnowflakeShareOutbound +mutation createSnowflakeOutboundShare ($workspaceId: ObjectId!, $input: SnowflakeOutboundShareInput!) { + share: createSnowflakeOutboundShare(workspaceId: $workspaceId, input: $input) { + ... SnowflakeOutboundShare } } -fragment SnowflakeShareOutbound on SnowflakeShareOutbound { +fragment SnowflakeOutboundShare on SnowflakeOutboundShare { id name description @@ -10863,14 +10863,14 @@ fragment SnowflakeAccount on SnowflakeAccount { account } `, - Variables: &__createSnowflakeShareOutboundInput{ + Variables: &__createSnowflakeOutboundShareInput{ WorkspaceId: workspaceId, Input: input, }, } var err error - var data createSnowflakeShareOutboundResponse + var data createSnowflakeOutboundShareResponse resp := &graphql.Response{Data: &data} err = client.MakeRequest( @@ -11847,16 +11847,16 @@ fragment ResultStatus on ResultStatus { return &data, err } -func deleteSnowflakeShareOutbound( +func deleteSnowflakeOutboundShare( ctx context.Context, client graphql.Client, id string, -) (*deleteSnowflakeShareOutboundResponse, error) { +) (*deleteSnowflakeOutboundShareResponse, error) { req := &graphql.Request{ - OpName: "deleteSnowflakeShareOutbound", + OpName: "deleteSnowflakeOutboundShare", Query: ` -mutation deleteSnowflakeShareOutbound ($id: ObjectId!) { - resultStatus: deleteSnowflakeShareOutbound(id: $id) { +mutation deleteSnowflakeOutboundShare ($id: ObjectId!) { + resultStatus: deleteSnowflakeOutboundShare(id: $id) { ... ResultStatus } } @@ -11866,13 +11866,13 @@ fragment ResultStatus on ResultStatus { detailedInfo } `, - Variables: &__deleteSnowflakeShareOutboundInput{ + Variables: &__deleteSnowflakeOutboundShareInput{ Id: id, }, } var err error - var data deleteSnowflakeShareOutboundResponse + var data deleteSnowflakeOutboundShareResponse resp := &graphql.Response{Data: &data} err = client.MakeRequest( @@ -13549,20 +13549,20 @@ fragment RbacStatement on RbacStatement { return &data, err } -func getSnowflakeShareOutbound( +func getSnowflakeOutboundShare( ctx context.Context, client graphql.Client, id string, -) (*getSnowflakeShareOutboundResponse, error) { +) (*getSnowflakeOutboundShareResponse, error) { req := &graphql.Request{ - OpName: "getSnowflakeShareOutbound", + OpName: "getSnowflakeOutboundShare", Query: ` -query getSnowflakeShareOutbound ($id: ObjectId!) { - share: snowflakeShareOutbound(id: $id) { - ... SnowflakeShareOutbound +query getSnowflakeOutboundShare ($id: ObjectId!) { + share: snowflakeOutboundShare(id: $id) { + ... SnowflakeOutboundShare } } -fragment SnowflakeShareOutbound on SnowflakeShareOutbound { +fragment SnowflakeOutboundShare on SnowflakeOutboundShare { id name description @@ -13577,13 +13577,13 @@ fragment SnowflakeAccount on SnowflakeAccount { account } `, - Variables: &__getSnowflakeShareOutboundInput{ + Variables: &__getSnowflakeOutboundShareInput{ Id: id, }, } var err error - var data getSnowflakeShareOutboundResponse + var data getSnowflakeOutboundShareResponse resp := &graphql.Response{Data: &data} err = client.MakeRequest( @@ -14303,23 +14303,23 @@ fragment StageQuery on StageQuery { return &data, err } -func lookupSnowflakeShareOutbound( +func lookupSnowflakeOutboundShare( ctx context.Context, client graphql.Client, name string, workspaceId string, -) (*lookupSnowflakeShareOutboundResponse, error) { +) (*lookupSnowflakeOutboundShareResponse, error) { req := &graphql.Request{ - OpName: "lookupSnowflakeShareOutbound", + OpName: "lookupSnowflakeOutboundShare", Query: ` -query lookupSnowflakeShareOutbound ($name: String!, $workspaceId: ObjectId!) { - shares: searchSnowflakeShareOutbound(nameExact: $name, workspaceId: $workspaceId) { +query lookupSnowflakeOutboundShare ($name: String!, $workspaceId: ObjectId!) { + shares: searchSnowflakeOutboundShare(nameExact: $name, workspaceId: $workspaceId) { results { - ... SnowflakeShareOutbound + ... SnowflakeOutboundShare } } } -fragment SnowflakeShareOutbound on SnowflakeShareOutbound { +fragment SnowflakeOutboundShare on SnowflakeOutboundShare { id name description @@ -14334,14 +14334,14 @@ fragment SnowflakeAccount on SnowflakeAccount { account } `, - Variables: &__lookupSnowflakeShareOutboundInput{ + Variables: &__lookupSnowflakeOutboundShareInput{ Name: name, WorkspaceId: workspaceId, }, } var err error - var data lookupSnowflakeShareOutboundResponse + var data lookupSnowflakeOutboundShareResponse resp := &graphql.Response{Data: &data} err = client.MakeRequest( @@ -16135,21 +16135,21 @@ fragment RbacStatement on RbacStatement { return &data, err } -func updateSnowflakeShareOutbound( +func updateSnowflakeOutboundShare( ctx context.Context, client graphql.Client, id string, - input SnowflakeShareOutboundInput, -) (*updateSnowflakeShareOutboundResponse, error) { + input SnowflakeOutboundShareInput, +) (*updateSnowflakeOutboundShareResponse, error) { req := &graphql.Request{ - OpName: "updateSnowflakeShareOutbound", + OpName: "updateSnowflakeOutboundShare", Query: ` -mutation updateSnowflakeShareOutbound ($id: ObjectId!, $input: SnowflakeShareOutboundInput!) { - share: updateSnowflakeShareOutbound(id: $id, input: $input) { - ... SnowflakeShareOutbound +mutation updateSnowflakeOutboundShare ($id: ObjectId!, $input: SnowflakeOutboundShareInput!) { + share: updateSnowflakeOutboundShare(id: $id, input: $input) { + ... SnowflakeOutboundShare } } -fragment SnowflakeShareOutbound on SnowflakeShareOutbound { +fragment SnowflakeOutboundShare on SnowflakeOutboundShare { id name description @@ -16164,14 +16164,14 @@ fragment SnowflakeAccount on SnowflakeAccount { account } `, - Variables: &__updateSnowflakeShareOutboundInput{ + Variables: &__updateSnowflakeOutboundShareInput{ Id: id, Input: input, }, } var err error - var data updateSnowflakeShareOutboundResponse + var data updateSnowflakeOutboundShareResponse resp := &graphql.Response{Data: &data} err = client.MakeRequest( diff --git a/client/meta/snowflakeoutboundshare.go b/client/meta/snowflakeoutboundshare.go new file mode 100644 index 00000000..077d81e4 --- /dev/null +++ b/client/meta/snowflakeoutboundshare.go @@ -0,0 +1,63 @@ +package meta + +import ( + "context" + "fmt" + + oid "github.com/observeinc/terraform-provider-observe/client/oid" +) + +type snowflakeOutboundShareResponse interface { + GetShare() SnowflakeOutboundShare +} + +func snowflakeOutboundShareOrError(r snowflakeOutboundShareResponse, err error) (*SnowflakeOutboundShare, error) { + if err != nil { + return nil, err + } + result := r.GetShare() + return &result, nil +} + +func (client *Client) GetSnowflakeOutboundShare(ctx context.Context, id string) (*SnowflakeOutboundShare, error) { + resp, err := getSnowflakeOutboundShare(ctx, client.Gql, id) + return snowflakeOutboundShareOrError(resp, err) +} + +func (client *Client) LookupSnowflakeOutboundShare(ctx context.Context, name string, workspaceId string) (*SnowflakeOutboundShare, error) { + resp, err := lookupSnowflakeOutboundShare(ctx, client.Gql, name, workspaceId) + + if err != nil { + return nil, err + } + + results := resp.Shares.Results + + if len(results) == 0 { + return nil, fmt.Errorf("share not found with name %q in workspace %q", name, workspaceId) + } + + return &results[0], nil +} + +func (client *Client) CreateSnowflakeOutboundShare(ctx context.Context, workspaceId string, input *SnowflakeOutboundShareInput) (*SnowflakeOutboundShare, error) { + resp, err := createSnowflakeOutboundShare(ctx, client.Gql, workspaceId, *input) + return snowflakeOutboundShareOrError(resp, err) +} + +func (client *Client) UpdateSnowflakeOutboundShare(ctx context.Context, id string, input *SnowflakeOutboundShareInput) (*SnowflakeOutboundShare, error) { + resp, err := updateSnowflakeOutboundShare(ctx, client.Gql, id, *input) + return snowflakeOutboundShareOrError(resp, err) +} + +func (client *Client) DeleteSnowflakeOutboundShare(ctx context.Context, id string) error { + resp, err := deleteSnowflakeOutboundShare(ctx, client.Gql, id) + return resultStatusError(resp, err) +} + +func (p *SnowflakeOutboundShare) Oid() *oid.OID { + return &oid.OID{ + Id: p.Id, + Type: oid.TypeSnowflakeOutboundShare, + } +} diff --git a/client/meta/snowflakeshareoutbound.go b/client/meta/snowflakeshareoutbound.go deleted file mode 100644 index 9bf9f65b..00000000 --- a/client/meta/snowflakeshareoutbound.go +++ /dev/null @@ -1,63 +0,0 @@ -package meta - -import ( - "context" - "fmt" - - oid "github.com/observeinc/terraform-provider-observe/client/oid" -) - -type snowflakeShareOutboundResponse interface { - GetShare() SnowflakeShareOutbound -} - -func snowflakeShareOutboundOrError(r snowflakeShareOutboundResponse, err error) (*SnowflakeShareOutbound, error) { - if err != nil { - return nil, err - } - result := r.GetShare() - return &result, nil -} - -func (client *Client) GetSnowflakeShareOutbound(ctx context.Context, id string) (*SnowflakeShareOutbound, error) { - resp, err := getSnowflakeShareOutbound(ctx, client.Gql, id) - return snowflakeShareOutboundOrError(resp, err) -} - -func (client *Client) LookupSnowflakeShareOutbound(ctx context.Context, name string, workspaceId string) (*SnowflakeShareOutbound, error) { - resp, err := lookupSnowflakeShareOutbound(ctx, client.Gql, name, workspaceId) - - if err != nil { - return nil, err - } - - results := resp.Shares.Results - - if len(results) == 0 { - return nil, fmt.Errorf("share not found with name %q in workspace %q", name, workspaceId) - } - - return &results[0], nil -} - -func (client *Client) CreateSnowflakeShareOutbound(ctx context.Context, workspaceId string, input *SnowflakeShareOutboundInput) (*SnowflakeShareOutbound, error) { - resp, err := createSnowflakeShareOutbound(ctx, client.Gql, workspaceId, *input) - return snowflakeShareOutboundOrError(resp, err) -} - -func (client *Client) UpdateSnowflakeShareOutbound(ctx context.Context, id string, input *SnowflakeShareOutboundInput) (*SnowflakeShareOutbound, error) { - resp, err := updateSnowflakeShareOutbound(ctx, client.Gql, id, *input) - return snowflakeShareOutboundOrError(resp, err) -} - -func (client *Client) DeleteSnowflakeShareOutbound(ctx context.Context, id string) error { - resp, err := deleteSnowflakeShareOutbound(ctx, client.Gql, id) - return resultStatusError(resp, err) -} - -func (p *SnowflakeShareOutbound) Oid() *oid.OID { - return &oid.OID{ - Id: p.Id, - Type: oid.TypeSnowflakeShareOutbound, - } -} diff --git a/client/oid/oid.go b/client/oid/oid.go index 8f0fd1b1..4185d4e1 100644 --- a/client/oid/oid.go +++ b/client/oid/oid.go @@ -46,7 +46,7 @@ const ( TypeRbacGroup Type = "rbacgroup" TypeRbacGroupmember Type = "rbacgroupmember" TypeRbacStatement Type = "rbacstatement" - TypeSnowflakeShareOutbound Type = "snowflakeshareoutbound" + TypeSnowflakeOutboundShare Type = "snowflakeoutboundshare" TypeDatasetOutboundShare Type = "datasetoutboundshare" ) @@ -78,7 +78,7 @@ func (t Type) IsValid() bool { case TypeRbacGroup: case TypeRbacGroupmember: case TypeRbacStatement: - case TypeSnowflakeShareOutbound: + case TypeSnowflakeOutboundShare: case TypeDatasetOutboundShare: default: return false @@ -274,6 +274,6 @@ func RbacStatementOid(id string) OID { return OID{Id: id, Type: TypeRbacStatement} } -func SnowflakeShareOutboundOid(id string) OID { - return OID{Id: id, Type: TypeSnowflakeShareOutbound} +func SnowflakeOutboundShareOid(id string) OID { + return OID{Id: id, Type: TypeSnowflakeOutboundShare} } diff --git a/docs/resources/snowflake_share_outbound.md b/docs/resources/snowflake_outbound_share.md similarity index 92% rename from docs/resources/snowflake_share_outbound.md rename to docs/resources/snowflake_outbound_share.md index 5a8ff8cd..ae12f901 100644 --- a/docs/resources/snowflake_share_outbound.md +++ b/docs/resources/snowflake_outbound_share.md @@ -1,11 +1,11 @@ --- # generated by https://github.com/hashicorp/terraform-plugin-docs -page_title: "observe_snowflake_share_outbound Resource - terraform-provider-observe" +page_title: "observe_snowflake_outbound_share Resource - terraform-provider-observe" subcategory: "" description: |- Manages an outbound Snowflake share, which allows you to share datasets with an existing Snowflake account. --- -# observe_snowflake_share_outbound +# observe_snowflake_outbound_share Manages an outbound Snowflake share, which allows you to share datasets with an existing Snowflake account. diff --git a/observe/observe_sweeper_test.go b/observe/observe_sweeper_test.go index 199f595a..f7a5f03e 100644 --- a/observe/observe_sweeper_test.go +++ b/observe/observe_sweeper_test.go @@ -101,9 +101,9 @@ func init() { Name: "observe_filedrop", F: filedropSweeperFunc, }) - resource.AddTestSweepers("observe_snowflake_share_outbound", &resource.Sweeper{ - Name: "observe_snowflake_share_outbound", - F: snowflakeShareOutboundSweeper, + resource.AddTestSweepers("observe_snowflake_outbound_share", &resource.Sweeper{ + Name: "observe_snowflake_outbound_share", + F: snowflakeOutboundShareSweeper, Dependencies: []string{ "observe_dataset_outbound_share", }, @@ -730,7 +730,7 @@ func filedropSweeperFunc(pattern string) error { return nil } -func snowflakeShareOutboundSweeper(pattern string) error { +func snowflakeOutboundShareSweeper(pattern string) error { client, err := sharedClient(pattern) if err != nil { return err @@ -745,8 +745,8 @@ func snowflakeShareOutboundSweeper(pattern string) error { for _, workspace := range workspaces { result, err := client.Meta.Run(ctx, ` - query snowflakeSharesOutbound($workspaceId: ObjectId!) { - searchSnowflakeShareOutbound(workspaceId: $workspaceId) { + query snowflakeOutboundShares($workspaceId: ObjectId!) { + searchSnowflakeOutboundShare(workspaceId: $workspaceId) { results { id name @@ -760,7 +760,7 @@ func snowflakeShareOutboundSweeper(pattern string) error { return fmt.Errorf("failed to lookup snowflake outbound shares: %w", err) } - result = result["searchSnowflakeShareOutbound"].(map[string]interface{}) + result = result["searchSnowflakeOutboundShare"].(map[string]interface{}) for _, i := range result["results"].([]interface{}) { var ( @@ -771,7 +771,7 @@ func snowflakeShareOutboundSweeper(pattern string) error { if client.MatchName(name) { log.Printf("[WARN] Deleting snowflake outbound share %s [id=%s]\n", name, id) - if err := client.DeleteSnowflakeShareOutbound(ctx, id); err != nil { + if err := client.DeleteSnowflakeOutboundShare(ctx, id); err != nil { return err } } diff --git a/observe/provider.go b/observe/provider.go index 220b9b7d..92243426 100644 --- a/observe/provider.go +++ b/observe/provider.go @@ -162,7 +162,7 @@ func Provider() *schema.Provider { "observe_rbac_group_member": resourceRbacGroupmember(), "observe_rbac_statement": resourceRbacStatement(), "observe_filedrop": resourceFiledrop(), - "observe_snowflake_share_outbound": resourceSnowflakeShareOutbound(), + "observe_snowflake_outbound_share": resourceSnowflakeOutboundShare(), "observe_dataset_outbound_share": resourceDatasetOutboundShare(), }, TerraformVersion: version.ProviderVersion, diff --git a/observe/resource_dataset_outbound_share.go b/observe/resource_dataset_outbound_share.go index 39a4f206..2d2c3648 100644 --- a/observe/resource_dataset_outbound_share.go +++ b/observe/resource_dataset_outbound_share.go @@ -72,7 +72,7 @@ func resourceDatasetOutboundShare() *schema.Resource { Type: schema.TypeString, Required: true, ForceNew: true, - ValidateDiagFunc: validateOID(oid.TypeSnowflakeShareOutbound), + ValidateDiagFunc: validateOID(oid.TypeSnowflakeOutboundShare), Description: "The OID of the Observe Snowflake outbound share where the dataset will be shared", }, "schema_name": { @@ -227,7 +227,7 @@ func resourceDatasetOutboundShareRead(ctx context.Context, d *schema.ResourceDat diags = append(diags, diag.FromErr(err)...) } - if err := d.Set("outbound_share", oid.SnowflakeShareOutboundOid(datasetShare.OutboundShareID).String()); err != nil { + if err := d.Set("outbound_share", oid.SnowflakeOutboundShareOid(datasetShare.OutboundShareID).String()); err != nil { diags = append(diags, diag.FromErr(err)...) } diff --git a/observe/resource_dataset_outbound_share_test.go b/observe/resource_dataset_outbound_share_test.go index 4edef0b9..6f0d0982 100644 --- a/observe/resource_dataset_outbound_share_test.go +++ b/observe/resource_dataset_outbound_share_test.go @@ -17,7 +17,7 @@ func TestAccObserveDatasetOutboundShare(t *testing.T) { Steps: []resource.TestStep{ { Config: fmt.Sprintf(configPreamble+datastreamConfigPreamble+` - resource "observe_snowflake_share_outbound" "test" { + resource "observe_snowflake_outbound_share" "test" { workspace = data.observe_workspace.default.oid name = "%[1]s" description = "test description" @@ -44,7 +44,7 @@ func TestAccObserveDatasetOutboundShare(t *testing.T) { description = "test description" name = "%[1]s" dataset = observe_dataset.test.oid - outbound_share = observe_snowflake_share_outbound.test.oid + outbound_share = observe_snowflake_outbound_share.test.oid schema_name = "%[1]s" view_name = "%[1]s" freshness_goal = "15m" @@ -58,7 +58,7 @@ func TestAccObserveDatasetOutboundShare(t *testing.T) { // TODO: implement custom TestCheckFunc that can compare OID without version // This OID has no version, while observe_dataset does, preventing direct comparison with TestCheckResourceAttrPair resource.TestCheckResourceAttrSet("observe_dataset_outbound_share.test", "dataset"), - resource.TestCheckResourceAttrPair("observe_dataset_outbound_share.test", "outbound_share", "observe_snowflake_share_outbound.test", "oid"), + resource.TestCheckResourceAttrPair("observe_dataset_outbound_share.test", "outbound_share", "observe_snowflake_outbound_share.test", "oid"), resource.TestCheckResourceAttr("observe_dataset_outbound_share.test", "schema_name", randomPrefix), resource.TestCheckResourceAttr("observe_dataset_outbound_share.test", "view_name", randomPrefix), resource.TestCheckResourceAttr("observe_dataset_outbound_share.test", "freshness_goal", "15m0s"), diff --git a/observe/resource_snowflake_share_outbound.go b/observe/resource_snowflake_outbound_share.go similarity index 76% rename from observe/resource_snowflake_share_outbound.go rename to observe/resource_snowflake_outbound_share.go index 29a4717c..c2d64f95 100644 --- a/observe/resource_snowflake_share_outbound.go +++ b/observe/resource_snowflake_outbound_share.go @@ -12,13 +12,13 @@ import ( "github.com/observeinc/terraform-provider-observe/observe/descriptions" ) -func resourceSnowflakeShareOutbound() *schema.Resource { +func resourceSnowflakeOutboundShare() *schema.Resource { return &schema.Resource{ Description: "Manages an outbound Snowflake share, which allows you to share datasets with an existing Snowflake account.", - CreateContext: resourceSnowflakeShareOutboundCreate, - ReadContext: resourceSnowflakeShareOutboundRead, - UpdateContext: resourceSnowflakeShareOutboundUpdate, - DeleteContext: resourceSnowflakeShareOutboundDelete, + CreateContext: resourceSnowflakeOutboundShareCreate, + ReadContext: resourceSnowflakeOutboundShareRead, + UpdateContext: resourceSnowflakeOutboundShareUpdate, + DeleteContext: resourceSnowflakeOutboundShareDelete, Importer: &schema.ResourceImporter{ StateContext: schema.ImportStatePassthroughContext, }, @@ -72,10 +72,10 @@ func resourceSnowflakeShareOutbound() *schema.Resource { } } -func newSnowflakeShareOutbound(d *schema.ResourceData) (*gql.SnowflakeShareOutboundInput, diag.Diagnostics) { - input := &gql.SnowflakeShareOutboundInput{ +func newSnowflakeOutboundShare(d *schema.ResourceData) (*gql.SnowflakeOutboundShareInput, diag.Diagnostics) { + input := &gql.SnowflakeOutboundShareInput{ Name: d.Get("name").(string), - Accounts: expandSnowflakeShareOutboundAccounts(d.Get("account").(*schema.Set).List()), + Accounts: expandSnowflakeOutboundShareAccounts(d.Get("account").(*schema.Set).List()), } if v, ok := d.GetOk("description"); ok { @@ -85,7 +85,7 @@ func newSnowflakeShareOutbound(d *schema.ResourceData) (*gql.SnowflakeShareOutbo return input, nil } -func expandSnowflakeShareOutboundAccounts(in []interface{}) []gql.SnowflakeAccountInput { +func expandSnowflakeOutboundShareAccounts(in []interface{}) []gql.SnowflakeAccountInput { out := make([]gql.SnowflakeAccountInput, 0) for _, v := range in { @@ -100,7 +100,7 @@ func expandSnowflakeShareOutboundAccounts(in []interface{}) []gql.SnowflakeAccou } -func resourceSnowflakeShareOutboundCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceSnowflakeOutboundShareCreate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { client := m.(*observe.Client) id, err := oid.NewOID(d.Get("workspace").(string)) @@ -108,25 +108,25 @@ func resourceSnowflakeShareOutboundCreate(ctx context.Context, d *schema.Resourc return diag.FromErr(err) } - input, diags := newSnowflakeShareOutbound(d) + input, diags := newSnowflakeOutboundShare(d) if diags.HasError() { return diags } - share, err := client.CreateSnowflakeShareOutbound(ctx, id.Id, input) + share, err := client.CreateSnowflakeOutboundShare(ctx, id.Id, input) if err != nil { return diag.Errorf("failed to create snowflake outbound share: %s", err) } d.SetId(share.Id) - return append(diags, resourceSnowflakeShareOutboundRead(ctx, d, m)...) + return append(diags, resourceSnowflakeOutboundShareRead(ctx, d, m)...) } -func resourceSnowflakeShareOutboundRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceSnowflakeOutboundShareRead(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { client := m.(*observe.Client) - share, err := client.GetSnowflakeShareOutbound(ctx, d.Id()) + share, err := client.GetSnowflakeOutboundShare(ctx, d.Id()) if err != nil { return diag.FromErr(err) } @@ -151,7 +151,7 @@ func resourceSnowflakeShareOutboundRead(ctx context.Context, d *schema.ResourceD } } - if err := d.Set("account", flattenSnowflakeShareOutboundAccounts(share.Accounts)); err != nil { + if err := d.Set("account", flattenSnowflakeOutboundShareAccounts(share.Accounts)); err != nil { diags = append(diags, diag.FromErr(err)...) } @@ -162,7 +162,7 @@ func resourceSnowflakeShareOutboundRead(ctx context.Context, d *schema.ResourceD return diags } -func flattenSnowflakeShareOutboundAccounts(accounts []gql.SnowflakeAccount) []map[string]interface{} { +func flattenSnowflakeOutboundShareAccounts(accounts []gql.SnowflakeAccount) []map[string]interface{} { var out []map[string]interface{} for _, account := range accounts { @@ -175,26 +175,26 @@ func flattenSnowflakeShareOutboundAccounts(accounts []gql.SnowflakeAccount) []ma return out } -func resourceSnowflakeShareOutboundUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceSnowflakeOutboundShareUpdate(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { client := m.(*observe.Client) - input, diags := newSnowflakeShareOutbound(d) + input, diags := newSnowflakeOutboundShare(d) if diags.HasError() { return diags } - _, err := client.UpdateSnowflakeShareOutbound(ctx, d.Id(), input) + _, err := client.UpdateSnowflakeOutboundShare(ctx, d.Id(), input) if err != nil { return diag.Errorf("failed to update snowflake outbound share: %s", err) } - return append(diags, resourceSnowflakeShareOutboundRead(ctx, d, m)...) + return append(diags, resourceSnowflakeOutboundShareRead(ctx, d, m)...) } -func resourceSnowflakeShareOutboundDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { +func resourceSnowflakeOutboundShareDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics { client := m.(*observe.Client) - err := client.DeleteSnowflakeShareOutbound(ctx, d.Id()) + err := client.DeleteSnowflakeOutboundShare(ctx, d.Id()) if err != nil { return diag.Errorf("failed to delete snowflake outbound share: %s", err) } diff --git a/observe/resource_snowflake_share_outbound_test.go b/observe/resource_snowflake_outbound_share_test.go similarity index 54% rename from observe/resource_snowflake_share_outbound_test.go rename to observe/resource_snowflake_outbound_share_test.go index 4baa7bd3..358e415d 100644 --- a/observe/resource_snowflake_share_outbound_test.go +++ b/observe/resource_snowflake_outbound_share_test.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" ) -func TestAccObserveSnowflakeShareOutbound(t *testing.T) { +func TestAccObserveSnowflakeOutboundShare(t *testing.T) { randomPrefix := acctest.RandomWithPrefix("tf") resource.ParallelTest(t, resource.TestCase{ @@ -17,7 +17,7 @@ func TestAccObserveSnowflakeShareOutbound(t *testing.T) { Steps: []resource.TestStep{ { Config: fmt.Sprintf(configPreamble+` - resource "observe_snowflake_share_outbound" "test" { + resource "observe_snowflake_outbound_share" "test" { workspace = data.observe_workspace.default.oid name = "%[1]s" description = "test description" @@ -29,11 +29,11 @@ func TestAccObserveSnowflakeShareOutbound(t *testing.T) { } `, randomPrefix), Check: resource.ComposeTestCheckFunc( - resource.TestCheckResourceAttrSet("observe_snowflake_share_outbound.test", "workspace"), - resource.TestCheckResourceAttrSet("observe_snowflake_share_outbound.test", "oid"), - resource.TestCheckResourceAttr("observe_snowflake_share_outbound.test", "name", randomPrefix), - resource.TestCheckResourceAttr("observe_snowflake_share_outbound.test", "description", "test description"), - resource.TestCheckResourceAttrSet("observe_snowflake_share_outbound.test", "share_name"), + resource.TestCheckResourceAttrSet("observe_snowflake_outbound_share.test", "workspace"), + resource.TestCheckResourceAttrSet("observe_snowflake_outbound_share.test", "oid"), + resource.TestCheckResourceAttr("observe_snowflake_outbound_share.test", "name", randomPrefix), + resource.TestCheckResourceAttr("observe_snowflake_outbound_share.test", "description", "test description"), + resource.TestCheckResourceAttrSet("observe_snowflake_outbound_share.test", "share_name"), ), }, },