-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
17 changed files
with
781 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
0.1.12 | ||
0.1.13 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "files_file_comment Data Source - files" | ||
subcategory: "" | ||
description: |- | ||
File Comments are comments attached to a file by a user. | ||
--- | ||
|
||
# files_file_comment (Data Source) | ||
|
||
File Comments are comments attached to a file by a user. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "files_file_comment" "example_file_comment" { | ||
id = 1 | ||
path = "path" | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `id` (Number) File Comment ID | ||
- `path` (String) File path. | ||
|
||
### Read-Only | ||
|
||
- `body` (String) Comment body. | ||
- `reactions` (Dynamic) Reactions to this comment. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "files_group_user Data Source - files" | ||
subcategory: "" | ||
description: |- | ||
A GroupUser describes the membership of a User within a Group. | ||
Creating GroupUsers | ||
GroupUsers can be created via the normal create action. When using the update action, if the | ||
GroupUser record does not exist for the given user/group IDs it will be created. | ||
--- | ||
|
||
# files_group_user (Data Source) | ||
|
||
A GroupUser describes the membership of a User within a Group. | ||
|
||
|
||
|
||
## Creating GroupUsers | ||
|
||
GroupUsers can be created via the normal `create` action. When using the `update` action, if the | ||
|
||
GroupUser record does not exist for the given user/group IDs it will be created. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "files_group_user" "example_group_user" { | ||
id = 1 | ||
group_id = 1 | ||
user_id = 1 | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `id` (Number) Group User ID. | ||
|
||
### Read-Only | ||
|
||
- `admin` (Boolean) Is this user an administrator of this group? | ||
- `group_id` (Number) Group ID | ||
- `group_name` (String) Group name | ||
- `user_id` (Number) User ID | ||
- `usernames` (List of String) A list of usernames for users in this group |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "files_permission Data Source - files" | ||
subcategory: "" | ||
description: |- | ||
Permission objects represent the grant of permissions to a user or group. | ||
They are specific to a path and can be either recursive or nonrecursive into the subfolders of that path. | ||
--- | ||
|
||
# files_permission (Data Source) | ||
|
||
Permission objects represent the grant of permissions to a user or group. | ||
|
||
|
||
|
||
They are specific to a path and can be either recursive or nonrecursive into the subfolders of that path. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "files_permission" "example_permission" { | ||
id = 1 | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `id` (Number) Permission ID | ||
|
||
### Read-Only | ||
|
||
- `group_id` (Number) Group ID | ||
- `group_name` (String) Group name if applicable | ||
- `path` (String) Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters. | ||
- `permission` (String) Permission type | ||
- `recursive` (Boolean) Does this permission apply to subfolders? | ||
- `user_id` (Number) User ID | ||
- `username` (String) User's username |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "files_request Data Source - files" | ||
subcategory: "" | ||
description: |- | ||
A Request represents a file that should be uploaded by a specific user or group. | ||
Requests can either be manually created and managed, or managed automatically by an Automation. | ||
--- | ||
|
||
# files_request (Data Source) | ||
|
||
A Request represents a file that *should* be uploaded by a specific user or group. | ||
|
||
|
||
|
||
Requests can either be manually created and managed, or managed automatically by an Automation. | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
data "files_request" "example_request" { | ||
id = 1 | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `id` (Number) Request ID | ||
|
||
### Read-Only | ||
|
||
- `automation_id` (String) ID of automation that created request | ||
- `destination` (String) Destination filename | ||
- `path` (String) Folder path This must be slash-delimited, but it must neither start nor end with a slash. Maximum of 5000 characters. | ||
- `source` (String) Source filename, if applicable | ||
- `user_display_name` (String) User making the request (if applicable) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
data "files_file_comment" "example_file_comment" { | ||
id = 1 | ||
path = "path" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
data "files_group_user" "example_group_user" { | ||
id = 1 | ||
group_id = 1 | ||
user_id = 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
data "files_lock" "example_lock" { | ||
path = "path" | ||
path = "path" | ||
token = "token" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "files_permission" "example_permission" { | ||
id = 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
data "files_request" "example_request" { | ||
id = 1 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
package provider | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
files_sdk "github.com/Files-com/files-sdk-go/v3" | ||
file_comment "github.com/Files-com/files-sdk-go/v3/filecomment" | ||
"github.com/Files-com/terraform-provider-files/lib" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource" | ||
"github.com/hashicorp/terraform-plugin-framework/datasource/schema" | ||
"github.com/hashicorp/terraform-plugin-framework/diag" | ||
"github.com/hashicorp/terraform-plugin-framework/path" | ||
"github.com/hashicorp/terraform-plugin-framework/types" | ||
) | ||
|
||
var ( | ||
_ datasource.DataSource = &fileCommentDataSource{} | ||
_ datasource.DataSourceWithConfigure = &fileCommentDataSource{} | ||
) | ||
|
||
func NewFileCommentDataSource() datasource.DataSource { | ||
return &fileCommentDataSource{} | ||
} | ||
|
||
type fileCommentDataSource struct { | ||
client *file_comment.Client | ||
} | ||
|
||
type fileCommentDataSourceModel struct { | ||
Id types.Int64 `tfsdk:"id"` | ||
Body types.String `tfsdk:"body"` | ||
Reactions types.Dynamic `tfsdk:"reactions"` | ||
Path types.String `tfsdk:"path"` | ||
} | ||
|
||
func (r *fileCommentDataSource) Configure(_ context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { | ||
if req.ProviderData == nil { | ||
return | ||
} | ||
|
||
sdk_config, ok := req.ProviderData.(files_sdk.Config) | ||
|
||
if !ok { | ||
resp.Diagnostics.AddError( | ||
"Unexpected Data Source Configure Type", | ||
fmt.Sprintf("Expected files_sdk.Config, got: %T. Please report this issue to the provider developers.", req.ProviderData), | ||
) | ||
|
||
return | ||
} | ||
|
||
r.client = &file_comment.Client{Config: sdk_config} | ||
} | ||
|
||
func (r *fileCommentDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { | ||
resp.TypeName = req.ProviderTypeName + "_file_comment" | ||
} | ||
|
||
func (r *fileCommentDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { | ||
resp.Schema = schema.Schema{ | ||
Description: "File Comments are comments attached to a file by a user.", | ||
Attributes: map[string]schema.Attribute{ | ||
"id": schema.Int64Attribute{ | ||
Description: "File Comment ID", | ||
Required: true, | ||
}, | ||
"body": schema.StringAttribute{ | ||
Description: "Comment body.", | ||
Computed: true, | ||
}, | ||
"reactions": schema.DynamicAttribute{ | ||
Description: "Reactions to this comment.", | ||
Computed: true, | ||
}, | ||
"path": schema.StringAttribute{ | ||
Description: "File path.", | ||
Required: true, | ||
}, | ||
}, | ||
} | ||
} | ||
|
||
func (r *fileCommentDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { | ||
var data fileCommentDataSourceModel | ||
diags := req.Config.Get(ctx, &data) | ||
resp.Diagnostics.Append(diags...) | ||
if resp.Diagnostics.HasError() { | ||
return | ||
} | ||
|
||
paramsFileCommentListFor := files_sdk.FileCommentListForParams{} | ||
paramsFileCommentListFor.Path = data.Path.ValueString() | ||
|
||
fileCommentIt, err := r.client.ListFor(paramsFileCommentListFor, files_sdk.WithContext(ctx)) | ||
if err != nil { | ||
resp.Diagnostics.AddError( | ||
"Error Reading Files FileComment", | ||
"Could not read file_comment id "+fmt.Sprint(data.Id.ValueInt64())+": "+err.Error(), | ||
) | ||
return | ||
} | ||
|
||
var fileComment *files_sdk.FileComment | ||
for fileCommentIt.Next() { | ||
entry := fileCommentIt.FileComment() | ||
if entry.Id == data.Id.ValueInt64() { | ||
fileComment = &entry | ||
break | ||
} | ||
} | ||
|
||
if fileComment == nil { | ||
resp.Diagnostics.AddError( | ||
"Error Reading Files FileComment", | ||
"Could not find file_comment id "+fmt.Sprint(data.Id.ValueInt64()), | ||
) | ||
return | ||
} | ||
|
||
diags = r.populateDataSourceModel(ctx, *fileComment, &data) | ||
resp.Diagnostics.Append(diags...) | ||
if resp.Diagnostics.HasError() { | ||
return | ||
} | ||
|
||
diags = resp.State.Set(ctx, data) | ||
resp.Diagnostics.Append(diags...) | ||
} | ||
|
||
func (r *fileCommentDataSource) populateDataSourceModel(ctx context.Context, fileComment files_sdk.FileComment, state *fileCommentDataSourceModel) (diags diag.Diagnostics) { | ||
var propDiags diag.Diagnostics | ||
|
||
state.Id = types.Int64Value(fileComment.Id) | ||
state.Body = types.StringValue(fileComment.Body) | ||
state.Reactions, propDiags = lib.ToDynamic(ctx, path.Root("reactions"), fileComment.Reactions, state.Reactions.UnderlyingValue()) | ||
diags.Append(propDiags...) | ||
|
||
return | ||
} |
Oops, something went wrong.