Skip to content

Commit a510cf1

Browse files
committed
Add _manifest for file entities
1 parent dc9dd04 commit a510cf1

File tree

28 files changed

+1146
-275
lines changed

28 files changed

+1146
-275
lines changed

.speakeasy/gen.lock

Lines changed: 279 additions & 85 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 53 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ TF_REATTACH_PROVIDERS=... terraform apply
4949

5050
<!-- End SDK <no value> -->
5151

52-
<!-- Start SDK Installation [installation] -->
53-
## SDK Installation
52+
<!-- Start Installation [installation] -->
53+
## Installation
5454

5555
To install this provider, copy and paste this code into your Terraform configuration. Then, run `terraform init`.
5656

@@ -59,7 +59,7 @@ terraform {
5959
required_providers {
6060
epilot-file = {
6161
source = "epilot-dev/epilot-file"
62-
version = "0.4.0"
62+
version = "0.4.1"
6363
}
6464
}
6565
}
@@ -68,19 +68,17 @@ provider "epilot-file" {
6868
# Configuration options
6969
}
7070
```
71-
<!-- End SDK Installation [installation] -->
71+
<!-- End Installation [installation] -->
7272

73-
<!-- Start SDK Example Usage [usage] -->
74-
## SDK Example Usage
73+
<!-- Start Testing the provider locally [usage] -->
74+
## Testing the provider locally
7575

76-
### Testing the provider locally
76+
#### Local Provider
7777

7878
Should you want to validate a change locally, the `--debug` flag allows you to execute the provider against a terraform instance locally.
7979

8080
This also allows for debuggers (e.g. delve) to be attached to the provider.
8181

82-
### Example
83-
8482
```sh
8583
go run main.go --debug
8684
# Copy the TF_REATTACH_PROVIDERS env var
@@ -89,13 +87,55 @@ cd examples/your-example
8987
TF_REATTACH_PROVIDERS=... terraform init
9088
TF_REATTACH_PROVIDERS=... terraform apply
9189
```
92-
<!-- End SDK Example Usage [usage] -->
9390

94-
<!-- Start Available Resources and Operations [operations] -->
95-
## Available Resources and Operations
91+
#### Compiled Provider
92+
93+
Terraform allows you to use local provider builds by setting a `dev_overrides` block in a configuration file called `.terraformrc`. This block overrides all other configured installation methods.
94+
95+
1. Execute `go build` to construct a binary called `terraform-provider-epilot-file`
96+
2. Ensure that the `.terraformrc` file is configured with a `dev_overrides` section such that your local copy of terraform can see the provider binary
97+
98+
Terraform searches for the `.terraformrc` file in your home directory and applies any configuration settings you set.
99+
100+
```
101+
provider_installation {
102+
103+
dev_overrides {
104+
"registry.terraform.io/epilot-dev/epilot-file" = "<PATH>"
105+
}
106+
107+
# For all other providers, install them directly from their origin provider
108+
# registries as normal. If you omit this, Terraform will _only_ use
109+
# the dev_overrides block, and so no other providers will be available.
110+
direct {}
111+
}
112+
```
113+
<!-- End Testing the provider locally [usage] -->
114+
115+
<!-- Start Available Resources and Data Sources [operations] -->
116+
## Available Resources and Data Sources
117+
118+
### Resources
119+
120+
* [epilot-file_file](docs/resources/file.md)
121+
### Data Sources
122+
123+
* [epilot-file_file](docs/data-sources/file.md)
124+
<!-- End Available Resources and Data Sources [operations] -->
125+
126+
<!-- Start Summary [summary] -->
127+
## Summary
128+
129+
File API: Upload and manage epilot Files
130+
<!-- End Summary [summary] -->
96131

132+
<!-- Start Table of Contents [toc] -->
133+
## Table of Contents
97134

98-
<!-- End Available Resources and Operations [operations] -->
135+
* [Installation](#installation)
136+
* [Available Resources and Data Sources](#available-resources-and-data-sources)
137+
* [Testing the provider locally](#testing-the-provider-locally)
138+
<!-- End Table of Contents [toc] -->
99139

100140
<!-- Placeholder for Future Speakeasy SDK Sections -->
101141

docs/data-sources/file.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,26 +28,27 @@ data "epilot-file_file" "my_file" {
2828

2929
### Read-Only
3030

31-
- `access_control` (String) must be one of ["private", "public-read"]
31+
- `access_control` (String)
3232
- `acl` (Attributes) Access control list (ACL) for an entity. Defines sharing access to external orgs or users. (see [below for nested schema](#nestedatt--acl))
3333
- `additional` (Map of String) Additional fields that are not part of the schema
3434
- `created_at` (String)
3535
- `custom_download_url` (String) Custom external download url used for the file
3636
- `filename` (String)
3737
- `id` (String) The ID of this resource.
38+
- `manifest` (List of String) Manifest ID used to create/update the entity
3839
- `mime_type` (String) MIME type of the file
3940
- `org` (String)
4041
- `owners` (Attributes List) (see [below for nested schema](#nestedatt--owners))
4142
- `public_url` (String) Direct URL for file (public only if file access control is public-read)
4243
- `purpose` (List of String)
4344
- `readable_size` (String) Human readable file size
4445
- `s3ref` (Attributes) (see [below for nested schema](#nestedatt--s3ref))
45-
- `schema` (String) must be one of ["file"]
46+
- `schema` (String)
4647
- `size_bytes` (Number) File size in bytes
4748
- `source_url` (String) Source URL for the file. Included if the entity was created from source_url, or when ?source_url=true
4849
- `tags` (List of String)
4950
- `title` (String)
50-
- `type` (String) must be one of ["document", "document_template", "text", "image", "video", "audio", "spreadsheet", "presentation", "font", "archive", "application", "unknown"]
51+
- `type` (String)
5152
- `updated_at` (String)
5253
- `versions` (Attributes List) (see [below for nested schema](#nestedatt--versions))
5354

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ terraform {
1717
required_providers {
1818
epilot-file = {
1919
source = "epilot-dev/epilot-file"
20-
version = "0.4.0"
20+
version = "0.4.1"
2121
}
2222
}
2323
}

docs/resources/file.md

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,44 @@ File Resource
1414

1515
```terraform
1616
resource "epilot-file_file" "my_file" {
17-
id = "ef7d985c-2385-44f4-9c71-ae06a52264f8"
18-
title = "document.pdf"
19-
access_control = "private"
17+
access_control = "public-read"
18+
acl = {
19+
delete = [
20+
"org:456"
21+
]
22+
edit = [
23+
"org:456"
24+
]
25+
view = [
26+
"org:456"
27+
]
28+
}
29+
activity_id = "01F130Q52Q6MWSNS8N2AVXV4JN"
30+
additional = {
31+
"see" : jsonencode("documentation"),
32+
}
2033
custom_download_url = "https://some-api-url.com/download?file_id=123"
2134
filename = "document.pdf"
22-
mime_type = "application/pdf"
23-
source_url = "https://productengineer-content.s3.eu-west-1.amazonaws.com/product-engineer-checklist.pdf"
24-
strict = true
25-
type = "application"
35+
fill_activity = true
36+
id = "ef7d985c-2385-44f4-9c71-ae06a52264f8"
37+
manifest = [
38+
"123e4567-e89b-12d3-a456-426614174000"
39+
]
40+
mime_type = "application/pdf"
41+
purpose = [
42+
"..."
43+
]
44+
s3ref = {
45+
bucket = "epilot-prod-user-content"
46+
key = "123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
47+
}
48+
source_url = "https://productengineer-content.s3.eu-west-1.amazonaws.com/product-engineer-checklist.pdf"
49+
strict = true
50+
tags = [
51+
"..."
52+
]
53+
title = "document.pdf"
54+
type = "font"
2655
}
2756
```
2857

@@ -31,11 +60,16 @@ resource "epilot-file_file" "my_file" {
3160

3261
### Optional
3362

34-
- `access_control` (String) must be one of ["private", "public-read"]; Default: "private"
63+
- `access_control` (String) Default: "private"; must be one of ["private", "public-read"]
3564
- `acl` (Attributes) Access control list (ACL) for an entity. Defines sharing access to external orgs or users. (see [below for nested schema](#nestedatt--acl))
65+
- `activity_id` (String) Activity to include in event feed
3666
- `additional` (Map of String) Additional fields that are not part of the schema
3767
- `custom_download_url` (String) Custom external download url used for the file
3868
- `filename` (String)
69+
- `fill_activity` (Boolean) Update the diff and entity for the custom activity included in the query.
70+
Pending state on activity is automatically ended when activity is filled.
71+
Default: false
72+
- `manifest` (List of String) Manifest ID used to create/update the entity
3973
- `mime_type` (String) MIME type of the file
4074
- `purpose` (List of String)
4175
- `s3ref` (Attributes) (see [below for nested schema](#nestedatt--s3ref))
@@ -53,7 +87,7 @@ resource "epilot-file_file" "my_file" {
5387
- `owners` (Attributes List) (see [below for nested schema](#nestedatt--owners))
5488
- `public_url` (String) Direct URL for file (public only if file access control is public-read)
5589
- `readable_size` (String) Human readable file size
56-
- `schema` (String) must be one of ["file"]
90+
- `schema` (String) must be "file"
5791
- `size_bytes` (Number) File size in bytes
5892
- `updated_at` (String)
5993
- `versions` (Attributes List) (see [below for nested schema](#nestedatt--versions))

examples/provider/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
epilot-file = {
44
source = "epilot-dev/epilot-file"
5-
version = "0.4.0"
5+
version = "0.4.1"
66
}
77
}
88
}
Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,40 @@
11
resource "epilot-file_file" "my_file" {
2-
id = "ef7d985c-2385-44f4-9c71-ae06a52264f8"
3-
title = "document.pdf"
4-
access_control = "private"
2+
access_control = "public-read"
3+
acl = {
4+
delete = [
5+
"org:456"
6+
]
7+
edit = [
8+
"org:456"
9+
]
10+
view = [
11+
"org:456"
12+
]
13+
}
14+
activity_id = "01F130Q52Q6MWSNS8N2AVXV4JN"
15+
additional = {
16+
"see" : jsonencode("documentation"),
17+
}
518
custom_download_url = "https://some-api-url.com/download?file_id=123"
619
filename = "document.pdf"
7-
mime_type = "application/pdf"
8-
source_url = "https://productengineer-content.s3.eu-west-1.amazonaws.com/product-engineer-checklist.pdf"
9-
strict = true
10-
type = "application"
20+
fill_activity = true
21+
id = "ef7d985c-2385-44f4-9c71-ae06a52264f8"
22+
manifest = [
23+
"123e4567-e89b-12d3-a456-426614174000"
24+
]
25+
mime_type = "application/pdf"
26+
purpose = [
27+
"..."
28+
]
29+
s3ref = {
30+
bucket = "epilot-prod-user-content"
31+
key = "123/4d689aeb-1497-4410-a9fe-b36ca9ac4389/document.pdf"
32+
}
33+
source_url = "https://productengineer-content.s3.eu-west-1.amazonaws.com/product-engineer-checklist.pdf"
34+
strict = true
35+
tags = [
36+
"..."
37+
]
38+
title = "document.pdf"
39+
type = "font"
1140
}

gen.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ go:
2727
outputModelSuffix: output
2828
packageName: openapi
2929
terraform:
30-
version: 0.4.0
30+
version: 0.4.1
3131
additionalDataSources: []
3232
additionalDependencies: {}
3333
additionalResources: []

internal/provider/file_data_source.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type FileDataSourceModel struct {
3636
CustomDownloadURL types.String `tfsdk:"custom_download_url"`
3737
Filename types.String `tfsdk:"filename"`
3838
ID types.String `tfsdk:"id"`
39+
Manifest []types.String `tfsdk:"manifest"`
3940
MimeType types.String `tfsdk:"mime_type"`
4041
Org types.String `tfsdk:"org"`
4142
Owners []tfTypes.BaseEntityOwner `tfsdk:"owners"`
@@ -66,8 +67,7 @@ func (r *FileDataSource) Schema(ctx context.Context, req datasource.SchemaReques
6667

6768
Attributes: map[string]schema.Attribute{
6869
"access_control": schema.StringAttribute{
69-
Computed: true,
70-
Description: `must be one of ["private", "public-read"]`,
70+
Computed: true,
7171
},
7272
"acl": schema.SingleNestedAttribute{
7373
Computed: true,
@@ -105,6 +105,11 @@ func (r *FileDataSource) Schema(ctx context.Context, req datasource.SchemaReques
105105
"id": schema.StringAttribute{
106106
Required: true,
107107
},
108+
"manifest": schema.ListAttribute{
109+
Computed: true,
110+
ElementType: types.StringType,
111+
Description: `Manifest ID used to create/update the entity`,
112+
},
108113
"mime_type": schema.StringAttribute{
109114
Computed: true,
110115
Description: `MIME type of the file`,
@@ -149,8 +154,7 @@ func (r *FileDataSource) Schema(ctx context.Context, req datasource.SchemaReques
149154
},
150155
},
151156
"schema": schema.StringAttribute{
152-
Computed: true,
153-
Description: `must be one of ["file"]`,
157+
Computed: true,
154158
},
155159
"size_bytes": schema.Int64Attribute{
156160
Computed: true,
@@ -173,8 +177,7 @@ func (r *FileDataSource) Schema(ctx context.Context, req datasource.SchemaReques
173177
Computed: true,
174178
},
175179
"type": schema.StringAttribute{
176-
Computed: true,
177-
Description: `must be one of ["document", "document_template", "text", "image", "video", "audio", "spreadsheet", "presentation", "font", "archive", "application", "unknown"]`,
180+
Computed: true,
178181
},
179182
"updated_at": schema.StringAttribute{
180183
Computed: true,

internal/provider/file_data_source_sdk.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ func (r *FileDataSourceModel) RefreshFromSharedFileEntity(resp *shared.FileEntit
4141
} else {
4242
r.CreatedAt = types.StringNull()
4343
}
44+
r.Manifest = []types.String{}
45+
for _, v := range resp.Manifest {
46+
r.Manifest = append(r.Manifest, types.StringValue(v))
47+
}
4448
r.Org = types.StringPointerValue(resp.Org)
4549
r.Owners = []tfTypes.BaseEntityOwner{}
4650
if len(r.Owners) > len(resp.Owners) {

0 commit comments

Comments
 (0)