Skip to content

Commit

Permalink
Implement Resource and Datasource for SMB Share (#7)
Browse files Browse the repository at this point in the history
* Implement Resource of SMB Share

* Set name attribute as required, update resource helper & datasource AT

Update resource helper to copy attribute type of nil pointer
Update case of NullableString
Set name attribute as required
Add resource config in "get all" case
  • Loading branch information
P-Cao authored Aug 3, 2023
1 parent 745a6fa commit 367a1b7
Show file tree
Hide file tree
Showing 24 changed files with 3,114 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func NewOpenAPIClient(ctx context.Context, endpoint string, insecure bool, verbo
OperationServers: map[string]powerscale.ServerConfigurations{},
}
cfg.DefaultHeader = getHeaders()
fmt.Printf("config %+v header %+v", cfg, cfg.DefaultHeader)
fmt.Printf("config %+v header %+v\n", cfg, cfg.DefaultHeader)
cfg.AddDefaultHeader("Authorization", "Basic "+basicAuthString)
apiClient := powerscale.NewAPIClient(&cfg)
return apiClient, nil
Expand Down
133 changes: 133 additions & 0 deletions docs/data-sources/smb_share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
---
# Copyright (c) 2023 Dell Inc., or its subsidiaries. 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
#
# http://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.

title: "powerscale_smb_share data source"
linkTitle: "powerscale_smb_share"
page_title: "powerscale_smb_share Data Source - terraform-provider-powerscale"
subcategory: ""
description: |-
Data source for reading SMB Shares in PowerScale array.
---

# powerscale_smb_share (Data Source)

Data source for reading SMB Shares in PowerScale array.



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

### Optional

- `filter` (Block, Optional) (see [below for nested schema](#nestedblock--filter))

### Read-Only

- `id` (String) Placeholder for acc testing
- `smb_shares` (Attributes List) List of smb shares (see [below for nested schema](#nestedatt--smb_shares))

<a id="nestedblock--filter"></a>
### Nested Schema for `filter`

Optional:

- `dir` (String) The direction of the sort.
- `limit` (Number) Return no more than this many results at once (see resume).
- `names` (Set of String) Names to filter smb shares.
- `offset` (Number) The position of the first item returned for a paginated query within the full result set.
- `resolve_names` (Boolean) If true, resolve group and user names in personas.
- `resume` (String) Continue returning results from previous call using this token (token should come from the previous call, resume cannot be used with other options).
- `scope` (String) If specified as "effective" or not specified, all fields are returned. If specified as "user", only fields with non-default values are shown. If specified as "default", the original values are returned.
- `sort` (String) The field that will be used for sorting.
- `zone` (String) Specifies which access zone to use.


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

Read-Only:

- `access_based_enumeration` (Boolean) Only enumerate files and folders the requesting user has access to.
- `access_based_enumeration_root_only` (Boolean) Access-based enumeration on only the root directory of the share.
- `allow_delete_readonly` (Boolean) Allow deletion of read-only files in the share.
- `allow_execute_always` (Boolean) Allows users to execute files they have read rights for.
- `allow_variable_expansion` (Boolean) Allow automatic expansion of variables for home directories.
- `auto_create_directory` (Boolean) Automatically create home directories.
- `browsable` (Boolean) Share is visible in net view and the browse list.
- `ca_timeout` (Number) Persistent open timeout for the share.
- `ca_write_integrity` (String) Specify the level of write-integrity on continuously available shares.
- `change_notify` (String) Level of change notification alerts on the share.
- `continuously_available` (Boolean) Specify if persistent opens are allowed on the share.
- `create_permissions` (String) Create permissions for new files and directories in share.
- `csc_policy` (String) Client-side caching policy for the shares.
- `description` (String) Description for this SMB share.
- `directory_create_mask` (Number) Directory create mask bits.
- `directory_create_mode` (Number) Directory create mode bits.
- `file_create_mask` (Number) File create mask bits.
- `file_create_mode` (Number) File create mode bits.
- `file_filter_extensions` (List of String) Specifies the list of file extensions.
- `file_filter_type` (String) Specifies if filter list is for deny or allow. Default is deny.
- `file_filtering_enabled` (Boolean) Enables file filtering on this zone.
- `hide_dot_files` (Boolean) Hide files and directories that begin with a period '.'.
- `host_acl` (List of String) An ACL expressing which hosts are allowed access. A deny clause must be the final entry.
- `id` (String) Share ID.
- `impersonate_guest` (String) Specify the condition in which user access is done as the guest account.
- `impersonate_user` (String) User account to be used as guest account.
- `inheritable_path_acl` (Boolean) Set the inheritable ACL on the share path.
- `mangle_byte_start` (Number) Specifies the wchar_t starting point for automatic byte mangling.
- `mangle_map` (List of String) Character mangle map.
- `name` (String) Share name.
- `ntfs_acl_support` (Boolean) Support NTFS ACLs on files and directories.
- `oplocks` (Boolean) Support oplocks.
- `path` (String) Path of share within /ifs.
- `permissions` (Attributes List) Specifies an ordered list of permission modifications. (see [below for nested schema](#nestedatt--smb_shares--permissions))
- `run_as_root` (Attributes List) Allow account to run as root. (see [below for nested schema](#nestedatt--smb_shares--run_as_root))
- `smb3_encryption_enabled` (Boolean) Enables SMB3 encryption for the share.
- `sparse_file` (Boolean) Enables sparse file.
- `strict_ca_lockout` (Boolean) Specifies if persistent opens would do strict lockout on the share.
- `strict_flush` (Boolean) Handle SMB flush operations.
- `strict_locking` (Boolean) Specifies whether byte range locks contend against SMB I/O.
- `zid` (Number) Numeric ID of the access zone which contains this SMB share

<a id="nestedatt--smb_shares--permissions"></a>
### Nested Schema for `smb_shares.permissions`

Read-Only:

- `permission` (String) Specifies the file system rights that are allowed or denied.
- `permission_type` (String) Determines whether the permission is allowed or denied.
- `trustee` (Attributes) Specifies the persona of the file group. (see [below for nested schema](#nestedatt--smb_shares--permissions--trustee))

<a id="nestedatt--smb_shares--permissions--trustee"></a>
### Nested Schema for `smb_shares.permissions.trustee`

Read-Only:

- `id` (String) Specifies the serialized form of a persona, which can be 'UID:0', 'USER:name', 'GID:0', 'GROUP:wheel', or 'SID:S-1-1'.
- `name` (String) Specifies the persona name, which must be combined with a type.
- `type` (String) Specifies the type of persona, which must be combined with a name.



<a id="nestedatt--smb_shares--run_as_root"></a>
### Nested Schema for `smb_shares.run_as_root`

Read-Only:

- `id` (String) Specifies the serialized form of a persona, which can be 'UID:0', 'USER:name', 'GID:0', 'GROUP:wheel', or 'SID:S-1-1'.
- `name` (String) Specifies the persona name, which must be combined with a type.
- `type` (String) Specifies the type of persona, which must be combined with a name.
176 changes: 176 additions & 0 deletions docs/resources/smb_share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
---
# Copyright (c) 2023 Dell Inc., or its subsidiaries. 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
#
# http://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.

title: "powerscale_smb_share resource"
linkTitle: "powerscale_smb_share"
page_title: "powerscale_smb_share Resource - terraform-provider-powerscale"
subcategory: ""
description: |-
Resource for managing SMB Shares in PowerScale array.
---

# powerscale_smb_share (Resource)

Resource for managing SMB Shares in PowerScale array.


## Example Usage

```terraform
/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. 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
http://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.
*/
resource "powerscale_smb_share" "share_example" {
auto_create_directory = true
name = "smb_share_example"
path = "/ifs/smb_share_example"
permissions = [
{
permission = "full"
permission_type = "allow"
trustee = {
id = "SID:S-1-1-0",
name = "Everyone",
type = "wellknown"
}
}
]
}
```

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

### Required

- `name` (String) Share name.
- `path` (String) Path of share within /ifs.
- `permissions` (Attributes List) Specifies an ordered list of permission modifications. (see [below for nested schema](#nestedatt--permissions))

### Optional

- `access_based_enumeration` (Boolean) Only enumerate files and folders the requesting user has access to.
- `access_based_enumeration_root_only` (Boolean) Access-based enumeration on only the root directory of the share.
- `allow_delete_readonly` (Boolean) Allow deletion of read-only files in the share.
- `allow_execute_always` (Boolean) Allows users to execute files they have read rights for.
- `allow_variable_expansion` (Boolean) Allow automatic expansion of variables for home directories.
- `auto_create_directory` (Boolean) Automatically create home directories.
- `browsable` (Boolean) Share is visible in net view and the browse list.
- `ca_timeout` (Number) Persistent open timeout for the share.
- `ca_write_integrity` (String) Specify the level of write-integrity on continuously available shares.
- `change_notify` (String) Level of change notification alerts on the share.
- `create_path` (Boolean) Create path if does not exist.
- `create_permissions` (String) Create permissions for new files and directories in share.
- `csc_policy` (String) Client-side caching policy for the shares.
- `description` (String) Description for this SMB share.
- `directory_create_mask` (Number) Directory create mask bits.
- `directory_create_mode` (Number) Directory create mode bits.
- `file_create_mask` (Number) File create mask bits.
- `file_create_mode` (Number) File create mode bits.
- `file_filter_extensions` (List of String) Specifies the list of file extensions.
- `file_filter_type` (String) Specifies if filter list is for deny or allow. Default is deny.
- `file_filtering_enabled` (Boolean) Enables file filtering on this zone.
- `hide_dot_files` (Boolean) Hide files and directories that begin with a period '.'.
- `host_acl` (List of String) An ACL expressing which hosts are allowed access. A deny clause must be the final entry.
- `impersonate_guest` (String) Specify the condition in which user access is done as the guest account.
- `impersonate_user` (String) User account to be used as guest account.
- `inheritable_path_acl` (Boolean) Set the inheritable ACL on the share path.
- `mangle_byte_start` (Number) Specifies the wchar_t starting point for automatic byte mangling.
- `mangle_map` (List of String) Character mangle map.
- `ntfs_acl_support` (Boolean) Support NTFS ACLs on files and directories.
- `oplocks` (Boolean) Support oplocks.
- `run_as_root` (Attributes List) Allow account to run as root. (see [below for nested schema](#nestedatt--run_as_root))
- `smb3_encryption_enabled` (Boolean) Enables SMB3 encryption for the share.
- `sparse_file` (Boolean) Enables sparse file.
- `strict_ca_lockout` (Boolean) Specifies if persistent opens would do strict lockout on the share.
- `strict_flush` (Boolean) Handle SMB flush operations.
- `strict_locking` (Boolean) Specifies whether byte range locks contend against SMB I/O.
- `zid` (Number) Numeric ID of the access zone which contains this SMB share.
- `zone` (String) Name of the access zone to which to move this SMB share.

### Read-Only

- `continuously_available` (Boolean) Specify if persistent opens are allowed on the share.
- `id` (String) The ID of the smb share.

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

Required:

- `permission` (String) Specifies the file system rights that are allowed or denied.
- `permission_type` (String) Determines whether the permission is allowed or denied.
- `trustee` (Attributes) Specifies the persona of the file group. (see [below for nested schema](#nestedatt--permissions--trustee))

<a id="nestedatt--permissions--trustee"></a>
### Nested Schema for `permissions.trustee`

Optional:

- `id` (String) Specifies the serialized form of a persona, which can be 'UID:0', 'USER:name', 'GID:0', 'GROUP:wheel', or 'SID:S-1-1'.
- `name` (String) Specifies the persona name, which must be combined with a type.
- `type` (String) Specifies the type of persona, which must be combined with a name.



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

Optional:

- `id` (String) Specifies the serialized form of a persona, which can be 'UID:0', 'USER:name', 'GID:0', 'GROUP:wheel', or 'SID:S-1-1'.
- `name` (String) Specifies the persona name, which must be combined with a type.
- `type` (String) Specifies the type of persona, which must be combined with a name.

## Import

Import is supported using the following syntax:

```shell
# Copyright (c) 2023 Dell Inc., or its subsidiaries. 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

# http://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.

# The command is
# terraform import powermax_host.example_share <name>
# Example:
terraform import powerscale_smb_share.example_share example_share
# after running this command, populate the name field in the config file to start managing this resource
```
16 changes: 16 additions & 0 deletions examples/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
---
# Copyright (c) 2023 Dell Inc., or its subsidiaries. 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
#
# http://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.

# Examples

This directory contains examples that are mostly used for documentation, but can also be run/tested manually via the Terraform CLI.
Expand Down
35 changes: 35 additions & 0 deletions examples/data-sources/powerscale_smb_share/datasource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
Copyright (c) 2023 Dell Inc., or its subsidiaries. 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
http://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.
*/

data "powerscale_smb_share" "test" {
filter {
zone = "System"
limit = 1
names = ["tfacc_smb_share"]
}
}

output "powerscale_smb_share" {
value = data.powerscale_smb_share.test
}

data "powerscale_smb_share" "all" {
}

output "powerscale_smb_share_data_all" {
value = data.powerscale_smb_share.all
}
Loading

0 comments on commit 367a1b7

Please sign in to comment.