Skip to content

Commit

Permalink
group policies bonjour works
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Parafiniuk committed Sep 6, 2024
1 parent 62b9a27 commit f5b3aa1
Show file tree
Hide file tree
Showing 29 changed files with 1,307 additions and 49 deletions.
46 changes: 46 additions & 0 deletions docs/data-sources/network_group_policies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "meraki_network_group_policies Data Source - terraform-provider-meraki"
subcategory: "Networks"
description: |-
This data source can read the Network Group Policies configuration.
---

# meraki_network_group_policies (Data Source)

This data source can read the `Network Group Policies` configuration.

## Example Usage

```terraform
data "meraki_network_group_policies" "example" {
id = "L_123456"
network_id = "L_123456"
}
```

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

### Required

- `network_id` (String) Network ID

### Optional

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

### Read-Only

- `bonjour_forwarding_rules` (Attributes List) (see [below for nested schema](#nestedatt--bonjour_forwarding_rules))
- `bonjour_forwarding_settings` (String)

<a id="nestedatt--bonjour_forwarding_rules"></a>
### Nested Schema for `bonjour_forwarding_rules`

Read-Only:

- `description` (String)
- `services` (List of String)
- `vlan_id` (String)
7 changes: 6 additions & 1 deletion docs/data-sources/network_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ This data source can read the `Network Settings` configuration.

```terraform
data "meraki_network_settings" "example" {
id = "12345678"
id = "L_123456"
network_id = "L_123456"
}
```
Expand All @@ -29,4 +29,9 @@ data "meraki_network_settings" "example" {

### Read-Only

- `local_status_page_authentication_enabled` (Boolean)
- `local_status_page_authentication_password` (String)
- `local_status_page_enabled` (Boolean) asdasdas
- `named_vlans_enabled` (Boolean)
- `remote_status_page_enabled` (Boolean)
- `secure_port_enabled` (Boolean)
62 changes: 62 additions & 0 deletions docs/resources/network_group_policies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
# generated by https://github.com/hashicorp/terraform-plugin-docs
page_title: "meraki_network_group_policies Resource - terraform-provider-meraki"
subcategory: "Networks"
description: |-
This resource can manage the Network Group Policies configuration.
---

# meraki_network_group_policies (Resource)

This resource can manage the `Network Group Policies` configuration.

## Example Usage

```terraform
resource "meraki_network_group_policies" "example" {
network_id = "L_123456"
name = "test_group_policy"
bonjour_forwarding_settings = "custom"
bonjour_forwarding_rules = [
{
description = ""
services = [""]
vlan_id = ""
}
]
}
```

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

### Required

- `name` (String)
- `network_id` (String) Network ID

### Optional

- `bonjour_forwarding_rules` (Attributes List) (see [below for nested schema](#nestedatt--bonjour_forwarding_rules))
- `bonjour_forwarding_settings` (String)

### Read-Only

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

<a id="nestedatt--bonjour_forwarding_rules"></a>
### Nested Schema for `bonjour_forwarding_rules`

Optional:

- `description` (String)
- `services` (List of String)
- `vlan_id` (String)

## Import

Import is supported using the following syntax:

```shell
terraform import meraki_network_group_policies.example "<network_id>"
```
19 changes: 16 additions & 3 deletions docs/resources/network_settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,13 @@ This resource can manage the `Network Settings` configuration.

```terraform
resource "meraki_network_settings" "example" {
network_id = "L_123456"
local_status_page_enabled = false
network_id = "L_123456"
local_status_page_enabled = false
remote_status_page_enabled = false
local_status_page_authentication_enabled = false
local_status_page_authentication_password = "miles123"
named_vlans_enabled = false
secure_port_enabled = false
}
```

Expand All @@ -27,6 +32,14 @@ resource "meraki_network_settings" "example" {
- `local_status_page_enabled` (Boolean) asdasdas
- `network_id` (String) Network ID

### Optional

- `local_status_page_authentication_enabled` (Boolean)
- `local_status_page_authentication_password` (String)
- `named_vlans_enabled` (Boolean)
- `remote_status_page_enabled` (Boolean)
- `secure_port_enabled` (Boolean)

### Read-Only

- `id` (String) The id of the object
Expand All @@ -36,5 +49,5 @@ resource "meraki_network_settings" "example" {
Import is supported using the following syntax:

```shell
terraform import meraki_network_settings.example "<network_id>,<id>"
terraform import meraki_network_settings.example "<network_id>"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data "meraki_network_group_policies" "example" {
id = "L_123456"
network_id = "L_123456"
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
data "meraki_network_settings" "example" {
id = "12345678"
id = "L_123456"
network_id = "L_123456"
}
1 change: 1 addition & 0 deletions examples/resources/meraki_network_group_policies/import.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
terraform import meraki_network_group_policies.example "<network_id>"
12 changes: 12 additions & 0 deletions examples/resources/meraki_network_group_policies/resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "meraki_network_group_policies" "example" {
network_id = "L_123456"
name = "test_group_policy"
bonjour_forwarding_settings = "custom"
bonjour_forwarding_rules = [
{
description = ""
services = [""]
vlan_id = ""
}
]
}
2 changes: 1 addition & 1 deletion examples/resources/meraki_network_settings/import.sh
Original file line number Diff line number Diff line change
@@ -1 +1 @@
terraform import meraki_network_settings.example "<network_id>,<id>"
terraform import meraki_network_settings.example "<network_id>"
9 changes: 7 additions & 2 deletions examples/resources/meraki_network_settings/resource.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
resource "meraki_network_settings" "example" {
network_id = "L_123456"
local_status_page_enabled = false
network_id = "L_123456"
local_status_page_enabled = false
remote_status_page_enabled = false
local_status_page_authentication_enabled = false
local_status_page_authentication_password = "miles123"
named_vlans_enabled = false
secure_port_enabled = false
}
47 changes: 47 additions & 0 deletions gen/definitions/networks_group_policies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
name: Network Group Policies
rest_endpoint: /networks/%v/groupPolicies
doc_category: Networks
id_name: group_policy_id
data_source_name_query: true
attributes:
- tf_name: network_id
type: String
id: true
reference: true
description: Network ID
example: L_123456
test_value: meraki_network.test.id
- model_name: name
type: String
mandatory: true
example: test_group_policy
- model_name: settings
data_path: [bonjourForwarding]
type: String
example: custom
- model_name: rules
data_path: [bonjourForwarding]
type: List
attributes:
- model_name: description
type: String
- model_name: services
type: List
element_type: String
- model_name: vlanId
type: String





test_prerequisites: |
data "meraki_organization" "test" {
name = "Dev"
}
resource "meraki_network" "test" {
organization_id = data.meraki_organization.test.id
name = "Network1"
product_types = ["switch"]
}
24 changes: 24 additions & 0 deletions gen/definitions/networks_settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ rest_endpoint: /networks/%v/settings
no_delete: true
put_create: true
doc_category: Networks
id_from_attribute: true
attributes:
- tf_name: network_id
type: String
id: true
reference: true
description: Network ID
example: L_123456
Expand All @@ -16,6 +18,28 @@ attributes:
description: asdasdas
example: false
mandatory: true
- model_name: remoteStatusPageEnabled
type: Bool
example: false
- model_name: enabled
data_path: [localStatusPage, authentication]
type: Bool
example: false
- model_name: password
data_path: [localStatusPage, authentication]
type: String
example: miles123
write_only: true
- model_name: enabled
data_path: [namedVlans]
type: Bool
example: false
- model_name: enabled
data_path: [securePort]
type: Bool
example: false


test_prerequisites: |
data "meraki_organization" "test" {
name = "Dev"
Expand Down
10 changes: 10 additions & 0 deletions gen/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ type YamlConfig struct {
Attributes []YamlConfigAttribute `yaml:"attributes"`
TestTags []string `yaml:"test_tags"`
TestPrerequisites string `yaml:"test_prerequisites"`
IdName string `yaml:"id_name"`
}

type YamlConfigAttribute struct {
Expand Down Expand Up @@ -177,6 +178,11 @@ func CamelCase(s string) string {
return strings.Join(g, "")
}

func DromedaryCase(s string) string {
s = ToGoName(s)
return strings.ToLower(string(s[0])) + s[1:]
}

// Templating helper function to convert string to snake case
func SnakeCase(s string) string {
var g []string
Expand Down Expand Up @@ -345,6 +351,7 @@ func Subtract(a, b int) int {
// Map of templating functions
var functions = template.FuncMap{
"toGoName": ToGoName,
"dromedaryCase": DromedaryCase,
"camelCase": CamelCase,
"snakeCase": SnakeCase,
"sprintf": fmt.Sprintf,
Expand Down Expand Up @@ -451,6 +458,9 @@ func NewYamlConfig(bytes []byte) (YamlConfig, error) {
if config.TfName == "" {
config.TfName = strings.Replace(config.Name, " ", "_", -1)
}
if config.IdName == "" {
config.IdName = "id"
}

return config, nil
}
Expand Down
Loading

0 comments on commit f5b3aa1

Please sign in to comment.