mirror of
https://github.com/titanscouting/tra-analysis.git
synced 2025-09-06 15:07:21 +00:00
Add files via upload
This commit is contained in:
26
website/functions/node_modules/@google-cloud/storage/CONTRIBUTORS
generated
vendored
Normal file
26
website/functions/node_modules/@google-cloud/storage/CONTRIBUTORS
generated
vendored
Normal file
@@ -0,0 +1,26 @@
|
||||
# The names of individuals who have contributed to this project.
|
||||
#
|
||||
# Names are formatted as:
|
||||
# name <email>
|
||||
#
|
||||
Ace Nassri <anassri@google.com>
|
||||
Alexander Borovykh <immaculate.pine@gmail.com>
|
||||
Alexander Fenster <github@fenster.name>
|
||||
Calvin Metcalf <calvin.metcalf@gmail.com>
|
||||
Colin Ihrig <cjihrig@gmail.com>
|
||||
Cristian Almstrand <almstrand@users.noreply.github.com>
|
||||
Dave Gramlich <callmehiphop@gmail.com>
|
||||
Dominic Valenciana <kiricon@live.com>
|
||||
Eric Uldall <ericuldall@gmail.com>
|
||||
Ernest Landrito <landrito@google.com>
|
||||
Frank Natividad <frankyn@users.noreply.github.com>
|
||||
Jason Dobry <jason.dobry@gmail.com>
|
||||
Jason Dobry <jmdobry@users.noreply.github.com>
|
||||
Justin Sprigg <justin.sprigg@gmail.com>
|
||||
Luke Sneeringer <luke@sneeringer.com>
|
||||
Stephen <stephenplusplus@users.noreply.github.com>
|
||||
Stephen Sawchuk <sawchuk@gmail.com>
|
||||
Stephen Sawchuk <stephenplusplus@users.noreply.github.com>
|
||||
Tyler Johnson <mail@tyler-johnson.ca>
|
||||
Zach Bjornson <bjornson@stanford.edu>
|
||||
greenkeeper[bot] <greenkeeper[bot]@users.noreply.github.com>
|
202
website/functions/node_modules/@google-cloud/storage/LICENSE
generated
vendored
Normal file
202
website/functions/node_modules/@google-cloud/storage/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,202 @@
|
||||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache 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://www.apache.org/licenses/LICENSE-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.
|
134
website/functions/node_modules/@google-cloud/storage/README.md
generated
vendored
Normal file
134
website/functions/node_modules/@google-cloud/storage/README.md
generated
vendored
Normal file
@@ -0,0 +1,134 @@
|
||||
<img src="https://avatars2.githubusercontent.com/u/2810941?v=3&s=96" alt="Google Cloud Platform logo" title="Google Cloud Platform" align="right" height="96" width="96"/>
|
||||
|
||||
# [Google Cloud Storage: Node.js Client](https://github.com/googleapis/nodejs-storage)
|
||||
|
||||
[](https://cloud.google.com/terms/launch-stages)
|
||||
[](https://circleci.com/gh/googleapis/nodejs-storage)
|
||||
[](https://ci.appveyor.com/project/googleapis/nodejs-storage)
|
||||
[](https://codecov.io/gh/googleapis/nodejs-storage)
|
||||
|
||||
> Node.js idiomatic client for [Cloud Storage][product-docs].
|
||||
|
||||
[Cloud Storage](https://cloud.google.com/storage/docs) allows world-wide storage and retrieval of any amount of data at any time. You can use Google Cloud Storage for a range of scenarios including serving website content, storing data for archival and disaster recovery, or distributing large data objects to users via direct download.
|
||||
|
||||
|
||||
* [Cloud Storage Node.js Client API Reference][client-docs]
|
||||
* [github.com/googleapis/nodejs-storage](https://github.com/googleapis/nodejs-storage)
|
||||
* [Cloud Storage Documentation][product-docs]
|
||||
|
||||
Read more about the client libraries for Cloud APIs, including the older
|
||||
Google APIs Client Libraries, in [Client Libraries Explained][explained].
|
||||
|
||||
[explained]: https://cloud.google.com/apis/docs/client-libraries-explained
|
||||
|
||||
**Table of contents:**
|
||||
|
||||
* [Quickstart](#quickstart)
|
||||
* [Before you begin](#before-you-begin)
|
||||
* [Installing the client library](#installing-the-client-library)
|
||||
* [Using the client library](#using-the-client-library)
|
||||
* [Samples](#samples)
|
||||
* [Versioning](#versioning)
|
||||
* [Contributing](#contributing)
|
||||
* [License](#license)
|
||||
|
||||
## Quickstart
|
||||
|
||||
### Before you begin
|
||||
|
||||
1. Select or create a Cloud Platform project.
|
||||
|
||||
[Go to the projects page][projects]
|
||||
|
||||
1. Enable billing for your project.
|
||||
|
||||
[Enable billing][billing]
|
||||
|
||||
1. Enable the Google Cloud Storage API.
|
||||
|
||||
[Enable the API][enable_api]
|
||||
|
||||
1. [Set up authentication with a service account][auth] so you can access the
|
||||
API from your local workstation.
|
||||
|
||||
[projects]: https://console.cloud.google.com/project
|
||||
[billing]: https://support.google.com/cloud/answer/6293499#enable-billing
|
||||
[enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=storage-api.googleapis.com
|
||||
[auth]: https://cloud.google.com/docs/authentication/getting-started
|
||||
|
||||
### Installing the client library
|
||||
|
||||
npm install --save @google-cloud/storage
|
||||
|
||||
### Using the client library
|
||||
|
||||
```javascript
|
||||
// Imports the Google Cloud client library
|
||||
const Storage = require('@google-cloud/storage');
|
||||
|
||||
// Your Google Cloud Platform project ID
|
||||
const projectId = 'YOUR_PROJECT_ID';
|
||||
|
||||
// Creates a client
|
||||
const storage = new Storage({
|
||||
projectId: projectId,
|
||||
});
|
||||
|
||||
// The name for the new bucket
|
||||
const bucketName = 'my-new-bucket';
|
||||
|
||||
// Creates the new bucket
|
||||
storage
|
||||
.createBucket(bucketName)
|
||||
.then(() => {
|
||||
console.log(`Bucket ${bucketName} created.`);
|
||||
})
|
||||
.catch(err => {
|
||||
console.error('ERROR:', err);
|
||||
});
|
||||
```
|
||||
|
||||
## Samples
|
||||
|
||||
Samples are in the [`samples/`](https://github.com/googleapis/nodejs-storage/tree/master/samples) directory. The samples' `README.md`
|
||||
has instructions for running the samples.
|
||||
|
||||
| Sample | Source Code | Try it |
|
||||
| --------------------------- | --------------------------------- | ------ |
|
||||
| ACL (Access Control Lists) | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/acl.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/acl.js,samples/README.md) |
|
||||
| Buckets | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/buckets.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/buckets.js,samples/README.md) |
|
||||
| Encryption | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/encryption.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/encryption.js,samples/README.md) |
|
||||
| Files | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/files.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/files.js,samples/README.md) |
|
||||
| Notifications | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/notifications.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/notifications.js,samples/README.md) |
|
||||
| Requester Pays | [source code](https://github.com/googleapis/nodejs-storage/blob/master/samples/requesterPays.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-storage&page=editor&open_in_editor=samples/requesterPays.js,samples/README.md) |
|
||||
|
||||
The [Cloud Storage Node.js Client API Reference][client-docs] documentation
|
||||
also contains samples.
|
||||
|
||||
## Versioning
|
||||
|
||||
This library follows [Semantic Versioning](http://semver.org/).
|
||||
|
||||
This library is considered to be **General Availability (GA)**. This means it
|
||||
is stable; the code surface will not change in backwards-incompatible ways
|
||||
unless absolutely necessary (e.g. because of critical security issues) or with
|
||||
an extensive deprecation period. Issues and requests against **GA** libraries
|
||||
are addressed with the highest priority.
|
||||
|
||||
More Information: [Google Cloud Platform Launch Stages][launch_stages]
|
||||
|
||||
[launch_stages]: https://cloud.google.com/terms/launch-stages
|
||||
|
||||
## Contributing
|
||||
|
||||
Contributions welcome! See the [Contributing Guide](https://github.com/googleapis/nodejs-storage/blob/master/.github/CONTRIBUTING.md).
|
||||
|
||||
## License
|
||||
|
||||
Apache Version 2.0
|
||||
|
||||
See [LICENSE](https://github.com/googleapis/nodejs-storage/blob/master/LICENSE)
|
||||
|
||||
[client-docs]: https://cloud.google.com/nodejs/docs/reference/storage/latest/
|
||||
[product-docs]: https://cloud.google.com/storage/docs
|
||||
[shell_img]: //gstatic.com/cloudssh/images/open-btn.png
|
209
website/functions/node_modules/@google-cloud/storage/package.json
generated
vendored
Normal file
209
website/functions/node_modules/@google-cloud/storage/package.json
generated
vendored
Normal file
@@ -0,0 +1,209 @@
|
||||
{
|
||||
"_from": "@google-cloud/storage@^1.6.0",
|
||||
"_id": "@google-cloud/storage@1.7.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-QaAxzCkbhspwajoaEnT0GcnQcpjPRcBrHYuQsXtD05BtOJgVnHCLXSsfUiRdU0nVpK+Thp7+sTkQ0fvk5PanKg==",
|
||||
"_location": "/@google-cloud/storage",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "@google-cloud/storage@^1.6.0",
|
||||
"name": "@google-cloud/storage",
|
||||
"escapedName": "@google-cloud%2fstorage",
|
||||
"scope": "@google-cloud",
|
||||
"rawSpec": "^1.6.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.6.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/firebase-admin"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/@google-cloud/storage/-/storage-1.7.0.tgz",
|
||||
"_shasum": "07bff573d92d5c294db6a04af246688875a8f74b",
|
||||
"_spec": "@google-cloud/storage@^1.6.0",
|
||||
"_where": "C:\\Users\\jlevi\\Downloads\\tr2022-strategy-master\\tr2022-strategy-master\\data analysis\\functions\\node_modules\\firebase-admin",
|
||||
"author": {
|
||||
"name": "Google Inc."
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/googleapis/nodejs-storage/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Ace Nassri",
|
||||
"email": "anassri@google.com"
|
||||
},
|
||||
{
|
||||
"name": "Alexander Borovykh",
|
||||
"email": "immaculate.pine@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Alexander Fenster",
|
||||
"email": "github@fenster.name"
|
||||
},
|
||||
{
|
||||
"name": "Calvin Metcalf",
|
||||
"email": "calvin.metcalf@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Colin Ihrig",
|
||||
"email": "cjihrig@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Cristian Almstrand",
|
||||
"email": "almstrand@users.noreply.github.com"
|
||||
},
|
||||
{
|
||||
"name": "Dave Gramlich",
|
||||
"email": "callmehiphop@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Dominic Valenciana",
|
||||
"email": "kiricon@live.com"
|
||||
},
|
||||
{
|
||||
"name": "Eric Uldall",
|
||||
"email": "ericuldall@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Ernest Landrito",
|
||||
"email": "landrito@google.com"
|
||||
},
|
||||
{
|
||||
"name": "Frank Natividad",
|
||||
"email": "frankyn@users.noreply.github.com"
|
||||
},
|
||||
{
|
||||
"name": "Jason Dobry",
|
||||
"email": "jason.dobry@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Jason Dobry",
|
||||
"email": "jmdobry@users.noreply.github.com"
|
||||
},
|
||||
{
|
||||
"name": "Justin Sprigg",
|
||||
"email": "justin.sprigg@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Luke Sneeringer",
|
||||
"email": "luke@sneeringer.com"
|
||||
},
|
||||
{
|
||||
"name": "Stephen",
|
||||
"email": "stephenplusplus@users.noreply.github.com"
|
||||
},
|
||||
{
|
||||
"name": "Stephen Sawchuk",
|
||||
"email": "sawchuk@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "Stephen Sawchuk",
|
||||
"email": "stephenplusplus@users.noreply.github.com"
|
||||
},
|
||||
{
|
||||
"name": "Tyler Johnson",
|
||||
"email": "mail@tyler-johnson.ca"
|
||||
},
|
||||
{
|
||||
"name": "Zach Bjornson",
|
||||
"email": "bjornson@stanford.edu"
|
||||
},
|
||||
{
|
||||
"name": "greenkeeper[bot]",
|
||||
"email": "greenkeeper[bot]@users.noreply.github.com"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"@google-cloud/common": "^0.17.0",
|
||||
"arrify": "^1.0.0",
|
||||
"async": "^2.0.1",
|
||||
"compressible": "^2.0.12",
|
||||
"concat-stream": "^1.5.0",
|
||||
"create-error-class": "^3.0.2",
|
||||
"duplexify": "^3.5.0",
|
||||
"extend": "^3.0.0",
|
||||
"gcs-resumable-upload": "^0.10.2",
|
||||
"hash-stream-validation": "^0.2.1",
|
||||
"is": "^3.0.1",
|
||||
"mime": "^2.2.0",
|
||||
"mime-types": "^2.0.8",
|
||||
"once": "^1.3.1",
|
||||
"pumpify": "^1.5.1",
|
||||
"request": "^2.85.0",
|
||||
"safe-buffer": "^5.1.1",
|
||||
"snakeize": "^0.1.0",
|
||||
"stream-events": "^1.0.1",
|
||||
"through2": "^2.0.0",
|
||||
"xdg-basedir": "^3.0.0"
|
||||
},
|
||||
"deprecated": false,
|
||||
"description": "Cloud Storage Client Library for Node.js",
|
||||
"devDependencies": {
|
||||
"@google-cloud/nodejs-repo-tools": "^2.2.3",
|
||||
"@google-cloud/pubsub": "*",
|
||||
"codecov": "^3.0.0",
|
||||
"eslint": "^4.7.1",
|
||||
"eslint-config-prettier": "^2.5.0",
|
||||
"eslint-plugin-node": "^6.0.0",
|
||||
"eslint-plugin-prettier": "^2.3.1",
|
||||
"ink-docstrap": "https://github.com/docstrap/docstrap/tarball/master",
|
||||
"intelli-espower-loader": "^1.0.1",
|
||||
"jsdoc": "^3.5.4",
|
||||
"mocha": "^5.0.0",
|
||||
"normalize-newline": "^3.0.0",
|
||||
"nyc": "^11.1.0",
|
||||
"power-assert": "^1.4.4",
|
||||
"prettier": "^1.7.0",
|
||||
"prop-assign": "^1.0.0",
|
||||
"propprop": "^0.3.0",
|
||||
"proxyquire": "^2.0.0",
|
||||
"semistandard": "^12.0.0",
|
||||
"tmp": "^0.0.33",
|
||||
"uuid": "^3.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=4"
|
||||
},
|
||||
"files": [
|
||||
"src",
|
||||
"AUTHORS",
|
||||
"CONTRIBUTORS",
|
||||
"COPYING"
|
||||
],
|
||||
"homepage": "https://github.com/googleapis/nodejs-storage#readme",
|
||||
"keywords": [
|
||||
"google apis client",
|
||||
"google api client",
|
||||
"google apis",
|
||||
"google api",
|
||||
"google",
|
||||
"google cloud platform",
|
||||
"google cloud",
|
||||
"cloud",
|
||||
"google storage",
|
||||
"storage"
|
||||
],
|
||||
"license": "Apache-2.0",
|
||||
"main": "./src/index.js",
|
||||
"name": "@google-cloud/storage",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/googleapis/nodejs-storage.git"
|
||||
},
|
||||
"scripts": {
|
||||
"all-test": "npm test && npm run system-test && npm run samples-test",
|
||||
"cover": "nyc --reporter=lcov mocha --require intelli-espower-loader test/*.js && nyc report",
|
||||
"docs": "repo-tools exec -- jsdoc -c .jsdoc.js",
|
||||
"generate-scaffolding": "repo-tools generate all && repo-tools generate lib_samples_readme -l samples/ --config ../.cloud-repo-tools.json",
|
||||
"lint": "repo-tools lint --cmd eslint -- src/ samples/ system-test/ test/",
|
||||
"prettier": "repo-tools exec -- prettier --write src/**/*.js samples/*.js samples/**/*.js system-test/**/*.js test/**/*.js",
|
||||
"samples-test": "npm link && cd samples/ && npm link @google-cloud/storage && npm test && cd ../",
|
||||
"system-test": "repo-tools test run --cmd mocha -- system-test/ --timeout 600000",
|
||||
"test": "repo-tools test run --cmd npm -- run cover",
|
||||
"test-no-cover": "repo-tools test run --cmd mocha -- test/"
|
||||
},
|
||||
"version": "1.7.0"
|
||||
}
|
766
website/functions/node_modules/@google-cloud/storage/src/acl.js
generated
vendored
Normal file
766
website/functions/node_modules/@google-cloud/storage/src/acl.js
generated
vendored
Normal file
@@ -0,0 +1,766 @@
|
||||
/*!
|
||||
* Copyright 2014 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache 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://www.apache.org/licenses/LICENSE-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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const arrify = require('arrify');
|
||||
const common = require('@google-cloud/common');
|
||||
const extend = require('extend');
|
||||
const is = require('is');
|
||||
const util = require('util');
|
||||
|
||||
/**
|
||||
* Cloud Storage uses access control lists (ACLs) to manage object and
|
||||
* bucket access. ACLs are the mechanism you use to share objects with other
|
||||
* users and allow other users to access your buckets and objects.
|
||||
*
|
||||
* An ACL consists of one or more entries, where each entry grants permissions
|
||||
* to an entity. Permissions define the actions that can be performed against an
|
||||
* object or bucket (for example, `READ` or `WRITE`); the entity defines who the
|
||||
* permission applies to (for example, a specific user or group of users).
|
||||
*
|
||||
* Where an `entity` value is accepted, we follow the format the Cloud Storage
|
||||
* API expects.
|
||||
*
|
||||
* Refer to
|
||||
* https://cloud.google.com/storage/docs/json_api/v1/defaultObjectAccessControls
|
||||
* for the most up-to-date values.
|
||||
*
|
||||
* - `user-userId`
|
||||
* - `user-email`
|
||||
* - `group-groupId`
|
||||
* - `group-email`
|
||||
* - `domain-domain`
|
||||
* - `project-team-projectId`
|
||||
* - `allUsers`
|
||||
* - `allAuthenticatedUsers`
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* - The user "liz@example.com" would be `user-liz@example.com`.
|
||||
* - The group "example@googlegroups.com" would be
|
||||
* `group-example@googlegroups.com`.
|
||||
* - To refer to all members of the Google Apps for Business domain
|
||||
* "example.com", the entity would be `domain-example.com`.
|
||||
*
|
||||
* For more detailed information, see
|
||||
* [About Access Control Lists](http://goo.gl/6qBBPO).
|
||||
*
|
||||
* @constructor Acl
|
||||
* @mixin
|
||||
* @param {object} options Configuration options.
|
||||
*/
|
||||
function Acl(options) {
|
||||
AclRoleAccessorMethods.call(this);
|
||||
|
||||
this.pathPrefix = options.pathPrefix;
|
||||
this.request_ = options.request;
|
||||
}
|
||||
|
||||
/**
|
||||
* An object of convenience methods to add or delete owner ACL permissions for a
|
||||
* given entity.
|
||||
*
|
||||
* The supported methods include:
|
||||
*
|
||||
* - `myFile.acl.owners.addAllAuthenticatedUsers`
|
||||
* - `myFile.acl.owners.deleteAllAuthenticatedUsers`
|
||||
* - `myFile.acl.owners.addAllUsers`
|
||||
* - `myFile.acl.owners.deleteAllUsers`
|
||||
* - `myFile.acl.owners.addDomain`
|
||||
* - `myFile.acl.owners.deleteDomain`
|
||||
* - `myFile.acl.owners.addGroup`
|
||||
* - `myFile.acl.owners.deleteGroup`
|
||||
* - `myFile.acl.owners.addProject`
|
||||
* - `myFile.acl.owners.deleteProject`
|
||||
* - `myFile.acl.owners.addUser`
|
||||
* - `myFile.acl.owners.deleteUser`
|
||||
*
|
||||
* @return {object}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const myFile = myBucket.file('my-file');
|
||||
*
|
||||
* //-
|
||||
* // Add a user as an owner of a file.
|
||||
* //-
|
||||
* const myBucket = gcs.bucket('my-bucket');
|
||||
* const myFile = myBucket.file('my-file');
|
||||
* myFile.acl.owners.addUser('email@example.com', function(err, aclObject) {});
|
||||
*
|
||||
* //-
|
||||
* // For reference, the above command is the same as running the following.
|
||||
* //-
|
||||
* myFile.acl.add({
|
||||
* entity: 'user-email@example.com',
|
||||
* role: gcs.acl.OWNER_ROLE
|
||||
* }, function(err, aclObject) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* myFile.acl.owners.addUser('email@example.com').then(function(data) {
|
||||
* const aclObject = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*/
|
||||
Acl.prototype.owners = {};
|
||||
|
||||
/**
|
||||
* An object of convenience methods to add or delete reader ACL permissions for
|
||||
* a given entity.
|
||||
*
|
||||
* The supported methods include:
|
||||
*
|
||||
* - `myFile.acl.readers.addAllAuthenticatedUsers`
|
||||
* - `myFile.acl.readers.deleteAllAuthenticatedUsers`
|
||||
* - `myFile.acl.readers.addAllUsers`
|
||||
* - `myFile.acl.readers.deleteAllUsers`
|
||||
* - `myFile.acl.readers.addDomain`
|
||||
* - `myFile.acl.readers.deleteDomain`
|
||||
* - `myFile.acl.readers.addGroup`
|
||||
* - `myFile.acl.readers.deleteGroup`
|
||||
* - `myFile.acl.readers.addProject`
|
||||
* - `myFile.acl.readers.deleteProject`
|
||||
* - `myFile.acl.readers.addUser`
|
||||
* - `myFile.acl.readers.deleteUser`
|
||||
*
|
||||
* @return {object}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const myFile = myBucket.file('my-file');
|
||||
*
|
||||
* //-
|
||||
* // Add a user as a reader of a file.
|
||||
* //-
|
||||
* myFile.acl.readers.addUser('email@example.com', function(err, aclObject) {});
|
||||
*
|
||||
* //-
|
||||
* // For reference, the above command is the same as running the following.
|
||||
* //-
|
||||
* myFile.acl.add({
|
||||
* entity: 'user-email@example.com',
|
||||
* role: gcs.acl.READER_ROLE
|
||||
* }, function(err, aclObject) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* myFile.acl.readers.addUser('email@example.com').then(function(data) {
|
||||
* const aclObject = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*/
|
||||
Acl.prototype.readers = {};
|
||||
|
||||
/**
|
||||
* An object of convenience methods to add or delete writer ACL permissions for
|
||||
* a given entity.
|
||||
*
|
||||
* The supported methods include:
|
||||
*
|
||||
* - `myFile.acl.writers.addAllAuthenticatedUsers`
|
||||
* - `myFile.acl.writers.deleteAllAuthenticatedUsers`
|
||||
* - `myFile.acl.writers.addAllUsers`
|
||||
* - `myFile.acl.writers.deleteAllUsers`
|
||||
* - `myFile.acl.writers.addDomain`
|
||||
* - `myFile.acl.writers.deleteDomain`
|
||||
* - `myFile.acl.writers.addGroup`
|
||||
* - `myFile.acl.writers.deleteGroup`
|
||||
* - `myFile.acl.writers.addProject`
|
||||
* - `myFile.acl.writers.deleteProject`
|
||||
* - `myFile.acl.writers.addUser`
|
||||
* - `myFile.acl.writers.deleteUser`
|
||||
*
|
||||
* @return {object}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const myFile = myBucket.file('my-file');
|
||||
*
|
||||
* //-
|
||||
* // Add a user as a writer of a file.
|
||||
* //-
|
||||
* myFile.acl.writers.addUser('email@example.com', function(err, aclObject) {});
|
||||
*
|
||||
* //-
|
||||
* // For reference, the above command is the same as running the following.
|
||||
* //-
|
||||
* myFile.acl.add({
|
||||
* entity: 'user-email@example.com',
|
||||
* role: gcs.acl.WRITER_ROLE
|
||||
* }, function(err, aclObject) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* myFile.acl.writers.addUser('email@example.com').then(function(data) {
|
||||
* const aclObject = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*/
|
||||
Acl.prototype.writers = {};
|
||||
|
||||
util.inherits(Acl, AclRoleAccessorMethods);
|
||||
|
||||
/**
|
||||
* @typedef {array} AddAclResponse
|
||||
* @property {object} 0 The Acl Objects.
|
||||
* @property {object} 1 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback AddAclCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object} acl The Acl Objects.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Add access controls on a {@link Bucket} or {@link File}.
|
||||
*
|
||||
* @see [BucketAccessControls: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/insert}
|
||||
* @see [ObjectAccessControls: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/insert}
|
||||
*
|
||||
* @param {object} options Configuration options.
|
||||
* @param {string} options.entity Whose permissions will be added.
|
||||
* @param {string} options.role Permissions allowed for the defined entity.
|
||||
* See {@link https://cloud.google.com/storage/docs/access-control Access Control}.
|
||||
* @param {number} [options.generation] **File Objects Only** Select a specific
|
||||
* revision of this file (as opposed to the latest version, the default).
|
||||
* @param {string} [options.userProject] The ID of the project which will be
|
||||
* billed for the request.
|
||||
* @param {AddAclCallback} [callback] Callback function.
|
||||
* @returns {Promise<AddAclResponse>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const myFile = myBucket.file('my-file');
|
||||
*
|
||||
* const options = {
|
||||
* entity: 'user-useremail@example.com',
|
||||
* role: gcs.acl.OWNER_ROLE
|
||||
* };
|
||||
*
|
||||
* myBucket.acl.add(options, function(err, aclObject, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // For file ACL operations, you can also specify a `generation` property.
|
||||
* // Here is how you would grant ownership permissions to a user on a specific
|
||||
* // revision of a file.
|
||||
* //-
|
||||
* myFile.acl.add({
|
||||
* entity: 'user-useremail@example.com',
|
||||
* role: gcs.acl.OWNER_ROLE,
|
||||
* generation: 1
|
||||
* }, function(err, aclObject, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* myBucket.acl.add(options).then(function(data) {
|
||||
* const aclObject = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_add_file_owner
|
||||
* Example of adding an owner to a file:
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_add_bucket_owner
|
||||
* Example of adding an owner to a bucket:
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_add_bucket_default_owner
|
||||
* Example of adding a default owner to a bucket:
|
||||
*/
|
||||
Acl.prototype.add = function(options, callback) {
|
||||
const self = this;
|
||||
|
||||
const query = {};
|
||||
|
||||
if (options.generation) {
|
||||
query.generation = options.generation;
|
||||
}
|
||||
|
||||
if (options.userProject) {
|
||||
query.userProject = options.userProject;
|
||||
}
|
||||
|
||||
this.request(
|
||||
{
|
||||
method: 'POST',
|
||||
uri: '',
|
||||
qs: query,
|
||||
json: {
|
||||
entity: options.entity,
|
||||
role: options.role.toUpperCase(),
|
||||
},
|
||||
},
|
||||
function(err, resp) {
|
||||
if (err) {
|
||||
callback(err, null, resp);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, self.makeAclObject_(resp), resp);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {array} RemoveAclResponse
|
||||
* @property {object} 0 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback RemoveAclCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Delete access controls on a {@link Bucket} or {@link File}.
|
||||
*
|
||||
* @see [BucketAccessControls: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/delete}
|
||||
* @see [ObjectAccessControls: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/delete}
|
||||
*
|
||||
* @param {object} options Configuration object.
|
||||
* @param {string} options.entity Whose permissions will be revoked.
|
||||
* @param {int} [options.generation] **File Objects Only** Select a specific
|
||||
* revision of this file (as opposed to the latest version, the default).
|
||||
* @param {string} [options.userProject] The ID of the project which will be
|
||||
* billed for the request.
|
||||
* @param {RemoveAclCallback} callback The callback function.
|
||||
* @returns {Promise<RemoveAclResponse>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const myFile = myBucket.file('my-file');
|
||||
*
|
||||
* myBucket.acl.delete({
|
||||
* entity: 'user-useremail@example.com'
|
||||
* }, function(err, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // For file ACL operations, you can also specify a `generation` property.
|
||||
* //-
|
||||
* myFile.acl.delete({
|
||||
* entity: 'user-useremail@example.com',
|
||||
* generation: 1
|
||||
* }, function(err, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* myFile.acl.delete().then(function(data) {
|
||||
* const apiResponse = data[0];
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_remove_bucket_owner
|
||||
* Example of removing an owner from a bucket:
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_remove_bucket_default_owner
|
||||
* Example of removing a default owner from a bucket:
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_remove_file_owner
|
||||
* Example of removing an owner from a bucket:
|
||||
*/
|
||||
Acl.prototype.delete = function(options, callback) {
|
||||
const query = {};
|
||||
|
||||
if (options.generation) {
|
||||
query.generation = options.generation;
|
||||
}
|
||||
|
||||
if (options.userProject) {
|
||||
query.userProject = options.userProject;
|
||||
}
|
||||
|
||||
this.request(
|
||||
{
|
||||
method: 'DELETE',
|
||||
uri: '/' + encodeURIComponent(options.entity),
|
||||
qs: query,
|
||||
},
|
||||
function(err, resp) {
|
||||
callback(err, resp);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {array} GetAclResponse
|
||||
* @property {object|object[]} 0 Single or array of Acl Objects.
|
||||
* @property {object} 1 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback GetAclCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object|object[]} acl Single or array of Acl Objects.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Get access controls on a {@link Bucket} or {@link File}. If
|
||||
* an entity is omitted, you will receive an array of all applicable access
|
||||
* controls.
|
||||
*
|
||||
* @see [BucketAccessControls: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/get}
|
||||
* @see [ObjectAccessControls: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/get}
|
||||
*
|
||||
* @param {object|function} [options] Configuration options. If you want to
|
||||
* receive a list of all access controls, pass the callback function as the
|
||||
* only argument.
|
||||
* @param {string} [options.entity] Whose permissions will be fetched.
|
||||
* @param {number} [options.generation] **File Objects Only** Select a specific
|
||||
* revision of this file (as opposed to the latest version, the default).
|
||||
* @param {string} [options.userProject] The ID of the project which will be
|
||||
* billed for the request.
|
||||
* @param {GetAclCallback} [callback] Callback function.
|
||||
* @returns {Promise<GetAclResponse>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const myFile = myBucket.file('my-file');
|
||||
*
|
||||
* myBucket.acl.get({
|
||||
* entity: 'user-useremail@example.com'
|
||||
* }, function(err, aclObject, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // Get all access controls.
|
||||
* //-
|
||||
* myBucket.acl.get(function(err, aclObjects, apiResponse) {
|
||||
* // aclObjects = [
|
||||
* // {
|
||||
* // entity: 'user-useremail@example.com',
|
||||
* // role: 'owner'
|
||||
* // }
|
||||
* // ]
|
||||
* });
|
||||
*
|
||||
* //-
|
||||
* // For file ACL operations, you can also specify a `generation` property.
|
||||
* //-
|
||||
* myFile.acl.get({
|
||||
* entity: 'user-useremail@example.com',
|
||||
* generation: 1
|
||||
* }, function(err, aclObject, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* myBucket.acl.get().then(function(data) {
|
||||
* const aclObject = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_print_file_acl
|
||||
* Example of printing a file's ACL:
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_print_file_acl_for_user
|
||||
* Example of printing a file's ACL for a specific user:
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_print_bucket_acl
|
||||
* Example of printing a bucket's ACL:
|
||||
*
|
||||
* @example <caption>include:samples/acl.js</caption>
|
||||
* region_tag:storage_print_bucket_acl_for_user
|
||||
* Example of printing a bucket's ACL for a specific user:
|
||||
*/
|
||||
Acl.prototype.get = function(options, callback) {
|
||||
const self = this;
|
||||
let path = '';
|
||||
const query = {};
|
||||
|
||||
if (is.fn(options)) {
|
||||
callback = options;
|
||||
options = null;
|
||||
} else {
|
||||
path = '/' + encodeURIComponent(options.entity);
|
||||
|
||||
if (options.generation) {
|
||||
query.generation = options.generation;
|
||||
}
|
||||
|
||||
if (options.userProject) {
|
||||
query.userProject = options.userProject;
|
||||
}
|
||||
}
|
||||
|
||||
this.request(
|
||||
{
|
||||
uri: path,
|
||||
qs: query,
|
||||
},
|
||||
function(err, resp) {
|
||||
if (err) {
|
||||
callback(err, null, resp);
|
||||
return;
|
||||
}
|
||||
|
||||
let results;
|
||||
|
||||
if (resp.items) {
|
||||
results = arrify(resp.items).map(self.makeAclObject_);
|
||||
} else {
|
||||
results = self.makeAclObject_(resp);
|
||||
}
|
||||
|
||||
callback(null, results, resp);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {array} UpdateAclResponse
|
||||
* @property {object} 0 The updated Acl Objects.
|
||||
* @property {object} 1 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback UpdateAclCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object} acl The updated Acl Objects.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Update access controls on a {@link Bucket} or {@link File}.
|
||||
*
|
||||
* @see [BucketAccessControls: update API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/bucketAccessControls/update}
|
||||
* @see [ObjectAccessControls: update API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/objectAccessControls/update}
|
||||
*
|
||||
* @param {object} options Configuration options.
|
||||
* @param {string} options.entity Whose permissions will be updated.
|
||||
* @param {string} options.role Permissions allowed for the defined entity.
|
||||
* See {@link Storage.acl}.
|
||||
* @param {number} [options.generation] **File Objects Only** Select a specific
|
||||
* revision of this file (as opposed to the latest version, the default).
|
||||
* @param {string} [options.userProject] The ID of the project which will be
|
||||
* billed for the request.
|
||||
* @param {UpdateAclCallback} [callback] Callback function.
|
||||
* @returns {Promise<UpdateAclResponse>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const myFile = myBucket.file('my-file');
|
||||
*
|
||||
* const options = {
|
||||
* entity: 'user-useremail@example.com',
|
||||
* role: gcs.acl.WRITER_ROLE
|
||||
* };
|
||||
*
|
||||
* myBucket.acl.update(options, function(err, aclObject, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // For file ACL operations, you can also specify a `generation` property.
|
||||
* //-
|
||||
* myFile.acl.update({
|
||||
* entity: 'user-useremail@example.com',
|
||||
* role: gcs.acl.WRITER_ROLE,
|
||||
* generation: 1
|
||||
* }, function(err, aclObject, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* myFile.acl.update(options).then(function(data) {
|
||||
* const aclObject = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*/
|
||||
Acl.prototype.update = function(options, callback) {
|
||||
const self = this;
|
||||
|
||||
const query = {};
|
||||
|
||||
if (options.generation) {
|
||||
query.generation = options.generation;
|
||||
}
|
||||
|
||||
if (options.userProject) {
|
||||
query.userProject = options.userProject;
|
||||
}
|
||||
|
||||
this.request(
|
||||
{
|
||||
method: 'PUT',
|
||||
uri: '/' + encodeURIComponent(options.entity),
|
||||
qs: query,
|
||||
json: {
|
||||
role: options.role.toUpperCase(),
|
||||
},
|
||||
},
|
||||
function(err, resp) {
|
||||
if (err) {
|
||||
callback(err, null, resp);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, self.makeAclObject_(resp), resp);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Transform API responses to a consistent object format.
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
Acl.prototype.makeAclObject_ = function(accessControlObject) {
|
||||
const obj = {
|
||||
entity: accessControlObject.entity,
|
||||
role: accessControlObject.role,
|
||||
};
|
||||
|
||||
if (accessControlObject.projectTeam) {
|
||||
obj.projectTeam = accessControlObject.projectTeam;
|
||||
}
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
/**
|
||||
* Patch requests up to the bucket's request object.
|
||||
*
|
||||
* @private
|
||||
*
|
||||
* @param {string} method Action.
|
||||
* @param {string} path Request path.
|
||||
* @param {*} query Request query object.
|
||||
* @param {*} body Request body contents.
|
||||
* @param {function} callback Callback function.
|
||||
*/
|
||||
Acl.prototype.request = function(reqOpts, callback) {
|
||||
reqOpts.uri = this.pathPrefix + reqOpts.uri;
|
||||
this.request_(reqOpts, callback);
|
||||
};
|
||||
|
||||
/*! Developer Documentation
|
||||
*
|
||||
* All async methods (except for streams) will return a Promise in the event
|
||||
* that a callback is omitted.
|
||||
*/
|
||||
common.util.promisifyAll(Acl);
|
||||
|
||||
module.exports = Acl;
|
||||
|
||||
/**
|
||||
* Attach functionality to a {@link Storage.acl} instance. This will add an
|
||||
* object for each role group (owners, readers, and writers), with each object
|
||||
* containing methods to add or delete a type of entity.
|
||||
*
|
||||
* As an example, here are a few methods that are created.
|
||||
*
|
||||
* myBucket.acl.readers.deleteGroup('groupId', function(err) {});
|
||||
*
|
||||
* myBucket.acl.owners.addUser('email@example.com', function(err, acl) {});
|
||||
*
|
||||
* myBucket.acl.writers.addDomain('example.com', function(err, acl) {});
|
||||
*
|
||||
* @private
|
||||
*/
|
||||
function AclRoleAccessorMethods() {
|
||||
AclRoleAccessorMethods.roles.forEach(this._assignAccessMethods.bind(this));
|
||||
}
|
||||
|
||||
AclRoleAccessorMethods.accessMethods = ['add', 'delete'];
|
||||
|
||||
AclRoleAccessorMethods.entities = [
|
||||
// Special entity groups that do not require further specification.
|
||||
'allAuthenticatedUsers',
|
||||
'allUsers',
|
||||
|
||||
// Entity groups that require specification, e.g. `user-email@example.com`.
|
||||
'domain-',
|
||||
'group-',
|
||||
'project-',
|
||||
'user-',
|
||||
];
|
||||
|
||||
AclRoleAccessorMethods.roles = ['OWNER', 'READER', 'WRITER'];
|
||||
|
||||
AclRoleAccessorMethods.prototype._assignAccessMethods = function(role) {
|
||||
const self = this;
|
||||
|
||||
const accessMethods = AclRoleAccessorMethods.accessMethods;
|
||||
const entities = AclRoleAccessorMethods.entities;
|
||||
const roleGroup = role.toLowerCase() + 's';
|
||||
|
||||
this[roleGroup] = entities.reduce(function(acc, entity) {
|
||||
const isPrefix = entity.charAt(entity.length - 1) === '-';
|
||||
|
||||
accessMethods.forEach(function(accessMethod) {
|
||||
let method = accessMethod + entity[0].toUpperCase() + entity.substr(1);
|
||||
|
||||
if (isPrefix) {
|
||||
method = method.replace('-', '');
|
||||
}
|
||||
|
||||
// Wrap the parent accessor method (e.g. `add` or `delete`) to avoid the
|
||||
// more complex API of specifying an `entity` and `role`.
|
||||
acc[method] = function(entityId, options, callback) {
|
||||
let apiEntity;
|
||||
|
||||
if (is.fn(options)) {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
if (isPrefix) {
|
||||
apiEntity = entity + entityId;
|
||||
} else {
|
||||
// If the entity is not a prefix, it is a special entity group that
|
||||
// does not require further details. The accessor methods only accept
|
||||
// a callback.
|
||||
apiEntity = entity;
|
||||
callback = entityId;
|
||||
}
|
||||
|
||||
options = extend(
|
||||
{
|
||||
entity: apiEntity,
|
||||
role: role,
|
||||
},
|
||||
options
|
||||
);
|
||||
|
||||
const args = [options];
|
||||
|
||||
if (is.fn(callback)) {
|
||||
args.push(callback);
|
||||
}
|
||||
|
||||
return self[accessMethod].apply(self, args);
|
||||
};
|
||||
});
|
||||
|
||||
return acc;
|
||||
}, {});
|
||||
};
|
||||
|
||||
module.exports.AclRoleAccessorMethods = AclRoleAccessorMethods;
|
2458
website/functions/node_modules/@google-cloud/storage/src/bucket.js
generated
vendored
Normal file
2458
website/functions/node_modules/@google-cloud/storage/src/bucket.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
116
website/functions/node_modules/@google-cloud/storage/src/channel.js
generated
vendored
Normal file
116
website/functions/node_modules/@google-cloud/storage/src/channel.js
generated
vendored
Normal file
@@ -0,0 +1,116 @@
|
||||
/*!
|
||||
* Copyright 2015 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache 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://www.apache.org/licenses/LICENSE-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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const common = require('@google-cloud/common');
|
||||
const util = require('util');
|
||||
|
||||
/**
|
||||
* Create a channel object to interact with a Cloud Storage channel.
|
||||
*
|
||||
* @see [Object Change Notification]{@link https://cloud.google.com/storage/docs/object-change-notification}
|
||||
*
|
||||
* @class
|
||||
*
|
||||
* @param {string} id The ID of the channel.
|
||||
* @param {string} resourceId The resource ID of the channel.
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const channel = storage.channel('id', 'resource-id');
|
||||
*/
|
||||
function Channel(storage, id, resourceId) {
|
||||
const config = {
|
||||
parent: storage,
|
||||
baseUrl: '/channels',
|
||||
|
||||
// An ID shouldn't be included in the API requests.
|
||||
// RE: https://github.com/GoogleCloudPlatform/google-cloud-node/issues/1145
|
||||
id: '',
|
||||
|
||||
methods: {
|
||||
// Only need `request`.
|
||||
},
|
||||
};
|
||||
|
||||
common.ServiceObject.call(this, config);
|
||||
|
||||
this.metadata.id = id;
|
||||
this.metadata.resourceId = resourceId;
|
||||
}
|
||||
|
||||
util.inherits(Channel, common.ServiceObject);
|
||||
|
||||
/**
|
||||
* @typedef {array} StopResponse
|
||||
* @property {object} 0 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback StopCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Stop this channel.
|
||||
*
|
||||
* @param {StopCallback} [callback] Callback function.
|
||||
* @returns {Promise<StopResponse>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const channel = storage.channel('id', 'resource-id');
|
||||
* channel.stop(function(err, apiResponse) {
|
||||
* if (!err) {
|
||||
* // Channel stopped successfully.
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* channel.stop().then(function(data) {
|
||||
* const apiResponse = data[0];
|
||||
* });
|
||||
*/
|
||||
Channel.prototype.stop = function(callback) {
|
||||
callback = callback || common.util.noop;
|
||||
|
||||
this.request(
|
||||
{
|
||||
method: 'POST',
|
||||
uri: '/stop',
|
||||
json: this.metadata,
|
||||
},
|
||||
function(err, apiResponse) {
|
||||
callback(err, apiResponse);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/*! Developer Documentation
|
||||
*
|
||||
* All async methods (except for streams) will return a Promise in the event
|
||||
* that a callback is omitted.
|
||||
*/
|
||||
common.util.promisifyAll(Channel);
|
||||
|
||||
/**
|
||||
* Reference to the {@link Channel} class.
|
||||
* @name module:@google-cloud/storage.Channel
|
||||
* @see Channel
|
||||
*/
|
||||
module.exports = Channel;
|
2475
website/functions/node_modules/@google-cloud/storage/src/file.js
generated
vendored
Normal file
2475
website/functions/node_modules/@google-cloud/storage/src/file.js
generated
vendored
Normal file
File diff suppressed because it is too large
Load Diff
300
website/functions/node_modules/@google-cloud/storage/src/iam.js
generated
vendored
Normal file
300
website/functions/node_modules/@google-cloud/storage/src/iam.js
generated
vendored
Normal file
@@ -0,0 +1,300 @@
|
||||
/*!
|
||||
* Copyright 2017 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache 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://www.apache.org/licenses/LICENSE-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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const arrify = require('arrify');
|
||||
const common = require('@google-cloud/common');
|
||||
const extend = require('extend');
|
||||
const is = require('is');
|
||||
|
||||
/**
|
||||
* Get and set IAM policies for your Cloud Storage bucket.
|
||||
*
|
||||
* @see [Cloud Storage IAM Management](https://cloud.google.com/storage/docs/access-control/iam#short_title_iam_management)
|
||||
* @see [Granting, Changing, and Revoking Access](https://cloud.google.com/iam/docs/granting-changing-revoking-access)
|
||||
* @see [IAM Roles](https://cloud.google.com/iam/docs/understanding-roles)
|
||||
*
|
||||
* @constructor Iam
|
||||
* @mixin
|
||||
*
|
||||
* @param {Bucket} bucket The parent instance.
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const bucket = storage.bucket('my-bucket');
|
||||
* // bucket.iam
|
||||
*/
|
||||
function Iam(bucket) {
|
||||
this.request_ = bucket.request.bind(bucket);
|
||||
this.resourceId_ = 'buckets/' + bucket.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @typedef {object} GetPolicyRequest
|
||||
* @property {string} userProject The ID of the project which will be billed for
|
||||
* the request.
|
||||
*/
|
||||
/**
|
||||
* @typedef {array} GetPolicyResponse
|
||||
* @property {object} 0 The policy.
|
||||
* @property {object} 1 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback GetPolicyCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object} acl The policy.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Get the IAM policy.
|
||||
*
|
||||
* @param {GetPolicyRequest} [options] Request options.
|
||||
* @param {GetPolicyCallback} [callback] Callback function.
|
||||
* @returns {Promise<GetPolicyResponse>}
|
||||
*
|
||||
* @see [Buckets: setIamPolicy API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/getIamPolicy}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const bucket = storage.bucket('my-bucket');
|
||||
* bucket.iam.getPolicy(function(err, policy, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* bucket.iam.getPolicy().then(function(data) {
|
||||
* const policy = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/iam.js</caption>
|
||||
* region_tag:storage_view_bucket_iam_members
|
||||
* Example of retrieving a bucket's IAM policy:
|
||||
*/
|
||||
Iam.prototype.getPolicy = function(options, callback) {
|
||||
if (is.fn(options)) {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
this.request_(
|
||||
{
|
||||
uri: '/iam',
|
||||
qs: options,
|
||||
},
|
||||
callback
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {array} SetPolicyResponse
|
||||
* @property {object} 0 The policy.
|
||||
* @property {object} 1 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback SetPolicyCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object} acl The policy.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Set the IAM policy.
|
||||
*
|
||||
* @throws {Error} If no policy is provided.
|
||||
*
|
||||
* @param {object} policy The policy.
|
||||
* @param {array} policy.bindings Bindings associate members with roles.
|
||||
* @param {string} [policy.etag] Etags are used to perform a read-modify-write.
|
||||
* @param {object} [options] Configuration opbject.
|
||||
* @param {string} [options.userProject] The ID of the project which will be
|
||||
* billed for the request.
|
||||
* @param {SetPolicyCallback} callback Callback function.
|
||||
* @returns {Promise<SetPolicyResponse>}
|
||||
*
|
||||
* @see [Buckets: setIamPolicy API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/setIamPolicy}
|
||||
* @see [IAM Roles](https://cloud.google.com/iam/docs/understanding-roles)
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const bucket = storage.bucket('my-bucket');
|
||||
*
|
||||
* const myPolicy = {
|
||||
* bindings: [
|
||||
* {
|
||||
* role: 'roles/storage.admin',
|
||||
* members: ['serviceAccount:myotherproject@appspot.gserviceaccount.com']
|
||||
* }
|
||||
* ]
|
||||
* };
|
||||
*
|
||||
* bucket.iam.setPolicy(myPolicy, function(err, policy, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* bucket.iam.setPolicy(myPolicy).then(function(data) {
|
||||
* const policy = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/iam.js</caption>
|
||||
* region_tag:storage_add_bucket_iam_member
|
||||
* Example of adding to a bucket's IAM policy:
|
||||
*
|
||||
* @example <caption>include:samples/iam.js</caption>
|
||||
* region_tag:storage_remove_bucket_iam_member
|
||||
* Example of removing from a bucket's IAM policy:
|
||||
*/
|
||||
Iam.prototype.setPolicy = function(policy, options, callback) {
|
||||
if (!is.object(policy)) {
|
||||
throw new Error('A policy object is required.');
|
||||
}
|
||||
|
||||
if (is.fn(options)) {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
this.request_(
|
||||
{
|
||||
method: 'PUT',
|
||||
uri: '/iam',
|
||||
json: extend(
|
||||
{
|
||||
resourceId: this.resourceId_,
|
||||
},
|
||||
policy
|
||||
),
|
||||
qs: options,
|
||||
},
|
||||
callback
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {array} TestIamPermissionsResponse
|
||||
* @property {object[]} 0 A subset of permissions that the caller is allowed.
|
||||
* @property {object} 1 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback TestIamPermissionsCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object[]} acl A subset of permissions that the caller is allowed.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Test a set of permissions for a resource.
|
||||
*
|
||||
* @throws {Error} If permissions are not provided.
|
||||
*
|
||||
* @param {string|string[]} permissions The permission(s) to test for.
|
||||
* @param {object} [options] Configuration object.
|
||||
* @param {string} [options.userProject] The ID of the project which will be
|
||||
* billed for the request.
|
||||
* @param {TestIamPermissionsCallback} [callback] Callback function.
|
||||
* @returns {Promise<TestIamPermissionsResponse>}
|
||||
*
|
||||
* @see [Buckets: testIamPermissions API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/testIamPermissions}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const bucket = storage.bucket('my-bucket');
|
||||
*
|
||||
* //-
|
||||
* // Test a single permission.
|
||||
* //-
|
||||
* const test = 'storage.buckets.delete';
|
||||
*
|
||||
* bucket.iam.testPermissions(test, function(err, permissions, apiResponse) {
|
||||
* console.log(permissions);
|
||||
* // {
|
||||
* // "storage.buckets.delete": true
|
||||
* // }
|
||||
* });
|
||||
*
|
||||
* //-
|
||||
* // Test several permissions at once.
|
||||
* //-
|
||||
* const tests = [
|
||||
* 'storage.buckets.delete',
|
||||
* 'storage.buckets.get'
|
||||
* ];
|
||||
*
|
||||
* bucket.iam.testPermissions(tests, function(err, permissions) {
|
||||
* console.log(permissions);
|
||||
* // {
|
||||
* // "storage.buckets.delete": false,
|
||||
* // "storage.buckets.get": true
|
||||
* // }
|
||||
* });
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* bucket.iam.testPermissions(test).then(function(data) {
|
||||
* const permissions = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*/
|
||||
Iam.prototype.testPermissions = function(permissions, options, callback) {
|
||||
if (!is.array(permissions) && !is.string(permissions)) {
|
||||
throw new Error('Permissions are required.');
|
||||
}
|
||||
|
||||
if (is.fn(options)) {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
options = extend(
|
||||
{
|
||||
permissions: arrify(permissions),
|
||||
},
|
||||
options
|
||||
);
|
||||
|
||||
this.request_(
|
||||
{
|
||||
uri: '/iam/testPermissions',
|
||||
qs: options,
|
||||
useQuerystring: true,
|
||||
},
|
||||
function(err, resp) {
|
||||
if (err) {
|
||||
callback(err, null, resp);
|
||||
return;
|
||||
}
|
||||
|
||||
const availablePermissions = arrify(resp.permissions);
|
||||
|
||||
const permissionsHash = permissions.reduce(function(acc, permission) {
|
||||
acc[permission] = availablePermissions.indexOf(permission) > -1;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
callback(null, permissionsHash, resp);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/*! Developer Documentation
|
||||
*
|
||||
* All async methods (except for streams) will return a Promise in the event
|
||||
* that a callback is omitted.
|
||||
*/
|
||||
common.util.promisifyAll(Iam);
|
||||
|
||||
module.exports = Iam;
|
591
website/functions/node_modules/@google-cloud/storage/src/index.js
generated
vendored
Normal file
591
website/functions/node_modules/@google-cloud/storage/src/index.js
generated
vendored
Normal file
@@ -0,0 +1,591 @@
|
||||
/**
|
||||
* Copyright 2014-2017 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache 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://www.apache.org/licenses/LICENSE-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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const arrify = require('arrify');
|
||||
const common = require('@google-cloud/common');
|
||||
const extend = require('extend');
|
||||
const util = require('util');
|
||||
|
||||
const Bucket = require('./bucket.js');
|
||||
const Channel = require('./channel.js');
|
||||
const File = require('./file.js');
|
||||
|
||||
/**
|
||||
* @typedef {object} ClientConfig
|
||||
* @property {string} [projectId] The project ID from the Google Developer's
|
||||
* Console, e.g. 'grape-spaceship-123'. We will also check the environment
|
||||
* variable `GCLOUD_PROJECT` for your project ID. If your app is running in
|
||||
* an environment which supports {@link https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application Application Default Credentials},
|
||||
* your project ID will be detected automatically.
|
||||
* @property {string} [keyFilename] Full path to the a .json, .pem, or .p12 key
|
||||
* downloaded from the Google Developers Console. If you provide a path to a
|
||||
* JSON file, the `projectId` option above is not necessary. NOTE: .pem and
|
||||
* .p12 require you to specify the `email` option as well.
|
||||
* @property {string} [email] Account email address. Required when using a .pem
|
||||
* or .p12 keyFilename.
|
||||
* @property {object} [credentials] Credentials object.
|
||||
* @property {string} [credentials.client_email]
|
||||
* @property {string} [credentials.private_key]
|
||||
* @property {boolean} [autoRetry=true] Automatically retry requests if the
|
||||
* response is related to rate limits or certain intermittent server errors.
|
||||
* We will exponentially backoff subsequent requests by default.
|
||||
* @property {number} [maxRetries=3] Maximum number of automatic retries
|
||||
* attempted before returning the error.
|
||||
* @property {Constructor} [promise] Custom promise module to use instead of
|
||||
* native Promises.
|
||||
*/
|
||||
|
||||
/*! Developer Documentation
|
||||
*
|
||||
* Invoke this method to create a new Storage object bound with pre-determined
|
||||
* configuration options. For each object that can be created (e.g., a bucket),
|
||||
* there is an equivalent static and instance method. While they are classes,
|
||||
* they can be instantiated without use of the `new` keyword.
|
||||
*/
|
||||
/**
|
||||
* <h4>ACLs</h4>
|
||||
* Cloud Storage uses access control lists (ACLs) to manage object and
|
||||
* bucket access. ACLs are the mechanism you use to share files with other users
|
||||
* and allow other users to access your buckets and files.
|
||||
*
|
||||
* To learn more about ACLs, read this overview on
|
||||
* [Access Control](https://cloud.google.com/storage/docs/access-control).
|
||||
*
|
||||
* @see [Cloud Storage overview]{@link https://cloud.google.com/storage/docs/overview}
|
||||
* @see [Access Control]{@link https://cloud.google.com/storage/docs/access-control}
|
||||
*
|
||||
* @class
|
||||
* @hideconstructor
|
||||
*
|
||||
* @example <caption>Create a client that uses Application Default Credentials (ADC)</caption>
|
||||
* const Storage = require('@google-cloud/storage');
|
||||
* const storage = new Storage();
|
||||
*
|
||||
* @example <caption>Create a client with explicit credentials</caption>
|
||||
* const Storage = require('@google-cloud/storage');
|
||||
* const storage = new Storage({
|
||||
* projectId: 'your-project-id',
|
||||
* keyFilename: '/path/to/keyfile.json'
|
||||
* });
|
||||
*
|
||||
* @param {ClientConfig} [options] Configuration options.
|
||||
*/
|
||||
function Storage(options) {
|
||||
if (!(this instanceof Storage)) {
|
||||
return new Storage(options);
|
||||
}
|
||||
|
||||
options = common.util.normalizeArguments(this, options);
|
||||
|
||||
const config = {
|
||||
baseUrl: 'https://www.googleapis.com/storage/v1',
|
||||
projectIdRequired: false,
|
||||
scopes: [
|
||||
'https://www.googleapis.com/auth/iam',
|
||||
'https://www.googleapis.com/auth/cloud-platform',
|
||||
'https://www.googleapis.com/auth/devstorage.full_control',
|
||||
],
|
||||
packageJson: require('../package.json'),
|
||||
};
|
||||
|
||||
common.Service.call(this, config, options);
|
||||
}
|
||||
|
||||
util.inherits(Storage, common.Service);
|
||||
|
||||
/**
|
||||
* Cloud Storage uses access control lists (ACLs) to manage object and
|
||||
* bucket access. ACLs are the mechanism you use to share objects with other
|
||||
* users and allow other users to access your buckets and objects.
|
||||
*
|
||||
* This object provides constants to refer to the three permission levels that
|
||||
* can be granted to an entity:
|
||||
*
|
||||
* - `gcs.acl.OWNER_ROLE` - ("OWNER")
|
||||
* - `gcs.acl.READER_ROLE` - ("READER")
|
||||
* - `gcs.acl.WRITER_ROLE` - ("WRITER")
|
||||
*
|
||||
* @see [About Access Control Lists]{@link https://cloud.google.com/storage/docs/access-control/lists}
|
||||
*
|
||||
* @name Storage.acl
|
||||
* @type {object}
|
||||
* @property {string} OWNER_ROLE
|
||||
* @property {string} READER_ROLE
|
||||
* @property {string} WRITER_ROLE
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const albums = storage.bucket('albums');
|
||||
*
|
||||
* //-
|
||||
* // Make all of the files currently in a bucket publicly readable.
|
||||
* //-
|
||||
* const options = {
|
||||
* entity: 'allUsers',
|
||||
* role: storage.acl.READER_ROLE
|
||||
* };
|
||||
*
|
||||
* albums.acl.add(options, function(err, aclObject) {});
|
||||
*
|
||||
* //-
|
||||
* // Make any new objects added to a bucket publicly readable.
|
||||
* //-
|
||||
* albums.acl.default.add(options, function(err, aclObject) {});
|
||||
*
|
||||
* //-
|
||||
* // Grant a user ownership permissions to a bucket.
|
||||
* //-
|
||||
* albums.acl.add({
|
||||
* entity: 'user-useremail@example.com',
|
||||
* role: storage.acl.OWNER_ROLE
|
||||
* }, function(err, aclObject) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* albums.acl.add(options).then(function(data) {
|
||||
* const aclObject = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*/
|
||||
Storage.acl = {
|
||||
OWNER_ROLE: 'OWNER',
|
||||
READER_ROLE: 'READER',
|
||||
WRITER_ROLE: 'WRITER',
|
||||
};
|
||||
|
||||
/**
|
||||
* Reference to {@link Storage.acl}.
|
||||
*
|
||||
* @name Storage#acl
|
||||
* @see Storage.acl
|
||||
*/
|
||||
Storage.prototype.acl = Storage.acl;
|
||||
|
||||
/**
|
||||
* Get a reference to a Cloud Storage bucket.
|
||||
*
|
||||
* @param {string} name Name of the bucket.
|
||||
* @param {object} [options] Configuration object.
|
||||
* @param {string} [options.kmsKeyName] A Cloud KMS key that will be used to
|
||||
* encrypt objects inserted into this bucket, if no encryption method is
|
||||
* specified.
|
||||
* @param {string} [options.userProject] User project to be billed for all
|
||||
* requests made from this Bucket object.
|
||||
* @returns {Bucket}
|
||||
* @see Bucket
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const albums = storage.bucket('albums');
|
||||
* const photos = storage.bucket('photos');
|
||||
*/
|
||||
Storage.prototype.bucket = function(name, options) {
|
||||
if (!name) {
|
||||
throw new Error('A bucket name is needed to use Cloud Storage.');
|
||||
}
|
||||
|
||||
return new Bucket(this, name, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Reference a channel to receive notifications about changes to your bucket.
|
||||
*
|
||||
* @param {string} id The ID of the channel.
|
||||
* @param {string} resourceId The resource ID of the channel.
|
||||
* @returns {Channel}
|
||||
* @see Channel
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const channel = storage.channel('id', 'resource-id');
|
||||
*/
|
||||
Storage.prototype.channel = function(id, resourceId) {
|
||||
return new Channel(this, id, resourceId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Metadata to set for the bucket.
|
||||
*
|
||||
* @typedef {object} CreateBucketRequest
|
||||
* @property {boolean} [coldline=false] Specify the storage class as Coldline.
|
||||
* @property {boolean} [dra=false] Specify the storage class as Durable Reduced
|
||||
* Availability.
|
||||
* @property {boolean} [multiRegional=false] Specify the storage class as
|
||||
* Multi-Regional.
|
||||
* @property {boolean} [nearline=false] Specify the storage class as Nearline.
|
||||
* @property {boolean} [regional=false] Specify the storage class as Regional.
|
||||
* @property {boolean} [requesterPays=false] **Early Access Testers Only**
|
||||
* Force the use of the User Project metadata field to assign operational
|
||||
* costs when an operation is made on a Bucket and its objects.
|
||||
* @property {string} [userProject] The ID of the project which will be billed
|
||||
* for the request.
|
||||
*/
|
||||
/**
|
||||
* @typedef {array} CreateBucketResponse
|
||||
* @property {Bucket} 0 The new {@link Bucket}.
|
||||
* @property {object} 1 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback CreateBucketCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {Bucket} bucket The new {@link Bucket}.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Create a bucket.
|
||||
*
|
||||
* Cloud Storage uses a flat namespace, so you can't create a bucket with
|
||||
* a name that is already in use. For more information, see
|
||||
* [Bucket Naming Guidelines](https://cloud.google.com/storage/docs/bucketnaming.html#requirements).
|
||||
*
|
||||
* @see [Buckets: insert API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/insert}
|
||||
* @see [Storage Classes]{@link https://cloud.google.com/storage/docs/storage-classes}
|
||||
*
|
||||
* @param {string} name Name of the bucket to create.
|
||||
* @param {CreateBucketRequest} [metadata] Metadata to set for the bucket.
|
||||
* @param {CreateBucketCallback} [callback] Callback function.
|
||||
* @returns {Promise<CreateBucketResponse>}
|
||||
* @throws {Error} If a name is not provided.
|
||||
* @see Bucket#create
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const callback = function(err, bucket, apiResponse) {
|
||||
* // `bucket` is a Bucket object.
|
||||
* };
|
||||
*
|
||||
* storage.createBucket('new-bucket', callback);
|
||||
*
|
||||
* //-
|
||||
* // Create a bucket in a specific location and region. <em>See the <a
|
||||
* // href="https://cloud.google.com/storage/docs/json_api/v1/buckets/insert">
|
||||
* // Official JSON API docs</a> for complete details on the `location` option.
|
||||
* // </em>
|
||||
* //-
|
||||
* const metadata = {
|
||||
* location: 'US-CENTRAL1',
|
||||
* regional: true
|
||||
* };
|
||||
*
|
||||
* storage.createBucket('new-bucket', metadata, callback);
|
||||
*
|
||||
* //-
|
||||
* // Enable versioning on a new bucket.
|
||||
* //-
|
||||
* const metadata = {
|
||||
* versioning: {
|
||||
* enabled: true
|
||||
* }
|
||||
* };
|
||||
*
|
||||
* storage.createBucket('new-bucket', metadata, callback);
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* storage.createBucket('new-bucket').then(function(data) {
|
||||
* const bucket = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/buckets.js</caption>
|
||||
* region_tag:storage_create_bucket
|
||||
* Another example:
|
||||
*/
|
||||
Storage.prototype.createBucket = function(name, metadata, callback) {
|
||||
const self = this;
|
||||
|
||||
if (!name) {
|
||||
throw new Error('A name is required to create a bucket.');
|
||||
}
|
||||
|
||||
if (!callback) {
|
||||
callback = metadata;
|
||||
metadata = {};
|
||||
}
|
||||
|
||||
const body = extend({}, metadata, {
|
||||
name: name,
|
||||
});
|
||||
|
||||
const storageClasses = {
|
||||
coldline: 'COLDLINE',
|
||||
dra: 'DURABLE_REDUCED_AVAILABILITY',
|
||||
multiRegional: 'MULTI_REGIONAL',
|
||||
nearline: 'NEARLINE',
|
||||
regional: 'REGIONAL',
|
||||
};
|
||||
|
||||
Object.keys(storageClasses).forEach(function(storageClass) {
|
||||
if (body[storageClass]) {
|
||||
body.storageClass = storageClasses[storageClass];
|
||||
delete body[storageClass];
|
||||
}
|
||||
});
|
||||
|
||||
if (body.requesterPays) {
|
||||
body.billing = {
|
||||
requesterPays: body.requesterPays,
|
||||
};
|
||||
delete body.requesterPays;
|
||||
}
|
||||
|
||||
const query = {
|
||||
project: this.projectId,
|
||||
};
|
||||
|
||||
if (body.userProject) {
|
||||
query.userProject = body.userProject;
|
||||
delete body.userProject;
|
||||
}
|
||||
|
||||
this.request(
|
||||
{
|
||||
method: 'POST',
|
||||
uri: '/b',
|
||||
qs: query,
|
||||
json: body,
|
||||
},
|
||||
function(err, resp) {
|
||||
if (err) {
|
||||
callback(err, null, resp);
|
||||
return;
|
||||
}
|
||||
|
||||
const bucket = self.bucket(name);
|
||||
bucket.metadata = resp;
|
||||
|
||||
callback(null, bucket, resp);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Query object for listing buckets.
|
||||
*
|
||||
* @typedef {object} GetBucketsRequest
|
||||
* @property {boolean} [autoPaginate=true] Have pagination handled
|
||||
* automatically.
|
||||
* @property {number} [maxApiCalls] Maximum number of API calls to make.
|
||||
* @property {number} [maxResults] Maximum number of items plus prefixes to
|
||||
* return.
|
||||
* @property {string} [pageToken] A previously-returned page token
|
||||
* representing part of the larger set of results to view.
|
||||
* @property {string} [userProject] The ID of the project which will be billed
|
||||
* for the request.
|
||||
*/
|
||||
/**
|
||||
* @typedef {array} GetBucketsResponse
|
||||
* @property {Bucket[]} 0 Array of {@link Bucket} instances.
|
||||
*/
|
||||
/**
|
||||
* @callback GetBucketsCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {Bucket[]} buckets Array of {@link Bucket} instances.
|
||||
*/
|
||||
/**
|
||||
* Get Bucket objects for all of the buckets in your project.
|
||||
*
|
||||
* @see [Buckets: list API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/buckets/list}
|
||||
*
|
||||
* @param {GetBucketsRequest} [query] Query object for listing buckets.
|
||||
* @param {GetBucketsCallback} [callback] Callback function.
|
||||
* @returns {Promise<GetBucketsResponse>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* storage.getBuckets(function(err, buckets) {
|
||||
* if (!err) {
|
||||
* // buckets is an array of Bucket objects.
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* //-
|
||||
* // To control how many API requests are made and page through the results
|
||||
* // manually, set `autoPaginate` to `false`.
|
||||
* //-
|
||||
* const callback = function(err, buckets, nextQuery, apiResponse) {
|
||||
* if (nextQuery) {
|
||||
* // More results exist.
|
||||
* storage.getBuckets(nextQuery, callback);
|
||||
* }
|
||||
*
|
||||
* // The `metadata` property is populated for you with the metadata at the
|
||||
* // time of fetching.
|
||||
* buckets[0].metadata;
|
||||
*
|
||||
* // However, in cases where you are concerned the metadata could have
|
||||
* // changed, use the `getMetadata` method.
|
||||
* buckets[0].getMetadata(function(err, metadata, apiResponse) {});
|
||||
* };
|
||||
*
|
||||
* storage.getBuckets({
|
||||
* autoPaginate: false
|
||||
* }, callback);
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* storage.getBuckets().then(function(data) {
|
||||
* const buckets = data[0];
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/buckets.js</caption>
|
||||
* region_tag:storage_list_buckets
|
||||
* Another example:
|
||||
*/
|
||||
Storage.prototype.getBuckets = function(query, callback) {
|
||||
const self = this;
|
||||
|
||||
if (!callback) {
|
||||
callback = query;
|
||||
query = {};
|
||||
}
|
||||
|
||||
query.project = query.project || this.projectId;
|
||||
|
||||
this.request(
|
||||
{
|
||||
uri: '/b',
|
||||
qs: query,
|
||||
},
|
||||
function(err, resp) {
|
||||
if (err) {
|
||||
callback(err, null, null, resp);
|
||||
return;
|
||||
}
|
||||
|
||||
const buckets = arrify(resp.items).map(function(bucket) {
|
||||
const bucketInstance = self.bucket(bucket.id);
|
||||
bucketInstance.metadata = bucket;
|
||||
return bucketInstance;
|
||||
});
|
||||
|
||||
let nextQuery = null;
|
||||
if (resp.nextPageToken) {
|
||||
nextQuery = extend({}, query, {pageToken: resp.nextPageToken});
|
||||
}
|
||||
|
||||
callback(null, buckets, nextQuery, resp);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* Get {@link Bucket} objects for all of the buckets in your project as
|
||||
* a readable object stream.
|
||||
*
|
||||
* @method Storage#getBucketsStream
|
||||
* @param {GetBucketsRequest} [query] Query object for listing buckets.
|
||||
* @returns {ReadableStream} A readable stream that emits {@link Bucket} instances.
|
||||
*
|
||||
* @example
|
||||
* storage.getBucketsStream()
|
||||
* .on('error', console.error)
|
||||
* .on('data', function(bucket) {
|
||||
* // bucket is a Bucket object.
|
||||
* })
|
||||
* .on('end', function() {
|
||||
* // All buckets retrieved.
|
||||
* });
|
||||
*
|
||||
* //-
|
||||
* // If you anticipate many results, you can end a stream early to prevent
|
||||
* // unnecessary processing and API requests.
|
||||
* //-
|
||||
* storage.getBucketsStream()
|
||||
* .on('data', function(bucket) {
|
||||
* this.end();
|
||||
* });
|
||||
*/
|
||||
Storage.prototype.getBucketsStream = common.paginator.streamify('getBuckets');
|
||||
|
||||
/*! Developer Documentation
|
||||
*
|
||||
* These methods can be auto-paginated.
|
||||
*/
|
||||
common.paginator.extend(Storage, 'getBuckets');
|
||||
|
||||
/*! Developer Documentation
|
||||
*
|
||||
* All async methods (except for streams) will return a Promise in the event
|
||||
* that a callback is omitted.
|
||||
*/
|
||||
common.util.promisifyAll(Storage, {
|
||||
exclude: ['bucket', 'channel'],
|
||||
});
|
||||
|
||||
/**
|
||||
* {@link Bucket} class.
|
||||
*
|
||||
* @name Storage.Bucket
|
||||
* @see Bucket
|
||||
* @type {Constructor}
|
||||
*/
|
||||
Storage.Bucket = Bucket;
|
||||
|
||||
/**
|
||||
* {@link Channel} class.
|
||||
*
|
||||
* @name Storage.Channel
|
||||
* @see Channel
|
||||
* @type {Constructor}
|
||||
*/
|
||||
Storage.Channel = Channel;
|
||||
|
||||
/**
|
||||
* {@link File} class.
|
||||
*
|
||||
* @name Storage.File
|
||||
* @see File
|
||||
* @type {Constructor}
|
||||
*/
|
||||
Storage.File = File;
|
||||
|
||||
/**
|
||||
* The default export of the `@google-cloud/storage` package is the
|
||||
* {@link Storage} class, which also serves as a factory function which produces
|
||||
* {@link Storage} instances.
|
||||
*
|
||||
* See {@link Storage} and {@link ClientConfig} for client methods and
|
||||
* configuration options.
|
||||
*
|
||||
* @module {Storage} @google-cloud/storage
|
||||
* @alias nodejs-storage
|
||||
*
|
||||
* @example <caption>Install the client library with <a href="https://www.npmjs.com/">npm</a>:</caption>
|
||||
* npm install --save @google-cloud/storage
|
||||
*
|
||||
* @example <caption>Import the client library</caption>
|
||||
* const Storage = require('@google-cloud/storage');
|
||||
*
|
||||
* @example <caption>Create a client that uses <a href="https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application">Application Default Credentials (ADC)</a>:</caption>
|
||||
* const storage = new Storage();
|
||||
*
|
||||
* @example <caption>Create a client with <a href="https://cloud.google.com/docs/authentication/production#obtaining_and_providing_service_account_credentials_manually">explicit credentials</a>:</caption>
|
||||
* const storage = new Storage({
|
||||
* projectId: 'your-project-id',
|
||||
* keyFilename: '/path/to/keyfile.json'
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/quickstart.js</caption>
|
||||
* region_tag:storage_quickstart
|
||||
* Full quickstart example:
|
||||
*/
|
||||
module.exports = Storage;
|
350
website/functions/node_modules/@google-cloud/storage/src/notification.js
generated
vendored
Normal file
350
website/functions/node_modules/@google-cloud/storage/src/notification.js
generated
vendored
Normal file
@@ -0,0 +1,350 @@
|
||||
/*!
|
||||
* Copyright 2017 Google Inc. All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache 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://www.apache.org/licenses/LICENSE-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.
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
const common = require('@google-cloud/common');
|
||||
const is = require('is');
|
||||
const util = require('util');
|
||||
|
||||
/**
|
||||
* A Notification object is created from your {@link Bucket} object using
|
||||
* {@link Bucket#notification}. Use it to interact with Cloud Pub/Sub
|
||||
* notifications.
|
||||
*
|
||||
* @see [Cloud Pub/Sub Notifications for Google Cloud Storage]{@link https://cloud.google.com/storage/docs/pubsub-notifications}
|
||||
*
|
||||
* @class
|
||||
* @hideconstructor
|
||||
*
|
||||
* @param {Bucket} bucket The bucket instance this notification is attached to.
|
||||
* @param {string} id The ID of the notification.
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
*
|
||||
* const notification = myBucket.notification('1');
|
||||
*/
|
||||
function Notification(bucket, id) {
|
||||
const methods = {
|
||||
/**
|
||||
* Creates a notification subscription for the bucket.
|
||||
*
|
||||
* @see [Notifications: insert]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/insert}
|
||||
*
|
||||
* @param {Topic|string} topic The Cloud PubSub topic to which this
|
||||
* subscription publishes. If the project ID is omitted, the current
|
||||
* project ID will be used.
|
||||
*
|
||||
* Acceptable formats are:
|
||||
* - `projects/grape-spaceship-123/topics/my-topic`
|
||||
*
|
||||
* - `my-topic`
|
||||
* @param {CreateNotificationRequest} [options] Metadata to set for
|
||||
* the notification.
|
||||
* @param {CreateNotificationCallback} [callback] Callback function.
|
||||
* @returns {Promise<CreateNotificationResponse>}
|
||||
* @throws {Error} If a valid topic is not provided.
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const notification = myBucket.notification('1');
|
||||
*
|
||||
* notification.create(function(err, notification, apiResponse) {
|
||||
* if (!err) {
|
||||
* // The notification was created successfully.
|
||||
* }
|
||||
* });
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* notification.create().then(function(data) {
|
||||
* const notification = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*/
|
||||
create: true,
|
||||
|
||||
/**
|
||||
* @typedef {array} NotificationExistsResponse
|
||||
* @property {boolean} 0 Whether the notification exists or not.
|
||||
*/
|
||||
/**
|
||||
* @callback NotificationExistsCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {boolean} exists Whether the notification exists or not.
|
||||
*/
|
||||
/**
|
||||
* Check if the notification exists.
|
||||
*
|
||||
* @param {NotificationExistsCallback} [callback] Callback function.
|
||||
* @returns {Promise<NotificationExistsResponse>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const notification = myBucket.notification('1');
|
||||
*
|
||||
* notification.exists(function(err, exists) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* notification.exists().then(function(data) {
|
||||
* const exists = data[0];
|
||||
* });
|
||||
*/
|
||||
exists: true,
|
||||
};
|
||||
|
||||
common.ServiceObject.call(this, {
|
||||
parent: bucket,
|
||||
baseUrl: '/notificationConfigs',
|
||||
id: id.toString(),
|
||||
createMethod: bucket.createNotification.bind(bucket),
|
||||
methods: methods,
|
||||
});
|
||||
}
|
||||
|
||||
util.inherits(Notification, common.ServiceObject);
|
||||
|
||||
/**
|
||||
* @typedef {array} DeleteNotificationResponse
|
||||
* @property {object} 0 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback DeleteNotificationCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Permanently deletes a notification subscription.
|
||||
*
|
||||
* @see [Notifications: delete API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/delete}
|
||||
*
|
||||
* @param {object} [options] Configuration options.
|
||||
* @param {string} [options.userProject] The ID of the project which will be
|
||||
* billed for the request.
|
||||
* @param {DeleteNotificationCallback} [callback] Callback function.
|
||||
* @returns {Promise<DeleteNotificationResponse>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const notification = myBucket.notification('1');
|
||||
*
|
||||
* notification.delete(function(err, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* notification.delete().then(function(data) {
|
||||
* const apiResponse = data[0];
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/notifications.js</caption>
|
||||
* region_tag:storage_delete_notification
|
||||
* Another example:
|
||||
*/
|
||||
Notification.prototype.delete = function(options, callback) {
|
||||
if (is.fn(options)) {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
this.request(
|
||||
{
|
||||
method: 'DELETE',
|
||||
uri: '',
|
||||
qs: options,
|
||||
},
|
||||
callback || common.util.noop
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {array} GetNotificationResponse
|
||||
* @property {Notification} 0 The {@link Notification}
|
||||
* @property {object} 1 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback GetNotificationCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {Notification} notification The {@link Notification}.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Get a notification and its metadata if it exists.
|
||||
*
|
||||
* @see [Notifications: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/get}
|
||||
*
|
||||
* @param {object} [options] Configuration options.
|
||||
* See {@link Bucket#createNotification} for create options.
|
||||
* @param {boolean} [options.autoCreate] Automatically create the object if
|
||||
* it does not exist. Default: `false`.
|
||||
* @param {string} [options.userProject] The ID of the project which will be
|
||||
* billed for the request.
|
||||
* @param {GetNotificationCallback} [callback] Callback function.
|
||||
* @return {Promise<GetNotificationCallback>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const notification = myBucket.notification('1');
|
||||
*
|
||||
* notification.get(function(err, notification, apiResponse) {
|
||||
* // `notification.metadata` has been populated.
|
||||
* });
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* notification.get().then(function(data) {
|
||||
* const notification = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*/
|
||||
Notification.prototype.get = function(options, callback) {
|
||||
const self = this;
|
||||
|
||||
if (is.fn(options)) {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
const autoCreate = options.autoCreate;
|
||||
delete options.autoCreate;
|
||||
|
||||
function onCreate(err, notification, apiResponse) {
|
||||
if (err) {
|
||||
if (err.code === 409) {
|
||||
self.get(options, callback);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(err, null, apiResponse);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, notification, apiResponse);
|
||||
}
|
||||
|
||||
this.getMetadata(options, function(err, metadata) {
|
||||
if (err) {
|
||||
if (err.code === 404 && autoCreate) {
|
||||
const args = [];
|
||||
|
||||
if (!is.empty(options)) {
|
||||
args.push(options);
|
||||
}
|
||||
|
||||
args.push(onCreate);
|
||||
|
||||
self.create.apply(self, args);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(err, null, metadata);
|
||||
return;
|
||||
}
|
||||
|
||||
callback(null, self, metadata);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* @typedef {array} GetNotificationMetadataResponse
|
||||
* @property {object} 0 The notification metadata.
|
||||
* @property {object} 1 The full API response.
|
||||
*/
|
||||
/**
|
||||
* @callback GetNotificationMetadataCallback
|
||||
* @param {?Error} err Request error, if any.
|
||||
* @param {object} files The notification metadata.
|
||||
* @param {object} apiResponse The full API response.
|
||||
*/
|
||||
/**
|
||||
* Get the notification's metadata.
|
||||
*
|
||||
* @see [Notifications: get API Documentation]{@link https://cloud.google.com/storage/docs/json_api/v1/notifications/get}
|
||||
*
|
||||
* @param {object} [options] Configuration options.
|
||||
* @param {string} [options.userProject] The ID of the project which will be
|
||||
* billed for the request.
|
||||
* @param {GetNotificationMetadataCallback} [callback] Callback function.
|
||||
* @returns {Promise<GetNotificationMetadataResponse>}
|
||||
*
|
||||
* @example
|
||||
* const storage = require('@google-cloud/storage')();
|
||||
* const myBucket = storage.bucket('my-bucket');
|
||||
* const notification = myBucket.notification('1');
|
||||
*
|
||||
* notification.getMetadata(function(err, metadata, apiResponse) {});
|
||||
*
|
||||
* //-
|
||||
* // If the callback is omitted, we'll return a Promise.
|
||||
* //-
|
||||
* notification.getMetadata().then(function(data) {
|
||||
* const metadata = data[0];
|
||||
* const apiResponse = data[1];
|
||||
* });
|
||||
*
|
||||
* @example <caption>include:samples/notifications.js</caption>
|
||||
* region_tag:storage_notifications_get_metadata
|
||||
* Another example:
|
||||
*/
|
||||
Notification.prototype.getMetadata = function(options, callback) {
|
||||
const self = this;
|
||||
|
||||
if (is.fn(options)) {
|
||||
callback = options;
|
||||
options = {};
|
||||
}
|
||||
|
||||
this.request(
|
||||
{
|
||||
uri: '',
|
||||
qs: options,
|
||||
},
|
||||
function(err, resp) {
|
||||
if (err) {
|
||||
callback(err, null, resp);
|
||||
return;
|
||||
}
|
||||
|
||||
self.metadata = resp;
|
||||
|
||||
callback(null, self.metadata, resp);
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
/*! Developer Documentation
|
||||
*
|
||||
* All async methods (except for streams) will return a Promise in the event
|
||||
* that a callback is omitted.
|
||||
*/
|
||||
common.util.promisifyAll(Notification);
|
||||
|
||||
/**
|
||||
* Reference to the {@link Notification} class.
|
||||
* @name module:@google-cloud/storage.Notification
|
||||
* @see Notification
|
||||
*/
|
||||
module.exports = Notification;
|
Reference in New Issue
Block a user