Skip to content

fabric_provision_device #107

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

Merged
merged 22 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c95fc8e
added GenerateQueryParamString templating helper function
kuba-mazurkiewicz Jul 19, 2024
b853a94
use create_query_path instead of query_param in Create and Update fun…
kuba-mazurkiewicz Jul 19, 2024
d0e2c6f
add query_param_no_body and data_source_no_id attributes
kuba-mazurkiewicz Jul 20, 2024
c1381fd
add import_no_id attribute, if import does not require and ID
kuba-mazurkiewicz Jul 20, 2024
a98ad26
add anycast_gateway
kuba-mazurkiewicz Jul 20, 2024
5545db0
update changelog
kuba-mazurkiewicz Jul 20, 2024
9c69bd5
add transitPeerNetworkId as id to transit_peer_network resource
kuba-mazurkiewicz Jul 20, 2024
c70bd2a
updated changelog
kuba-mazurkiewicz Jul 20, 2024
38d93bf
add fabric_l3_handoff_ip_transit resource and data source
kuba-mazurkiewicz Jul 21, 2024
59173f3
add fabric_device resource and data source
kuba-mazurkiewicz Jul 21, 2024
522d49c
pnp bulk import
kuba-mazurkiewicz Jul 22, 2024
30854ad
update changelog
kuba-mazurkiewicz Jul 22, 2024
9a6533c
rename pnp_device_import to pnp_import_devices
kuba-mazurkiewicz Jul 24, 2024
35565f0
add tag and assign_templates_to_tag
kuba-mazurkiewicz Jul 26, 2024
241fe0a
changed template_ids from List to Set
kuba-mazurkiewicz Jul 26, 2024
2db5bce
update changelog
kuba-mazurkiewicz Jul 26, 2024
b10aeaa
add fabric_provision_device resource and data source
kuba-mazurkiewicz Jul 30, 2024
9f31f09
Merge branch 'main' into tags_to_template
kuba-mazurkiewicz Aug 5, 2024
df90953
update changelog
kuba-mazurkiewicz Aug 5, 2024
c8291fd
modified res_description
kuba-mazurkiewicz Aug 5, 2024
7252a29
Merge branch 'tags_to_template' into provision_sda
kuba-mazurkiewicz Aug 5, 2024
5e38979
fix conflicts
kuba-mazurkiewicz Aug 5, 2024
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 0.1.10 (unreleased)

- Add `fabric_provision_device` resource and data source
- Add `assign_templates_to_tag` resource and data source
- Add `tag` resource and data source
- Add `pnp_import_devices` resource
Expand Down
32 changes: 32 additions & 0 deletions docs/data-sources/fabric_provision_device.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_fabric_provision_device Data Source - terraform-provider-catalystcenter"
subcategory: "SDA"
description: |-
This data source can read the Fabric Provision Device.
---

# catalystcenter_fabric_provision_device (Data Source)

This data source can read the Fabric Provision Device.

## Example Usage

```terraform
data "catalystcenter_fabric_provision_device" "example" {
site_id = "5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1"
network_device_id = "4cb565d3-1944-42be-be9f-a87cff79e831"
}
```

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

### Required

- `network_device_id` (String) ID of network device to be provisioned
- `site_id` (String) ID of the site this network device needs to be provisioned

### Read-Only

- `id` (String) The id of the object
1 change: 1 addition & 0 deletions docs/guides/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ description: |-

## 0.1.10 (unreleased)

- Add `fabric_provision_device` resource and data source
- Add `assign_templates_to_tag` resource and data source
- Add `tag` resource and data source
- Add `pnp_import_devices` resource
Expand Down
40 changes: 40 additions & 0 deletions docs/resources/fabric_provision_device.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "catalystcenter_fabric_provision_device Resource - terraform-provider-catalystcenter"
subcategory: "SDA"
description: |-
This resource can manage a Fabric Provision Device.
---

# catalystcenter_fabric_provision_device (Resource)

This resource can manage a Fabric Provision Device.

