Skip to content

Commit

Permalink
New resource: dataset_outbound_share (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
bendrucker authored Oct 19, 2023
1 parent f5fd2b8 commit 0106d37
Show file tree
Hide file tree
Showing 9 changed files with 947 additions and 0 deletions.
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

0 comments on commit 0106d37

Please sign in to comment.