@@ -56,11 +56,31 @@ const fastly = require('@adobe/fastly-native-promises');
56
56
const service_1 = fastly (' token' , ' service_id_1' );
57
57
const serivce_2 = fastly (' token' , ' service_id_2' );
58
58
59
- // read/write baseURL property
60
- console .log (service_1 .request .defaults .baseURL ); // https://api.fastly.com
61
-
62
- // read/write timeout property
63
- console .log (service_1 .request .defaults .timeout ); // 3000
59
+ // make changes
60
+
61
+ service_1 .transact (async () => {
62
+ return this .writeS3 (' test-s3' , {
63
+ name: ' test-s3' ,
64
+ bucket_name: ' my_corporate_bucket' ,
65
+ access_key: ' AKIAIOSFODNN7EXAMPLE' ,
66
+ secret_key: ' wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY' ,
67
+ });
68
+ });
69
+
70
+
71
+ service_2 .transact (async () => {
72
+ return this .writeBigquery (' test-bq' , {
73
+ name: ' test-bq' ,
74
+ format: ' {\n "timestamp":"%{begin:%Y-%m-%dT%H:%M:%S}t",\n "time_elapsed":%{time.elapsed.usec}V,\n "is_tls":%{if(req.is_ssl, "true", "false")}V,\n "client_ip":"%{req.http.Fastly-Client-IP}V",\n "geo_city":"%{client.geo.city}V",\n "geo_country_code":"%{client.geo.country_code}V",\n "request":"%{req.request}V",\n "host":"%{req.http.Fastly-Orig-Host}V",\n "url":"%{json.escape(req.url)}V",\n "request_referer":"%{json.escape(req.http.Referer)}V",\n "request_user_agent":"%{json.escape(req.http.User-Agent)}V",\n "request_accept_language":"%{json.escape(req.http.Accept-Language)}V",\n "request_accept_charset":"%{json.escape(req.http.Accept-Charset)}V",\n "cache_status":"%{regsub(fastly_info.state, "^(HIT-(SYNTH)|(HITPASS|HIT|MISS|PASS|ERROR|PIPE)).*", "\\\\ 2\\\\ 3") }V"\n }' ,
75
+ user: ' fastly-bigquery-log@example-fastly-log.iam.gserviceaccount.com' ,
76
+ project_id: ' example-fastly-log' ,
77
+ dataset: ' fastly_log_test' ,
78
+ table: ' fastly_logs' ,
79
+ template_suffix: null ,
80
+ secret_key: '-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Mbl+PiJtFwhEHECLU9QfgBVS6r2lDAlZA+w6nwCRiidlrObzO\nCXqVOzN3fwKBgAsrOuu//bClHP0ChnCReO38aU+1/gWnDiOOnKVq0DXhAiaOzD1P\nqAG6hZlEkFBDMPWzq62doKv+gPgpRkfmV0DenHuYnGrrHdG3p2IxYoCSuq/QupPA\nPpU+xjDMhpQI30zuu4/rQq+/yDl4+aoSKYB3xAtb0Zxg6dMU8QpZ/hmnAoGBAIFu\nIesbcQR7O8FGkMrmxZweNNrYCtQ57R/WU/FImWm6OnJGNmsMO6Q2jJiT12RKKjg8\nOxrYGz7vTfOIDOddyAiPhXPUSyyF/3uvCrIzUUsmeeUJ8xq9dVwQ5HS3pYuKVfDg\nXYHbG4w9UJaF1A+3xEdUsYglSLouo7z/67zH9tZXAoGBAKpsdjSd3R+llaAv2HQ8\nGMlN92UTr5i9w++QMXq4qspH5NEYqz3NHbKuYthZqxEsRUZbRP50eDWU4jvxFVJl\nLBFINp6B+3AsIme0YCyOaleB/Cy0347miSinSv2I6QiH6dQxHdHzrG+x1evS/76f\nKT0KS+ySjCAEWgg4v+mjUDUV\n-----END PRIVATE KEY-----\n',
81
+ response_condition: ' ' ,
82
+ });
83
+ });
64
84
```
65
85
66
86
### Promises
@@ -253,6 +273,8 @@ HTTP status code can be retrieved. Known error status codes include:</p>
253
273
* [ .createVCL(version, data)] ( #Fastly+createVCL ) ⇒ <code >Promise</code >
254
274
* [ .updateVCL(version, name, data)] ( #Fastly+updateVCL ) ⇒ <code >Promise</code >
255
275
* [ .setMainVCL(version, name)] ( #Fastly+setMainVCL ) ⇒ <code >Promise</code >
276
+ * [ .transact(operations, activate)] ( #Fastly+transact ) ⇒ <code >Object</code >
277
+ * [ .dryrun(operations)] ( #Fastly+dryrun ) ⇒ <code >Object</code >
256
278
257
279
<a name =" new_Fastly_new " ></a >
258
280
@@ -817,6 +839,41 @@ Define a custom VCL to be the main VCL for a particular service and version.
817
839
| version | <code >string</code > | The current version of a service. |
818
840
| name | <code >string</code > | The name of the VCL to declare main. |
819
841
842
+ <a name =" Fastly+transact " ></a >
843
+
844
+ #### fastly.transact(operations, activate) ⇒ <code >Object</code >
845
+ Creates a new version, runs the function ` operations ` and then
846
+ optionally activates the newly created version. This function
847
+ is useful for making modifications to a service config.
848
+
849
+ ** Kind** : instance method of [ <code >Fastly</code >] ( #Fastly )
850
+ ** Returns** : <code >Object</code > - The return value of the wrapped function.
851
+
852
+ | Param | Type | Default | Description |
853
+ | --- | --- | --- | --- |
854
+ | operations | <code >function</code > | | A function that performs changes on the service config. |
855
+ | activate | <code >boolean</code > | <code >true</code > | Set to false to prevent automatic activation. |
856
+
857
+ ** Example**
858
+ ``` javascript
859
+ await fastly .transact (async (newversion ) => {
860
+ await fastly .doSomething (newversion);
861
+ });
862
+ // new version has been activated
863
+ ```
864
+ <a name =" Fastly+dryrun " ></a >
865
+
866
+ #### fastly.dryrun(operations) ⇒ <code >Object</code >
867
+ See ` transact ` , but this version does not activate the created version.
868
+
869
+ ** Kind** : instance method of [ <code >Fastly</code >] ( #Fastly )
870
+ ** Returns** : <code >Object</code > - Whatever ` operations ` returns.
871
+ ** See** : #transact
872
+
873
+ | Param | Type | Description |
874
+ | --- | --- | --- |
875
+ | operations | <code >function</code > | The operations that should be applied to the cloned service config version. |
876
+
820
877
<a name =" CreateFunction " ></a >
821
878
822
879
### CreateFunction ⇒ <code >Promise</code >
0 commit comments