## Example Usage

```terraform
resource "catalystcenter_fabric_provision_device" "example" {
site_id = "5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1"
network_device_id = "4cb565d3-1944-42be-be9f-a87cff79e831"
}
```

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

### Required

- `network_device_id` (String) ID of network device to be provisioned
- `site_id` (String) ID of the site this network device needs to be provisioned

### Read-Only

- `id` (String) The id of the object

## Import

Import is supported using the following syntax:

```shell
terraform import catalystcenter_fabric_provision_device.example "<site_id>,<network_device_id>"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "catalystcenter_fabric_provision_device" "example" {
site_id = "5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1"
network_device_id = "4cb565d3-1944-42be-be9f-a87cff79e831"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import catalystcenter_fabric_provision_device.example "<site_id>,<network_device_id>"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
resource "catalystcenter_fabric_provision_device" "example" {
site_id = "5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1"
network_device_id = "4cb565d3-1944-42be-be9f-a87cff79e831"
}
43 changes: 43 additions & 0 deletions gen/definitions/fabric_provision_device.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
---
name: Fabric Provision Device
rest_endpoint: /dna/intent/api/v1/sda/provisionDevices
id_from_query_path: response.0
id_from_query_path_attribute: id
import_no_id: true
data_source_no_id: true
put_id_include_path: "0.id"
put_no_id: true
max_async_wait_time: 120
doc_category: SDA
test_tags: [SDA]
attributes:
- model_name: siteId
requires_replace: true
data_path: '0'
query_param: true
response_data_path: response.0.siteId
mandatory: true
description: ID of the site this network device needs to be provisioned
type: String
example: 5e6f7b3a-2b0b-4a7d-8b1c-0d4b1cd5e1b1
test_value: catalystcenter_area.test.id
- model_name: networkDeviceId
requires_replace: true
data_path: '0'
query_param: true
response_data_path: response.0.networkDeviceId
mandatory: true
description: ID of network device to be provisioned
type: String
example: 4cb565d3-1944-42be-be9f-a87cff79e831
test_prerequisites: |
resource "catalystcenter_area" "test" {
name = "Area1"
parent_name = "Global"
}
resource "catalystcenter_fabric_site" "test" {
site_id = catalystcenter_area.test.id
pub_sub_enabled = false
authentication_profile_name = "No Authentication"
depends_on = [catalystcenter_area.test]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://mozilla.org/MPL/2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: MPL-2.0

package provider

// Section below is generated&owned by "gen/generator.go". //template:begin imports
import (
"context"
"fmt"
"net/url"

"github.com/hashicorp/terraform-plugin-framework/datasource"
"github.com/hashicorp/terraform-plugin-framework/datasource/schema"
"github.com/hashicorp/terraform-plugin-log/tflog"
cc "github.com/netascode/go-catalystcenter"
)

// End of section. //template:end imports

// Section below is generated&owned by "gen/generator.go". //template:begin model

// Ensure the implementation satisfies the expected interfaces.
var (
_ datasource.DataSource = &FabricProvisionDeviceDataSource{}
_ datasource.DataSourceWithConfigure = &FabricProvisionDeviceDataSource{}
)

func NewFabricProvisionDeviceDataSource() datasource.DataSource {
return &FabricProvisionDeviceDataSource{}
}

type FabricProvisionDeviceDataSource struct {
client *cc.Client
}

func (d *FabricProvisionDeviceDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) {
resp.TypeName = req.ProviderTypeName + "_fabric_provision_device"
}

func (d *FabricProvisionDeviceDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) {
resp.Schema = schema.Schema{
// This description is used by the documentation generator and the language server.
MarkdownDescription: "This data source can read the Fabric Provision Device.",

Attributes: map[string]schema.Attribute{
"id": schema.StringAttribute{
MarkdownDescription: "The id of the object",
Computed: true,
},
"site_id": schema.StringAttribute{
MarkdownDescription: "ID of the site this network device needs to be provisioned",
Required: true,
},
"network_device_id": schema.StringAttribute{
MarkdownDescription: "ID of network device to be provisioned",
Required: true,
},
},
}
}

func (d *FabricProvisionDeviceDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, _ *datasource.ConfigureResponse) {
if req.ProviderData == nil {
return
}

d.client = req.ProviderData.(*CcProviderData).Client
}

// End of section. //template:end model

// Section below is generated&owned by "gen/generator.go". //template:begin read
func (d *FabricProvisionDeviceDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) {
var config FabricProvisionDevice

// Read config
diags := req.Config.Get(ctx, &config)
resp.Diagnostics.Append(diags...)
if resp.Diagnostics.HasError() {
return
}

tflog.Debug(ctx, fmt.Sprintf("%s: Beginning Read", config.Id.String()))

params := ""
params += "?siteId=" + url.QueryEscape(config.SiteId.ValueString()) + "&networkDeviceId=" + url.QueryEscape(config.NetworkDeviceId.ValueString())
res, err := d.client.Get(config.getPath() + params)
if err != nil {
resp.Diagnostics.AddError("Client Error", fmt.Sprintf("Failed to retrieve object, got error: %s", err))
return
}

config.fromBody(ctx, res)

tflog.Debug(ctx, fmt.Sprintf("%s: Read finished successfully", config.Id.ValueString()))

diags = resp.State.Set(ctx, &config)
resp.Diagnostics.Append(diags...)
}

// End of section. //template:end read
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Copyright © 2023 Cisco Systems, Inc. and its affiliates.
// All rights reserved.
//
// Licensed under the Mozilla Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://mozilla.org/MPL/2.0/
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// SPDX-License-Identifier: MPL-2.0

package provider

// Section below is generated&owned by "gen/generator.go". //template:begin imports
import (
"os"
"testing"

"github.com/hashicorp/terraform-plugin-testing/helper/resource"
)

// End of section. //template:end imports

// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSource
func TestAccDataSourceCcFabricProvisionDevice(t *testing.T) {
if os.Getenv("SDA") == "" {
t.Skip("skipping test, set environment variable SDA")
}
var checks []resource.TestCheckFunc
checks = append(checks, resource.TestCheckResourceAttr("data.catalystcenter_fabric_provision_device.test", "network_device_id", "4cb565d3-1944-42be-be9f-a87cff79e831"))
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
Steps: []resource.TestStep{
{
Config: testAccDataSourceCcFabricProvisionDevicePrerequisitesConfig + testAccDataSourceCcFabricProvisionDeviceConfig(),
Check: resource.ComposeTestCheckFunc(checks...),
},
},
})
}

// End of section. //template:end testAccDataSource

// Section below is generated&owned by "gen/generator.go". //template:begin testPrerequisites
const testAccDataSourceCcFabricProvisionDevicePrerequisitesConfig = `
resource "catalystcenter_area" "test" {
name = "Area1"
parent_name = "Global"
}
resource "catalystcenter_fabric_site" "test" {
site_id = catalystcenter_area.test.id
pub_sub_enabled = false
authentication_profile_name = "No Authentication"
depends_on = [catalystcenter_area.test]
}
`

// End of section. //template:end testPrerequisites

// Section below is generated&owned by "gen/generator.go". //template:begin testAccDataSourceConfig
func testAccDataSourceCcFabricProvisionDeviceConfig() string {
config := `resource "catalystcenter_fabric_provision_device" "test" {` + "\n"
config += ` site_id = catalystcenter_area.test.id` + "\n"
config += ` network_device_id = "4cb565d3-1944-42be-be9f-a87cff79e831"` + "\n"
config += `}` + "\n"

config += `
data "catalystcenter_fabric_provision_device" "test" {
id = catalystcenter_fabric_provision_device.test.id
site_id = catalystcenter_area.test.id
network_device_id = "4cb565d3-1944-42be-be9f-a87cff79e831"
}
`
return config
}

// End of section. //template:end testAccDataSourceConfig
Loading