files.com 1.1.648 → 1.1.650
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -20
- data/_VERSION +1 -1
- data/docs/custom_domain.md +150 -0
- data/lib/files.com/api.rb +2 -1
- data/lib/files.com/api_client.rb +6 -3
- data/lib/files.com/models/custom_domain.rb +214 -0
- data/lib/files.com/util.rb +1 -1
- data/lib/files.com/version.rb +1 -1
- data/lib/files.com.rb +3 -1
- data/spec/workspace_id_spec.rb +79 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f7dde18d343e9bf8a8538ccfb34491976a3db43de79ce6589d686767c75316bd
|
|
4
|
+
data.tar.gz: 7d82c5763649255e9817bca9f5c06a6936615ab76e2dd3e160b2d86ece0f61a5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b83595592c9e9e3ac15367209f141970cd60c28a6c7dd78756a82adb027e70e2b026aadaf0c66398c9a82be5b4ab31c5479447496e129b0eb5ec76449caec23a
|
|
7
|
+
data.tar.gz: 3350a714101aa458812fd311a8899040484d16b2d4393cfce4cd445230e87866a783e37cc0f945d288e72fcbc37d278d7a879834c2b34e6e47f4ade1f1a3d1f3
|
data/README.md
CHANGED
|
@@ -406,30 +406,15 @@ Customers commonly group resources by project, department, client, or region. Wo
|
|
|
406
406
|
|
|
407
407
|
Every Site has an implicit Default workspace (ID `0`). Resources that are not explicitly assigned to a named workspace are considered part of the Default workspace.
|
|
408
408
|
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
<div></div>
|
|
413
|
-
|
|
414
|
-
### Using Workspaces with the REST API
|
|
409
|
+
The Files.com Ruby SDK supports workspace scoping by using the `Files.workspace_id` configuration attribute. Scope a single request by passing `workspace_id` in the request options.
|
|
410
|
+
```ruby title="Example Request"
|
|
411
|
+
require "files.com"
|
|
415
412
|
|
|
416
|
-
|
|
413
|
+
Files.workspace_id = 123
|
|
417
414
|
|
|
418
|
-
|
|
419
|
-
X-Files-Workspace-Id: <workspace_id>
|
|
415
|
+
Files::Folder.list_for("", {}, workspace_id: 456)
|
|
420
416
|
```
|
|
421
417
|
|
|
422
|
-
This changes path mapping and "what you're looking at."
|
|
423
|
-
|
|
424
|
-
When the `X-Files-Workspace-Id` header is provided:
|
|
425
|
-
|
|
426
|
-
- List, show, update, and delete operations are constrained to that workspace for workspace-scoped models.
|
|
427
|
-
- Create operations default `workspace_id` to the scoped workspace when not explicitly provided.
|
|
428
|
-
- Attempts to provide a mismatching `workspace_id` are rejected with `not-authorized/insufficient-permission-for-params`.
|
|
429
|
-
|
|
430
|
-
This header only works for sitewide keys, or keys related to users with permissions to more than one workspace.
|
|
431
|
-
<div></div>
|
|
432
|
-
|
|
433
418
|
## Foreign Language Support
|
|
434
419
|
|
|
435
420
|
The Files.com Ruby SDK supports localized responses by using the `Files.language` configuration attribute.
|
data/_VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.1.
|
|
1
|
+
1.1.650
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# CustomDomain
|
|
2
|
+
|
|
3
|
+
## Example CustomDomain Object
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
{
|
|
7
|
+
"id": 1,
|
|
8
|
+
"domain": "files.example.com",
|
|
9
|
+
"destination": "site_alias",
|
|
10
|
+
"dns_status": "correct",
|
|
11
|
+
"ssl_certificate_id": 1,
|
|
12
|
+
"brick_managed": true,
|
|
13
|
+
"folder_behavior_id": 1,
|
|
14
|
+
"created_at": "2000-01-01T01:00:00Z",
|
|
15
|
+
"updated_at": "2000-01-01T01:00:00Z"
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
* `id` (int64): Custom Domain ID.
|
|
20
|
+
* `domain` (string): Customer-owned domain name.
|
|
21
|
+
* `destination` (string): Where this custom domain routes. Can be `site_alias`, `public_hosting`, or `s3_endpoint`.
|
|
22
|
+
* `dns_status` (string): Current DNS verification status.
|
|
23
|
+
* `ssl_certificate_id` (int64): Current SSL certificate ID.
|
|
24
|
+
* `brick_managed` (boolean): Is this domain's SSL certificate automatically managed and renewed by Files.com?
|
|
25
|
+
* `folder_behavior_id` (int64): Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior.
|
|
26
|
+
* `created_at` (date-time): When this Custom Domain was created.
|
|
27
|
+
* `updated_at` (date-time): When this Custom Domain was last updated.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## List Custom Domains
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
Files::CustomDomain.list
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Parameters
|
|
39
|
+
|
|
40
|
+
* `cursor` (string): Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
|
41
|
+
* `per_page` (int64): Number of records to show per page. (Max: 10000, 1,000 or less is recommended).
|
|
42
|
+
* `sort_by` (object): If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `id`.
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Show Custom Domain
|
|
48
|
+
|
|
49
|
+
```
|
|
50
|
+
Files::CustomDomain.find(id)
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Parameters
|
|
54
|
+
|
|
55
|
+
* `id` (int64): Required - Custom Domain ID.
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Create Custom Domain
|
|
61
|
+
|
|
62
|
+
```
|
|
63
|
+
Files::CustomDomain.create(
|
|
64
|
+
destination: "site_alias",
|
|
65
|
+
folder_behavior_id: 1,
|
|
66
|
+
ssl_certificate_id: 1,
|
|
67
|
+
domain: "files.example.com"
|
|
68
|
+
)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Parameters
|
|
72
|
+
|
|
73
|
+
* `destination` (string): Where this custom domain routes. Can be `site_alias`, `public_hosting`, or `s3_endpoint`.
|
|
74
|
+
* `folder_behavior_id` (int64): Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior.
|
|
75
|
+
* `ssl_certificate_id` (int64): Current SSL certificate ID.
|
|
76
|
+
* `domain` (string): Required - Customer-owned domain name.
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Update Custom Domain
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
Files::CustomDomain.update(id,
|
|
85
|
+
destination: "site_alias",
|
|
86
|
+
folder_behavior_id: 1,
|
|
87
|
+
ssl_certificate_id: 1,
|
|
88
|
+
domain: "files.example.com"
|
|
89
|
+
)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Parameters
|
|
93
|
+
|
|
94
|
+
* `id` (int64): Required - Custom Domain ID.
|
|
95
|
+
* `destination` (string): Where this custom domain routes. Can be `site_alias`, `public_hosting`, or `s3_endpoint`.
|
|
96
|
+
* `folder_behavior_id` (int64): Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior.
|
|
97
|
+
* `ssl_certificate_id` (int64): Current SSL certificate ID.
|
|
98
|
+
* `domain` (string): Customer-owned domain name.
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## Delete Custom Domain
|
|
104
|
+
|
|
105
|
+
```
|
|
106
|
+
Files::CustomDomain.delete(id)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Parameters
|
|
110
|
+
|
|
111
|
+
* `id` (int64): Required - Custom Domain ID.
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## Update Custom Domain
|
|
117
|
+
|
|
118
|
+
```
|
|
119
|
+
custom_domain = Files::CustomDomain.find(id)
|
|
120
|
+
|
|
121
|
+
custom_domain.update(
|
|
122
|
+
destination: "site_alias",
|
|
123
|
+
folder_behavior_id: 1,
|
|
124
|
+
ssl_certificate_id: 1,
|
|
125
|
+
domain: "files.example.com"
|
|
126
|
+
)
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Parameters
|
|
130
|
+
|
|
131
|
+
* `id` (int64): Required - Custom Domain ID.
|
|
132
|
+
* `destination` (string): Where this custom domain routes. Can be `site_alias`, `public_hosting`, or `s3_endpoint`.
|
|
133
|
+
* `folder_behavior_id` (int64): Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior.
|
|
134
|
+
* `ssl_certificate_id` (int64): Current SSL certificate ID.
|
|
135
|
+
* `domain` (string): Customer-owned domain name.
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## Delete Custom Domain
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
custom_domain = Files::CustomDomain.find(id)
|
|
144
|
+
|
|
145
|
+
custom_domain.delete
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Parameters
|
|
149
|
+
|
|
150
|
+
* `id` (int64): Required - Custom Domain ID.
|
data/lib/files.com/api.rb
CHANGED
|
@@ -11,13 +11,14 @@ module Files
|
|
|
11
11
|
api_key = headers.delete(:api_key)
|
|
12
12
|
client = headers.delete(:client)
|
|
13
13
|
session_id = headers.delete(:session_id)
|
|
14
|
+
workspace_id = headers.delete(:workspace_id)
|
|
14
15
|
if session = headers.delete(:session)
|
|
15
16
|
session.save unless session.id
|
|
16
17
|
session_id = session.id
|
|
17
18
|
end
|
|
18
19
|
|
|
19
20
|
resp, options[:api_key], options[:session_id] = client.execute_request(
|
|
20
|
-
verb, path, api_key: api_key, headers: headers, params: params, session_id: session_id
|
|
21
|
+
verb, path, api_key: api_key, headers: headers, params: params, session_id: session_id, workspace_id: workspace_id
|
|
21
22
|
)
|
|
22
23
|
|
|
23
24
|
# Hash#select returns an array before 1.9
|
data/lib/files.com/api_client.rb
CHANGED
|
@@ -93,9 +93,10 @@ module Files
|
|
|
93
93
|
end
|
|
94
94
|
end
|
|
95
95
|
|
|
96
|
-
def execute_request(method, path, base_url: nil, api_key: nil, session_id: nil, headers: {}, params: {})
|
|
96
|
+
def execute_request(method, path, base_url: nil, api_key: nil, session_id: nil, workspace_id: nil, headers: {}, params: {})
|
|
97
97
|
base_url ||= Files.base_url
|
|
98
98
|
session_id ||= Files.session_id
|
|
99
|
+
workspace_id = Files.workspace_id if workspace_id.nil?
|
|
99
100
|
|
|
100
101
|
if session_id and session_id != ""
|
|
101
102
|
check_session_id!(session_id)
|
|
@@ -113,7 +114,7 @@ module Files
|
|
|
113
114
|
body = params
|
|
114
115
|
end
|
|
115
116
|
|
|
116
|
-
headers = request_headers(api_key, session_id, method).update(headers)
|
|
117
|
+
headers = request_headers(api_key, session_id, method, workspace_id).update(headers)
|
|
117
118
|
url = api_url(path, base_url)
|
|
118
119
|
|
|
119
120
|
context = RequestLogContext.new
|
|
@@ -315,7 +316,7 @@ module Files
|
|
|
315
316
|
raise APIConnectionError, message
|
|
316
317
|
end
|
|
317
318
|
|
|
318
|
-
private def request_headers(api_key, session_id, _method)
|
|
319
|
+
private def request_headers(api_key, session_id, _method, workspace_id)
|
|
319
320
|
user_agent = "Files.com Ruby SDK v#{Files::VERSION}"
|
|
320
321
|
user_agent += " #{format_app_info(Files.app_info)}" unless Files.app_info.nil?
|
|
321
322
|
|
|
@@ -334,6 +335,8 @@ module Files
|
|
|
334
335
|
headers["X-FilesAPI-Key"] = api_key if api_key
|
|
335
336
|
headers["X-FilesAPI-Auth"] = session_id if session_id
|
|
336
337
|
headers["Accept-Language"] = Files.language if Files.language
|
|
338
|
+
workspace_id = workspace_id.to_s
|
|
339
|
+
headers["X-Files-Workspace-Id"] = workspace_id unless workspace_id.empty?
|
|
337
340
|
|
|
338
341
|
user_agent = @system_profiler.user_agent
|
|
339
342
|
begin
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Files
|
|
4
|
+
class CustomDomain
|
|
5
|
+
attr_reader :options, :attributes
|
|
6
|
+
|
|
7
|
+
def initialize(attributes = {}, options = {})
|
|
8
|
+
@attributes = attributes || {}
|
|
9
|
+
@options = options || {}
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# int64 - Custom Domain ID.
|
|
13
|
+
def id
|
|
14
|
+
@attributes[:id]
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def id=(value)
|
|
18
|
+
@attributes[:id] = value
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# string - Customer-owned domain name.
|
|
22
|
+
def domain
|
|
23
|
+
@attributes[:domain]
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def domain=(value)
|
|
27
|
+
@attributes[:domain] = value
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# string - Where this custom domain routes. Can be `site_alias`, `public_hosting`, or `s3_endpoint`.
|
|
31
|
+
def destination
|
|
32
|
+
@attributes[:destination]
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def destination=(value)
|
|
36
|
+
@attributes[:destination] = value
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# string - Current DNS verification status.
|
|
40
|
+
def dns_status
|
|
41
|
+
@attributes[:dns_status]
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def dns_status=(value)
|
|
45
|
+
@attributes[:dns_status] = value
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# int64 - Current SSL certificate ID.
|
|
49
|
+
def ssl_certificate_id
|
|
50
|
+
@attributes[:ssl_certificate_id]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def ssl_certificate_id=(value)
|
|
54
|
+
@attributes[:ssl_certificate_id] = value
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
# boolean - Is this domain's SSL certificate automatically managed and renewed by Files.com?
|
|
58
|
+
def brick_managed
|
|
59
|
+
@attributes[:brick_managed]
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def brick_managed=(value)
|
|
63
|
+
@attributes[:brick_managed] = value
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
# int64 - Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior.
|
|
67
|
+
def folder_behavior_id
|
|
68
|
+
@attributes[:folder_behavior_id]
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def folder_behavior_id=(value)
|
|
72
|
+
@attributes[:folder_behavior_id] = value
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# date-time - When this Custom Domain was created.
|
|
76
|
+
def created_at
|
|
77
|
+
@attributes[:created_at]
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# date-time - When this Custom Domain was last updated.
|
|
81
|
+
def updated_at
|
|
82
|
+
@attributes[:updated_at]
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
# Parameters:
|
|
86
|
+
# destination - string - Where this custom domain routes. Can be `site_alias`, `public_hosting`, or `s3_endpoint`.
|
|
87
|
+
# folder_behavior_id - int64 - Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior.
|
|
88
|
+
# ssl_certificate_id - int64 - Current SSL certificate ID.
|
|
89
|
+
# domain - string - Customer-owned domain name.
|
|
90
|
+
def update(params = {})
|
|
91
|
+
params ||= {}
|
|
92
|
+
params[:id] = @attributes[:id]
|
|
93
|
+
raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
|
|
94
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
|
|
95
|
+
raise InvalidParameterError.new("Bad parameter: destination must be an String") if params[:destination] and !params[:destination].is_a?(String)
|
|
96
|
+
raise InvalidParameterError.new("Bad parameter: folder_behavior_id must be an Integer") if params[:folder_behavior_id] and !params[:folder_behavior_id].is_a?(Integer)
|
|
97
|
+
raise InvalidParameterError.new("Bad parameter: ssl_certificate_id must be an Integer") if params[:ssl_certificate_id] and !params[:ssl_certificate_id].is_a?(Integer)
|
|
98
|
+
raise InvalidParameterError.new("Bad parameter: domain must be an String") if params[:domain] and !params[:domain].is_a?(String)
|
|
99
|
+
raise MissingParameterError.new("Parameter missing: id") unless params[:id]
|
|
100
|
+
|
|
101
|
+
Api.send_request("/custom_domains/#{@attributes[:id]}", :patch, params, @options)
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def delete(params = {})
|
|
105
|
+
params ||= {}
|
|
106
|
+
params[:id] = @attributes[:id]
|
|
107
|
+
raise MissingParameterError.new("Current object doesn't have a id") unless @attributes[:id]
|
|
108
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
|
|
109
|
+
raise MissingParameterError.new("Parameter missing: id") unless params[:id]
|
|
110
|
+
|
|
111
|
+
Api.send_request("/custom_domains/#{@attributes[:id]}", :delete, params, @options)
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
def destroy(params = {})
|
|
115
|
+
delete(params)
|
|
116
|
+
nil
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def save
|
|
120
|
+
if @attributes[:id]
|
|
121
|
+
new_obj = update(@attributes)
|
|
122
|
+
else
|
|
123
|
+
new_obj = CustomDomain.create(@attributes, @options)
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
@attributes = new_obj.attributes
|
|
127
|
+
true
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
# Parameters:
|
|
131
|
+
# cursor - string - Used for pagination. When a list request has more records available, cursors are provided in the response headers `X-Files-Cursor-Next` and `X-Files-Cursor-Prev`. Send one of those cursor value here to resume an existing list from the next available record. Note: many of our SDKs have iterator methods that will automatically handle cursor-based pagination.
|
|
132
|
+
# per_page - int64 - Number of records to show per page. (Max: 10000, 1,000 or less is recommended).
|
|
133
|
+
# sort_by - object - If set, sort records by the specified field in either `asc` or `desc` direction. Valid fields are `id`.
|
|
134
|
+
def self.list(params = {}, options = {})
|
|
135
|
+
raise InvalidParameterError.new("Bad parameter: cursor must be an String") if params[:cursor] and !params[:cursor].is_a?(String)
|
|
136
|
+
raise InvalidParameterError.new("Bad parameter: per_page must be an Integer") if params[:per_page] and !params[:per_page].is_a?(Integer)
|
|
137
|
+
raise InvalidParameterError.new("Bad parameter: sort_by must be an Hash") if params[:sort_by] and !params[:sort_by].is_a?(Hash)
|
|
138
|
+
|
|
139
|
+
List.new(CustomDomain, params) do
|
|
140
|
+
Api.send_request("/custom_domains", :get, params, options)
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
def self.all(params = {}, options = {})
|
|
145
|
+
list(params, options)
|
|
146
|
+
end
|
|
147
|
+
|
|
148
|
+
# Parameters:
|
|
149
|
+
# id (required) - int64 - Custom Domain ID.
|
|
150
|
+
def self.find(id, params = {}, options = {})
|
|
151
|
+
params ||= {}
|
|
152
|
+
params[:id] = id
|
|
153
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
|
|
154
|
+
raise MissingParameterError.new("Parameter missing: id") unless params[:id]
|
|
155
|
+
|
|
156
|
+
response, options = Api.send_request("/custom_domains/#{params[:id]}", :get, params, options)
|
|
157
|
+
CustomDomain.new(response.data, options)
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
def self.get(id, params = {}, options = {})
|
|
161
|
+
find(id, params, options)
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# Parameters:
|
|
165
|
+
# destination - string - Where this custom domain routes. Can be `site_alias`, `public_hosting`, or `s3_endpoint`.
|
|
166
|
+
# folder_behavior_id - int64 - Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior.
|
|
167
|
+
# ssl_certificate_id - int64 - Current SSL certificate ID.
|
|
168
|
+
# domain (required) - string - Customer-owned domain name.
|
|
169
|
+
def self.create(params = {}, options = {})
|
|
170
|
+
raise InvalidParameterError.new("Bad parameter: destination must be an String") if params[:destination] and !params[:destination].is_a?(String)
|
|
171
|
+
raise InvalidParameterError.new("Bad parameter: folder_behavior_id must be an Integer") if params[:folder_behavior_id] and !params[:folder_behavior_id].is_a?(Integer)
|
|
172
|
+
raise InvalidParameterError.new("Bad parameter: ssl_certificate_id must be an Integer") if params[:ssl_certificate_id] and !params[:ssl_certificate_id].is_a?(Integer)
|
|
173
|
+
raise InvalidParameterError.new("Bad parameter: domain must be an String") if params[:domain] and !params[:domain].is_a?(String)
|
|
174
|
+
raise MissingParameterError.new("Parameter missing: domain") unless params[:domain]
|
|
175
|
+
|
|
176
|
+
response, options = Api.send_request("/custom_domains", :post, params, options)
|
|
177
|
+
CustomDomain.new(response.data, options)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
# Parameters:
|
|
181
|
+
# destination - string - Where this custom domain routes. Can be `site_alias`, `public_hosting`, or `s3_endpoint`.
|
|
182
|
+
# folder_behavior_id - int64 - Public Hosting behavior ID when this domain routes to a specific Public Hosting behavior.
|
|
183
|
+
# ssl_certificate_id - int64 - Current SSL certificate ID.
|
|
184
|
+
# domain - string - Customer-owned domain name.
|
|
185
|
+
def self.update(id, params = {}, options = {})
|
|
186
|
+
params ||= {}
|
|
187
|
+
params[:id] = id
|
|
188
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
|
|
189
|
+
raise InvalidParameterError.new("Bad parameter: destination must be an String") if params[:destination] and !params[:destination].is_a?(String)
|
|
190
|
+
raise InvalidParameterError.new("Bad parameter: folder_behavior_id must be an Integer") if params[:folder_behavior_id] and !params[:folder_behavior_id].is_a?(Integer)
|
|
191
|
+
raise InvalidParameterError.new("Bad parameter: ssl_certificate_id must be an Integer") if params[:ssl_certificate_id] and !params[:ssl_certificate_id].is_a?(Integer)
|
|
192
|
+
raise InvalidParameterError.new("Bad parameter: domain must be an String") if params[:domain] and !params[:domain].is_a?(String)
|
|
193
|
+
raise MissingParameterError.new("Parameter missing: id") unless params[:id]
|
|
194
|
+
|
|
195
|
+
response, options = Api.send_request("/custom_domains/#{params[:id]}", :patch, params, options)
|
|
196
|
+
CustomDomain.new(response.data, options)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
def self.delete(id, params = {}, options = {})
|
|
200
|
+
params ||= {}
|
|
201
|
+
params[:id] = id
|
|
202
|
+
raise InvalidParameterError.new("Bad parameter: id must be an Integer") if params[:id] and !params[:id].is_a?(Integer)
|
|
203
|
+
raise MissingParameterError.new("Parameter missing: id") unless params[:id]
|
|
204
|
+
|
|
205
|
+
Api.send_request("/custom_domains/#{params[:id]}", :delete, params, options)
|
|
206
|
+
nil
|
|
207
|
+
end
|
|
208
|
+
|
|
209
|
+
def self.destroy(id, params = {}, options = {})
|
|
210
|
+
delete(id, params, options)
|
|
211
|
+
nil
|
|
212
|
+
end
|
|
213
|
+
end
|
|
214
|
+
end
|
data/lib/files.com/util.rb
CHANGED
data/lib/files.com/version.rb
CHANGED
data/lib/files.com.rb
CHANGED
|
@@ -60,6 +60,7 @@ require "files.com/models/bundle_recipient"
|
|
|
60
60
|
require "files.com/models/bundle_registration"
|
|
61
61
|
require "files.com/models/child_site_management_policy"
|
|
62
62
|
require "files.com/models/clickwrap"
|
|
63
|
+
require "files.com/models/custom_domain"
|
|
63
64
|
require "files.com/models/desktop_configuration_profile"
|
|
64
65
|
require "files.com/models/dns_record"
|
|
65
66
|
require "files.com/models/email_incoming_message"
|
|
@@ -176,6 +177,7 @@ module Files
|
|
|
176
177
|
@logger = nil
|
|
177
178
|
@proxy = nil
|
|
178
179
|
@session_id = nil
|
|
180
|
+
@workspace_id = nil
|
|
179
181
|
@default_headers = nil
|
|
180
182
|
|
|
181
183
|
@max_network_retries = 3
|
|
@@ -186,7 +188,7 @@ module Files
|
|
|
186
188
|
@read_timeout = 60
|
|
187
189
|
|
|
188
190
|
class << self
|
|
189
|
-
attr_accessor :api_key, :base_url, :default_headers, :initial_network_retry_delay, :language, :max_network_retry_delay, :open_timeout, :read_timeout, :proxy, :session_id
|
|
191
|
+
attr_accessor :api_key, :base_url, :default_headers, :initial_network_retry_delay, :language, :max_network_retry_delay, :open_timeout, :read_timeout, :proxy, :session_id, :workspace_id
|
|
190
192
|
end
|
|
191
193
|
|
|
192
194
|
# map to the same values as the standard library's logger
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe "Workspace scoping" do
|
|
4
|
+
around do |example|
|
|
5
|
+
old_workspace_id = Files.workspace_id
|
|
6
|
+
Files.workspace_id = nil
|
|
7
|
+
example.run
|
|
8
|
+
ensure
|
|
9
|
+
Files.workspace_id = old_workspace_id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
describe Files::ApiClient do
|
|
13
|
+
let(:client) { described_class.new }
|
|
14
|
+
|
|
15
|
+
it "includes the configured workspace ID header" do
|
|
16
|
+
headers = client.send(:request_headers, "api-key", nil, :get, 123)
|
|
17
|
+
|
|
18
|
+
expect(headers["X-Files-Workspace-Id"]).to eq("123")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it "omits the workspace ID header when unset" do
|
|
22
|
+
headers = client.send(:request_headers, "api-key", nil, :get, nil)
|
|
23
|
+
|
|
24
|
+
expect(headers).not_to have_key("X-Files-Workspace-Id")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
it "falls back to the configured workspace ID" do
|
|
28
|
+
Files.workspace_id = 123
|
|
29
|
+
response = double(status: 204, body: "", headers: {})
|
|
30
|
+
conn = double
|
|
31
|
+
client = described_class.new(conn)
|
|
32
|
+
|
|
33
|
+
expect(client).to receive(:request_headers).with("api-key", nil, :get, 123).and_return({})
|
|
34
|
+
expect(conn).to receive(:run_request).and_return(response)
|
|
35
|
+
|
|
36
|
+
client.execute_request(:get, "/folders", api_key: "api-key")
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
it "lets a per-request workspace ID override the configured workspace ID" do
|
|
40
|
+
Files.workspace_id = 123
|
|
41
|
+
response = double(status: 204, body: "", headers: {})
|
|
42
|
+
conn = double
|
|
43
|
+
client = described_class.new(conn)
|
|
44
|
+
|
|
45
|
+
expect(client).to receive(:request_headers).with("api-key", nil, :get, 456).and_return({})
|
|
46
|
+
expect(conn).to receive(:run_request).and_return(response)
|
|
47
|
+
|
|
48
|
+
client.execute_request(:get, "/folders", api_key: "api-key", workspace_id: 456)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
describe Files::Api do
|
|
53
|
+
it "passes per-request workspace ID options to the API client" do
|
|
54
|
+
client = instance_double(Files::ApiClient)
|
|
55
|
+
response = instance_double(Files::Response)
|
|
56
|
+
|
|
57
|
+
expect(client).to receive(:execute_request).with(
|
|
58
|
+
:get,
|
|
59
|
+
"/folders",
|
|
60
|
+
api_key: nil,
|
|
61
|
+
headers: {},
|
|
62
|
+
params: {},
|
|
63
|
+
session_id: nil,
|
|
64
|
+
workspace_id: 456
|
|
65
|
+
).and_return([ response, nil, nil ])
|
|
66
|
+
|
|
67
|
+
actual_response, options = described_class.send_request(
|
|
68
|
+
"/folders",
|
|
69
|
+
:get,
|
|
70
|
+
{},
|
|
71
|
+
client: client,
|
|
72
|
+
workspace_id: 456
|
|
73
|
+
)
|
|
74
|
+
|
|
75
|
+
expect(actual_response).to eq(response)
|
|
76
|
+
expect(options[:workspace_id]).to eq(456)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: files.com
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.1.
|
|
4
|
+
version: 1.1.650
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- files.com
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-06-
|
|
11
|
+
date: 2026-06-17 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|
|
@@ -198,6 +198,7 @@ files:
|
|
|
198
198
|
- docs/bundle_registration.md
|
|
199
199
|
- docs/child_site_management_policy.md
|
|
200
200
|
- docs/clickwrap.md
|
|
201
|
+
- docs/custom_domain.md
|
|
201
202
|
- docs/desktop_configuration_profile.md
|
|
202
203
|
- docs/dns_record.md
|
|
203
204
|
- docs/email_incoming_message.md
|
|
@@ -336,6 +337,7 @@ files:
|
|
|
336
337
|
- lib/files.com/models/bundle_registration.rb
|
|
337
338
|
- lib/files.com/models/child_site_management_policy.rb
|
|
338
339
|
- lib/files.com/models/clickwrap.rb
|
|
340
|
+
- lib/files.com/models/custom_domain.rb
|
|
339
341
|
- lib/files.com/models/desktop_configuration_profile.rb
|
|
340
342
|
- lib/files.com/models/dir.rb
|
|
341
343
|
- lib/files.com/models/dns_record.rb
|
|
@@ -461,6 +463,7 @@ files:
|
|
|
461
463
|
- spec/path_util_spec.rb
|
|
462
464
|
- spec/spec_helper.rb
|
|
463
465
|
- spec/uri_spec.rb
|
|
466
|
+
- spec/workspace_id_spec.rb
|
|
464
467
|
- test.sh
|
|
465
468
|
- test/test.rb
|
|
466
469
|
homepage: https://www.files.com
|