Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

New resource: dataset_outbound_share #54

Merged
merged 14 commits into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions client/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1263,3 +1263,34 @@ func (c *Client) DeleteSnowflakeShareOutbound(ctx context.Context, id string) er

return c.Meta.DeleteSnowflakeShareOutbound(ctx, id)
}

func (c *Client) GetDatasetOutboundShare(ctx context.Context, id string) (*meta.DatasetOutboundShare, error) {
return c.Meta.GetDatasetOutboundShare(ctx, id)
}

func (c *Client) CreateDatasetOutboundShare(ctx context.Context, workspaceId string, datasetId string, shareId string, input *meta.DatasetOutboundShareInput) (*meta.DatasetOutboundShare, error) {
if !c.Flags[flagObs2110] {
c.obs2110.Lock()
defer c.obs2110.Unlock()
}

return c.Meta.CreateDatasetOutboundShare(ctx, workspaceId, datasetId, shareId, input)
}

func (c *Client) UpdateDatasetOutboundShare(ctx context.Context, id string, input *meta.DatasetOutboundShareInput) (*meta.DatasetOutboundShare, error) {
if !c.Flags[flagObs2110] {
c.obs2110.Lock()
defer c.obs2110.Unlock()
}

return c.Meta.UpdateDatasetOutboundShare(ctx, id, input)
}

func (c *Client) DeleteDatasetOutboundShare(ctx context.Context, id string) error {
if !c.Flags[flagObs2110] {
c.obs2110.Lock()
defer c.obs2110.Unlock()
}

return c.Meta.DeleteDatasetOutboundShare(ctx, id)
}
63 changes: 63 additions & 0 deletions client/internal/meta/operation/dataset_outbound_share.graphql
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
fragment DatasetOutboundShare on DatasetOutboundShare {
id
name
description
workspaceId
folderId

datasetID
outboundShareID

schemaName
viewName
freshnessGoal

status {
state
error
}
}

query getDatasetOutboundShare($id: ObjectId!) {
# @genqlient(flatten: true)
datasetOutboundShare(id: $id) {
...DatasetOutboundShare
}
}

mutation createDatasetOutboundShare(
$workspaceId: ObjectId!,
$datasetID: ObjectId!,
$outboundShareID: ObjectId!,
$input: DatasetOutboundShareInput!
) {
# @genqlient(flatten: true)
datasetOutboundShare: createDatasetOutboundShare(
workspaceId: $workspaceId,
datasetID: $datasetID,
outboundShareID: $outboundShareID,
input: $input
) {
...DatasetOutboundShare
}
}

mutation updateDatasetOutboundShare(
$id: ObjectId!,
$input: DatasetOutboundShareInput!
) {
# @genqlient(flatten: true)
datasetOutboundShare: updateDatasetOutboundShare(
id: $id,
input: $input
) {
...DatasetOutboundShare
}
}

mutation deleteDatasetOutboundShare($id: ObjectId!) {
# @genqlient(flatten: true)
resultStatus: deleteDatasetOutboundShare(id: $id) {
...ResultStatus
}
}
46 changes: 46 additions & 0 deletions client/meta/dataset_outbound_share.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package meta

import (
"context"

"github.com/observeinc/terraform-provider-observe/client/oid"
)

type datasetOutboundShareResponse interface {
GetDatasetOutboundShare() DatasetOutboundShare
}

func datasetOutboundShareOrError(r datasetOutboundShareResponse, err error) (*DatasetOutboundShare, error) {
if err != nil {
return nil, err
}
result := r.GetDatasetOutboundShare()
return &result, nil
}

func (client *Client) GetDatasetOutboundShare(ctx context.Context, id string) (*DatasetOutboundShare, error) {
resp, err := getDatasetOutboundShare(ctx, client.Gql, id)
return datasetOutboundShareOrError(resp, err)
}

func (client *Client) CreateDatasetOutboundShare(ctx context.Context, workspaceId string, datasetId string, outboundShareId string, input *DatasetOutboundShareInput) (*DatasetOutboundShare, error) {
resp, err := createDatasetOutboundShare(ctx, client.Gql, workspaceId, datasetId, outboundShareId, *input)
return datasetOutboundShareOrError(resp, err)
}

func (client *Client) UpdateDatasetOutboundShare(ctx context.Context, id string, input *DatasetOutboundShareInput) (*DatasetOutboundShare, error) {
resp, err := updateDatasetOutboundShare(ctx, client.Gql, id, *input)
return datasetOutboundShareOrError(resp, err)
}

func (client *Client) DeleteDatasetOutboundShare(ctx context.Context, id string) error {
resp, err := deleteDatasetOutboundShare(ctx, client.Gql, id)
return resultStatusError(resp, err)
}

func (p *DatasetOutboundShare) Oid() *oid.OID {
return &oid.OID{
Id: p.Id,
Type: oid.TypeDatasetOutboundShare,
}
}
Loading