Skip to content

Commit

Permalink
feat(graphql_api): onboard new resource/data-source (#257)
Browse files Browse the repository at this point in the history
# 📥 Pull Request

close #197

## ❓ What are you trying to address

- Add new resource `fabric_graphql_api`
- Add new data-source `fabric_graphql_api`
- Add new data-source `fabric_graphql_apis`
  • Loading branch information
DariuszPorowski authored Feb 24, 2025
1 parent 35c5a79 commit 2bad4da
Show file tree
Hide file tree
Showing 24 changed files with 959 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changes/unreleased/added-20250214-161520.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
kind: added
body: Onboard new resource/data-source `fabric_graphql_api`.
time: 2025-02-14T16:15:20.6202369+01:00
custom:
Issue: "197"
67 changes: 67 additions & 0 deletions docs/data-sources/graphql_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fabric_graphql_api Data Source - terraform-provider-fabric"
subcategory: ""
description: |-
Get a Fabric GraphQL API.
Use this data source to fetch a GraphQL API https://learn.microsoft.com/fabric/data-engineering/api-graphql-overview.
-> This item supports Service Principal authentication.
~> This data-source is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration.
---

# fabric_graphql_api (Data Source)

Get a Fabric GraphQL API.

Use this data source to fetch a [GraphQL API](https://learn.microsoft.com/fabric/data-engineering/api-graphql-overview).

-> This item supports Service Principal authentication.

~> This data-source is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration.

## Example Usage

```terraform
data "fabric_graphql_api" "example_by_id" {
id = "11111111-1111-1111-1111-111111111111"
workspace_id = "00000000-0000-0000-0000-000000000000"
}
data "fabric_graphql_api" "example_by_name" {
display_name = "example"
workspace_id = "00000000-0000-0000-0000-000000000000"
}
# This is an invalid data source
# Do not specify `id` and `display_name` in the same data source block
# data "fabric_graphql_api" "example" {
# display_name = "example"
# id = "11111111-1111-1111-1111-111111111111"
# workspace_id = "00000000-0000-0000-0000-000000000000"
# }
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `workspace_id` (String) The Workspace ID.

### Optional

- `display_name` (String) The GraphQL API display name.
- `id` (String) The GraphQL API ID.
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `description` (String) The GraphQL API description.

<a id="nestedatt--timeouts"></a>

### Nested Schema for `timeouts`

Optional:

- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
59 changes: 59 additions & 0 deletions docs/data-sources/graphql_apis.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fabric_graphql_apis Data Source - terraform-provider-fabric"
subcategory: ""
description: |-
List a Fabric GraphQL APIs.
Use this data source to list GraphQL APIs https://learn.microsoft.com/fabric/data-engineering/api-graphql-overview.
-> This item supports Service Principal authentication.
---

# fabric_graphql_apis (Data Source)

List a Fabric GraphQL APIs.

Use this data source to list [GraphQL APIs](https://learn.microsoft.com/fabric/data-engineering/api-graphql-overview).

-> This item supports Service Principal authentication.

## Example Usage

```terraform
data "fabric_graphql_apis" "example" {
workspace_id = "00000000-0000-0000-0000-000000000000"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `workspace_id` (String) The Workspace ID.

### Optional

- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `values` (Attributes List) The list of GraphQL APIs. (see [below for nested schema](#nestedatt--values))

<a id="nestedatt--timeouts"></a>

### Nested Schema for `timeouts`

Optional:

- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

<a id="nestedatt--values"></a>

### Nested Schema for `values`

Read-Only:

- `description` (String) The GraphQL API description.
- `display_name` (String) The GraphQL API display name.
- `id` (String) The GraphQL API ID.
- `workspace_id` (String) The Workspace ID.
66 changes: 66 additions & 0 deletions docs/resources/graphql_api.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "fabric_graphql_api Resource - terraform-provider-fabric"
subcategory: ""
description: |-
Manage a Fabric GraphQL API.
Use this resource to manage GraphQL API https://learn.microsoft.com/fabric/data-engineering/api-graphql-overview.
-> This item supports Service Principal authentication.
~> This resource is in preview. To access it, you must explicitly enable the preview mode in the provider level configuration.
---

# fabric_graphql_api (Resource)

Manage a Fabric GraphQL API.

Use this resource to manage [GraphQL API](https://learn.microsoft.com/fabric/data-engineering/api-graphql-overview).

-> This item supports Service Principal authentication.

~> This resource is in **preview**. To access it, you must explicitly enable the `preview` mode in the provider level configuration.

## Example Usage

```terraform
resource "fabric_graphql_api" "example" {
display_name = "example"
workspace_id = "00000000-0000-0000-0000-000000000000"
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `display_name` (String) The GraphQL API display name.
- `workspace_id` (String) The Workspace ID.

### Optional

- `description` (String) The GraphQL API description.
- `timeouts` (Attributes) (see [below for nested schema](#nestedatt--timeouts))

### Read-Only

- `id` (String) The GraphQL API ID.

<a id="nestedatt--timeouts"></a>

### Nested Schema for `timeouts`

Optional:

- `create` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).
- `delete` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Setting a timeout for a Delete operation is only applicable if changes are saved into state before the destroy operation occurs.
- `read` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours). Read operations occur during any refresh or planning operation when refresh is enabled.
- `update` (String) A string that can be [parsed as a duration](https://pkg.go.dev/time#ParseDuration) consisting of numbers and unit suffixes, such as "30s" or "2h45m". Valid time units are "s" (seconds), "m" (minutes), "h" (hours).

## Import

Import is supported using the following syntax:

```shell
# terraform import fabric_graphql_api.example "<WorkspaceID>/<GraphQLApiID>"
terraform import fabric_graphql_api.example "00000000-0000-0000-0000-000000000000/11111111-1111-1111-1111-111111111111"
```
17 changes: 17 additions & 0 deletions examples/data-sources/fabric_graphql_api/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
data "fabric_graphql_api" "example_by_id" {
id = "11111111-1111-1111-1111-111111111111"
workspace_id = "00000000-0000-0000-0000-000000000000"
}

data "fabric_graphql_api" "example_by_name" {
display_name = "example"
workspace_id = "00000000-0000-0000-0000-000000000000"
}

# This is an invalid data source
# Do not specify `id` and `display_name` in the same data source block
# data "fabric_graphql_api" "example" {
# display_name = "example"
# id = "11111111-1111-1111-1111-111111111111"
# workspace_id = "00000000-0000-0000-0000-000000000000"
# }
7 changes: 7 additions & 0 deletions examples/data-sources/fabric_graphql_api/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
output "example_by_id" {
value = data.fabric_graphql_api.example_by_id
}

output "example_by_name" {
value = data.fabric_graphql_api.example_by_name
}
11 changes: 11 additions & 0 deletions examples/data-sources/fabric_graphql_api/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
terraform {
required_version = ">= 1.8, < 2.0"
required_providers {
fabric = {
source = "microsoft/fabric"
version = "0.0.0" # Check for the latest version on the Terraform Registry
}
}
}

provider "fabric" {}
3 changes: 3 additions & 0 deletions examples/data-sources/fabric_graphql_apis/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
data "fabric_graphql_apis" "example" {
workspace_id = "00000000-0000-0000-0000-000000000000"
}
3 changes: 3 additions & 0 deletions examples/data-sources/fabric_graphql_apis/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "example" {
value = data.fabric_graphql_apis.example
}
11 changes: 11 additions & 0 deletions examples/data-sources/fabric_graphql_apis/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
terraform {
required_version = ">= 1.8, < 2.0"
required_providers {
fabric = {
source = "microsoft/fabric"
version = "0.0.0" # Check for the latest version on the Terraform Registry
}
}
}

provider "fabric" {}
2 changes: 2 additions & 0 deletions examples/resources/fabric_graphql_api/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# terraform import fabric_graphql_api.example "<WorkspaceID>/<GraphQLApiID>"
terraform import fabric_graphql_api.example "00000000-0000-0000-0000-000000000000/11111111-1111-1111-1111-111111111111"
3 changes: 3 additions & 0 deletions examples/resources/fabric_graphql_api/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "example" {
value = resource.fabric_graphql_api.example
}
11 changes: 11 additions & 0 deletions examples/resources/fabric_graphql_api/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
terraform {
required_version = ">= 1.8, < 2.0"
required_providers {
fabric = {
source = "microsoft/fabric"
version = "0.0.0" # Check for the latest version on the Terraform Registry
}
}
}

provider "fabric" {}
4 changes: 4 additions & 0 deletions examples/resources/fabric_graphql_api/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "fabric_graphql_api" "example" {
display_name = "example"
workspace_id = "00000000-0000-0000-0000-000000000000"
}
4 changes: 4 additions & 0 deletions internal/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import (
"github.com/microsoft/terraform-provider-fabric/internal/services/environment"
"github.com/microsoft/terraform-provider-fabric/internal/services/eventhouse"
"github.com/microsoft/terraform-provider-fabric/internal/services/eventstream"
"github.com/microsoft/terraform-provider-fabric/internal/services/graphqlapi"
"github.com/microsoft/terraform-provider-fabric/internal/services/kqldashboard"
"github.com/microsoft/terraform-provider-fabric/internal/services/kqldatabase"
"github.com/microsoft/terraform-provider-fabric/internal/services/kqlqueryset"
Expand Down Expand Up @@ -387,6 +388,7 @@ func (p *FabricProvider) Resources(ctx context.Context) []func() resource.Resour
func() resource.Resource { return environment.NewResourceEnvironment(ctx) },
func() resource.Resource { return eventhouse.NewResourceEventhouse(ctx) },
eventstream.NewResourceEventstream,
graphqlapi.NewResourceGraphQLApi,
kqldashboard.NewResourceKQLDashboard,
kqldatabase.NewResourceKQLDatabase,
kqlqueryset.NewResourceKQLQueryset,
Expand Down Expand Up @@ -424,6 +426,8 @@ func (p *FabricProvider) DataSources(ctx context.Context) []func() datasource.Da
func() datasource.DataSource { return eventhouse.NewDataSourceEventhouses(ctx) },
eventstream.NewDataSourceEventstream,
eventstream.NewDataSourceEventstreams,
graphqlapi.NewDataSourceGraphQLApi,
graphqlapi.NewDataSourceGraphQLApis,
kqldashboard.NewDataSourceKQLDashboard,
kqldashboard.NewDataSourceKQLDashboards,
kqldatabase.NewDataSourceKQLDatabase,
Expand Down
21 changes: 21 additions & 0 deletions internal/services/graphqlapi/base.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MPL-2.0

package graphqlapi

import (
fabcore "github.com/microsoft/fabric-sdk-go/fabric/core"

"github.com/microsoft/terraform-provider-fabric/internal/common"
)

const (
ItemName = "GraphQL API"
ItemTFName = "graphql_api"
ItemsName = "GraphQL APIs"
ItemsTFName = "graphql_apis"
ItemType = fabcore.ItemTypeGraphQLAPI
ItemDocsSPNSupport = common.DocsSPNSupported
ItemDocsURL = "https://learn.microsoft.com/fabric/data-engineering/api-graphql-overview"
ItemPreview = true
)
14 changes: 14 additions & 0 deletions internal/services/graphqlapi/base_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MPL-2.0

package graphqlapi_test

import (
"github.com/microsoft/terraform-provider-fabric/internal/services/graphqlapi"
)

const (
itemTFName = graphqlapi.ItemTFName
itemsTFName = graphqlapi.ItemsTFName
itemType = graphqlapi.ItemType
)
25 changes: 25 additions & 0 deletions internal/services/graphqlapi/data_graphql_api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation
// SPDX-License-Identifier: MPL-2.0

package graphqlapi

import (
"github.com/hashicorp/terraform-plugin-framework/datasource"

"github.com/microsoft/terraform-provider-fabric/internal/pkg/fabricitem"
)

func NewDataSourceGraphQLApi() datasource.DataSource {
config := fabricitem.DataSourceFabricItem{
Type: ItemType,
Name: ItemName,
TFName: ItemTFName,
MarkdownDescription: "Get a Fabric " + ItemName + ".\n\n" +
"Use this data source to fetch a [" + ItemName + "](" + ItemDocsURL + ").\n\n" +
ItemDocsSPNSupport,
IsDisplayNameUnique: true,
IsPreview: ItemPreview,
}

return fabricitem.NewDataSourceFabricItem(config)
}
Loading

0 comments on commit 2bad4da

Please sign in to comment.