├── .eslintignore ├── .eslintrc.json ├── .gitattributes ├── .github ├── .OwlBot.lock.yaml ├── .OwlBot.yaml ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ ├── config.yml │ ├── feature_request.md │ ├── question.md │ └── support_request.md ├── PULL_REQUEST_TEMPLATE.md ├── auto-approve.yml ├── auto-label.yaml ├── blunderbuss.yml ├── flakybot.yaml ├── generated-files-bot.yml ├── release-please.yml ├── release-trigger.yml ├── sync-repo-settings.yaml └── workflows │ └── ci.yaml ├── .gitignore ├── .gitmodules ├── .jsdoc.js ├── .kokoro ├── .gitattributes ├── common.cfg ├── common_env_vars.cfg ├── continuous │ └── node14 │ │ ├── common.cfg │ │ ├── lint.cfg │ │ ├── samples-test.cfg │ │ ├── system-test.cfg │ │ └── test.cfg ├── docs.sh ├── lint.sh ├── populate-secrets.sh ├── presubmit │ ├── node14 │ │ ├── common.cfg │ │ ├── samples-test.cfg │ │ ├── system-test.cfg │ │ └── test.cfg │ └── windows │ │ ├── common.cfg │ │ └── test.cfg ├── publish-min.sh ├── publish.sh ├── release │ ├── common.cfg │ ├── docs-devsite.cfg │ ├── docs-devsite.sh │ ├── docs.cfg │ ├── docs.sh │ └── publish.cfg ├── samples-test.sh ├── system-test.sh ├── test.bat ├── test.sh ├── trampoline.sh └── trampoline_v2.sh ├── .mocharc.js ├── .nycrc ├── .prettierignore ├── .prettierrc.js ├── .readme-partials.yml ├── .repo-metadata.json ├── .trampolinerc ├── CHANGELOG.md ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── _static ├── _static │ └── guide-me.svg └── guide-me.svg ├── linkinator.config.json ├── owlbot.py ├── package.json ├── protos ├── google │ ├── cloud │ │ └── common_resources.proto │ └── logging │ │ ├── type │ │ ├── http_request.proto │ │ └── log_severity.proto │ │ └── v2 │ │ ├── log_entry.proto │ │ ├── logging.proto │ │ ├── logging_config.proto │ │ └── logging_metrics.proto ├── protos.d.ts ├── protos.js └── protos.json ├── renovate.json ├── samples ├── .eslintrc.yml ├── README.md ├── fluent.js ├── generated │ └── v2 │ │ ├── config_service_v2.copy_log_entries.js │ │ ├── config_service_v2.create_bucket.js │ │ ├── config_service_v2.create_bucket_async.js │ │ ├── config_service_v2.create_exclusion.js │ │ ├── config_service_v2.create_link.js │ │ ├── config_service_v2.create_sink.js │ │ ├── config_service_v2.create_view.js │ │ ├── config_service_v2.delete_bucket.js │ │ ├── config_service_v2.delete_exclusion.js │ │ ├── config_service_v2.delete_link.js │ │ ├── config_service_v2.delete_sink.js │ │ ├── config_service_v2.delete_view.js │ │ ├── config_service_v2.get_bucket.js │ │ ├── config_service_v2.get_cmek_settings.js │ │ ├── config_service_v2.get_exclusion.js │ │ ├── config_service_v2.get_link.js │ │ ├── config_service_v2.get_settings.js │ │ ├── config_service_v2.get_sink.js │ │ ├── config_service_v2.get_view.js │ │ ├── config_service_v2.list_buckets.js │ │ ├── config_service_v2.list_exclusions.js │ │ ├── config_service_v2.list_links.js │ │ ├── config_service_v2.list_sinks.js │ │ ├── config_service_v2.list_views.js │ │ ├── config_service_v2.undelete_bucket.js │ │ ├── config_service_v2.update_bucket.js │ │ ├── config_service_v2.update_bucket_async.js │ │ ├── config_service_v2.update_cmek_settings.js │ │ ├── config_service_v2.update_exclusion.js │ │ ├── config_service_v2.update_settings.js │ │ ├── config_service_v2.update_sink.js │ │ ├── config_service_v2.update_view.js │ │ ├── logging_service_v2.delete_log.js │ │ ├── logging_service_v2.list_log_entries.js │ │ ├── logging_service_v2.list_logs.js │ │ ├── logging_service_v2.list_monitored_resource_descriptors.js │ │ ├── logging_service_v2.tail_log_entries.js │ │ ├── logging_service_v2.write_log_entries.js │ │ ├── metrics_service_v2.create_log_metric.js │ │ ├── metrics_service_v2.delete_log_metric.js │ │ ├── metrics_service_v2.get_log_metric.js │ │ ├── metrics_service_v2.list_log_metrics.js │ │ ├── metrics_service_v2.update_log_metric.js │ │ ├── snippet_metadata.google.logging.v2.json │ │ └── snippet_metadata_google.logging.v2.json ├── http-request.js ├── logs.js ├── package.json ├── quickstart.js ├── sinks.js └── test │ ├── fluent.test.js │ ├── http-request.test.js │ ├── logs.test.js │ ├── quickstart.test.js │ └── sinks.test.js ├── src ├── entry.ts ├── index.ts ├── log-sync.ts ├── log.ts ├── middleware │ ├── express │ │ ├── index.ts │ │ └── make-middleware.ts │ └── index.ts ├── sink.ts ├── utils │ ├── common.ts │ ├── context.ts │ ├── http-request.ts │ ├── instrumentation.ts │ ├── log-common.ts │ └── metadata.ts └── v2 │ ├── config_service_v2_client.ts │ ├── config_service_v2_client_config.json │ ├── config_service_v2_proto_list.json │ ├── gapic_metadata.json │ ├── index.ts │ ├── logging_service_v2_client.ts │ ├── logging_service_v2_client_config.json │ ├── logging_service_v2_proto_list.json │ ├── metrics_service_v2_client.ts │ ├── metrics_service_v2_client_config.json │ └── metrics_service_v2_proto_list.json ├── system-test ├── fixtures │ └── sample │ │ └── src │ │ ├── index.js │ │ └── index.ts ├── install.ts └── logging.ts ├── test ├── entry.ts ├── gapic_config_service_v2_v2.ts ├── gapic_logging_service_v2_v2.ts ├── gapic_metrics_service_v2_v2.ts ├── index.ts ├── instrumentation.ts ├── log-sync.ts ├── log.ts ├── middleware │ └── express │ │ └── test-make-middleware.ts ├── sink.ts └── utils │ ├── common.ts │ ├── context.ts │ ├── http-request.ts │ ├── log-common.ts │ └── metadata.ts ├── tsconfig.json └── webpack.config.js /.eslintignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | **/coverage 3 | test/fixtures 4 | build/ 5 | docs/ 6 | protos/ 7 | **/env-tests-logging 8 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/gts" 3 | } 4 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.ts text eol=lf 2 | *.js text eol=lf 3 | protos/* linguist-generated 4 | **/api-extractor.json linguist-language=JSON-with-Comments 5 | -------------------------------------------------------------------------------- /.github/.OwlBot.lock.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | docker: 15 | image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest 16 | digest: sha256:68e1cece0d6d3336c4f1cb9d2857b020af5574dff6da6349293d1c6d4eea82d8 17 | # created: 2024-05-31T15:46:42.989947733Z 18 | -------------------------------------------------------------------------------- /.github/.OwlBot.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2021 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | docker: 15 | image: gcr.io/cloud-devrel-public-resources/owlbot-nodejs:latest 16 | 17 | 18 | deep-remove-regex: 19 | - /owl-bot-staging 20 | 21 | deep-copy-regex: 22 | - source: /google/logging/(v.*)/.*-nodejs/(.*) 23 | dest: /owl-bot-staging/$1/$2 24 | 25 | begin-after-commit-hash: fb91803ccef5d7c695139b22788b309e2197856b 26 | 27 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # Code owners file. 2 | # This file controls who is tagged for review for any given pull request. 3 | # 4 | # For syntax help see: 5 | # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax 6 | 7 | 8 | # The yoshi-nodejs team is the default owner for nodejs repositories. 9 | * @googleapis/yoshi-nodejs @googleapis/api-logging @googleapis/api-logging-partners 10 | 11 | # The github automation team is the default owner for the auto-approve file. 12 | .github/auto-approve.yml @googleapis/github-automation 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | labels: 'type: bug, priority: p2' 5 | --- 6 | 7 | Thanks for stopping by to let us know something could be better! 8 | 9 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 10 | 11 | 1) Is this a client library issue or a product issue? 12 | This is the client library for . We will only be able to assist with issues that pertain to the behaviors of this library. If the issue you're experiencing is due to the behavior of the product itself, please visit the [ Support page]() to reach the most relevant engineers. 13 | 14 | 2) Did someone already solve this? 15 | - Search the issues already opened: https://github.com/googleapis/nodejs-logging/issues 16 | - Search the issues on our "catch-all" repository: https://github.com/googleapis/google-cloud-node 17 | - Search or ask on StackOverflow (engineers monitor these tags): http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js 18 | 19 | 3) Do you have a support contract? 20 | Please create an issue in the [support console](https://cloud.google.com/support/) to ensure a timely response. 21 | 22 | If the support paths suggested above still do not result in a resolution, please provide the following details. 23 | 24 | #### Environment details 25 | 26 | - OS: 27 | - Node.js version: 28 | - npm version: 29 | - `@google-cloud/logging` version: 30 | 31 | #### Steps to reproduce 32 | 33 | 1. ? 34 | 2. ? 35 | 36 | Making sure to follow these steps will guarantee the quickest resolution possible. 37 | 38 | Thanks! 39 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | contact_links: 2 | - name: Google Cloud Support 3 | url: https://cloud.google.com/support/ 4 | about: If you have a support contract with Google, please use the Google Cloud Support portal. 5 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this library 4 | labels: 'type: feature request, priority: p3' 5 | --- 6 | 7 | Thanks for stopping by to let us know something could be better! 8 | 9 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 10 | 11 | **Is your feature request related to a problem? Please describe.** 12 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | **Describe alternatives you've considered** 16 | A clear and concise description of any alternative solutions or features you've considered. 17 | **Additional context** 18 | Add any other context or screenshots about the feature request here. 19 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/question.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Question 3 | about: Ask a question 4 | labels: 'type: question, priority: p3' 5 | --- 6 | 7 | Thanks for stopping by to ask us a question! Please make sure to include: 8 | - What you're trying to do 9 | - What code you've already tried 10 | - Any error messages you're getting 11 | 12 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 13 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/support_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Support request 3 | about: If you have a support contract with Google, please create an issue in the Google Cloud Support console. 4 | 5 | --- 6 | 7 | **PLEASE READ**: If you have a support contract with Google, please create an issue in the [support console](https://cloud.google.com/support/) instead of filing on GitHub. This will ensure a timely response. 8 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: 2 | - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/nodejs-logging/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea 3 | - [ ] Ensure the tests and linter pass 4 | - [ ] Code coverage does not decrease (if any source code was changed) 5 | - [ ] Appropriate docs were updated (if necessary) 6 | 7 | Fixes # 🦕 8 | -------------------------------------------------------------------------------- /.github/auto-approve.yml: -------------------------------------------------------------------------------- 1 | processes: 2 | - "NodeDependency" 3 | - "OwlBotTemplateChangesNode" 4 | - "OwlBotPRsNode" -------------------------------------------------------------------------------- /.github/auto-label.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2022 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | requestsize: 15 | enabled: true 16 | staleness: 17 | pullrequest: true 18 | old: 30 19 | extraold: 60 20 | -------------------------------------------------------------------------------- /.github/blunderbuss.yml: -------------------------------------------------------------------------------- 1 | assign_issues: 2 | - googleapis/api-logging-nodejs-reviewers 3 | assign_prs: 4 | - googleapis/api-logging-nodejs-reviewers 5 | -------------------------------------------------------------------------------- /.github/flakybot.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2024 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | issuePriority: p2 16 | 17 | -------------------------------------------------------------------------------- /.github/generated-files-bot.yml: -------------------------------------------------------------------------------- 1 | generatedFiles: 2 | - path: '.kokoro/**' 3 | message: '`.kokoro` files are templated and should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' 4 | - path: '.github/CODEOWNERS' 5 | message: 'CODEOWNERS should instead be modified via the `codeowner_team` property in .repo-metadata.json' 6 | - path: '.github/workflows/ci.yaml' 7 | message: '`.github/workflows/ci.yaml` (GitHub Actions) should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' 8 | - path: '.github/generated-files-bot.+(yml|yaml)' 9 | message: '`.github/generated-files-bot.(yml|yaml)` should be updated in [`synthtool`](https://github.com/googleapis/synthtool)' 10 | - path: 'README.md' 11 | message: '`README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml' 12 | - path: 'samples/README.md' 13 | message: '`samples/README.md` is managed by [`synthtool`](https://github.com/googleapis/synthtool). However, a partials file can be used to update the README, e.g.: https://github.com/googleapis/nodejs-storage/blob/main/.readme-partials.yaml' 14 | ignoreAuthors: 15 | - 'gcf-owl-bot[bot]' 16 | - 'yoshi-automation' 17 | -------------------------------------------------------------------------------- /.github/release-please.yml: -------------------------------------------------------------------------------- 1 | handleGHRelease: true 2 | releaseType: node 3 | extraFiles: ["src/utils/instrumentation.ts"] 4 | -------------------------------------------------------------------------------- /.github/release-trigger.yml: -------------------------------------------------------------------------------- 1 | enabled: true 2 | -------------------------------------------------------------------------------- /.github/sync-repo-settings.yaml: -------------------------------------------------------------------------------- 1 | branchProtectionRules: 2 | - pattern: main 3 | isAdminEnforced: true 4 | requiredApprovingReviewCount: 1 5 | requiresCodeOwnerReviews: true 6 | requiresStrictStatusChecks: true 7 | requiredStatusCheckContexts: 8 | - "ci/kokoro: Samples test" 9 | - "ci/kokoro: System test" 10 | - docs 11 | - lint 12 | - test (14) 13 | - test (16) 14 | - test (18) 15 | - test (20) 16 | - cla/google 17 | - windows 18 | - OwlBot Post Processor 19 | permissionRules: 20 | - team: yoshi-admins 21 | permission: admin 22 | - team: jsteam-admins 23 | permission: admin 24 | - team: jsteam 25 | permission: push 26 | - team: api-logging-partners 27 | permission: push 28 | 29 | -------------------------------------------------------------------------------- /.github/workflows/ci.yaml: -------------------------------------------------------------------------------- 1 | on: 2 | push: 3 | branches: 4 | - main 5 | pull_request: 6 | name: ci 7 | jobs: 8 | test: 9 | runs-on: ubuntu-latest 10 | strategy: 11 | matrix: 12 | node: [14, 16, 18, 20] 13 | steps: 14 | - uses: actions/checkout@v3 15 | - uses: actions/setup-node@v3 16 | with: 17 | node-version: ${{ matrix.node }} 18 | - run: node --version 19 | # The first installation step ensures that all of our production 20 | # dependencies work on the given Node.js version, this helps us find 21 | # dependencies that don't match our engines field: 22 | - run: npm install --production --engine-strict --ignore-scripts --no-package-lock 23 | # Clean up the production install, before installing dev/production: 24 | - run: rm -rf node_modules 25 | - run: npm install --engine-strict 26 | - run: npm test 27 | env: 28 | MOCHA_THROW_DEPRECATION: false 29 | windows: 30 | runs-on: windows-latest 31 | steps: 32 | - uses: actions/checkout@v3 33 | - uses: actions/setup-node@v3 34 | with: 35 | node-version: 14 36 | - run: npm install --engine-strict 37 | - run: npm test 38 | env: 39 | MOCHA_THROW_DEPRECATION: false 40 | lint: 41 | runs-on: ubuntu-latest 42 | steps: 43 | - uses: actions/checkout@v3 44 | - uses: actions/setup-node@v3 45 | with: 46 | node-version: 14 47 | - run: npm install 48 | - run: npm run lint 49 | docs: 50 | runs-on: ubuntu-latest 51 | steps: 52 | - uses: actions/checkout@v3 53 | - uses: actions/setup-node@v3 54 | with: 55 | node-version: 14 56 | - run: npm install 57 | - run: npm run docs 58 | - uses: JustinBeckwith/linkinator-action@v1 59 | with: 60 | paths: docs/ 61 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | **/*.log 2 | **/node_modules 3 | /.coverage 4 | /coverage 5 | /.nyc_output 6 | /docs/ 7 | /out/ 8 | /build/ 9 | system-test/secrets.js 10 | system-test/*key.json 11 | *.lock 12 | .DS_Store 13 | package-lock.json 14 | __pycache__ 15 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "env-tests-logging"] 2 | path = env-tests-logging 3 | url = https://github.com/googleapis/env-tests-logging 4 | ignore = dirty 5 | -------------------------------------------------------------------------------- /.jsdoc.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | module.exports = { 22 | opts: { 23 | readme: './README.md', 24 | package: './package.json', 25 | template: './node_modules/jsdoc-fresh', 26 | recurse: true, 27 | verbose: true, 28 | destination: './docs/' 29 | }, 30 | plugins: [ 31 | 'plugins/markdown', 32 | 'jsdoc-region-tag' 33 | ], 34 | source: { 35 | excludePattern: '(^|\\/|\\\\)[._]', 36 | include: [ 37 | 'build/src', 38 | 'protos' 39 | ], 40 | includePattern: '\\.js$' 41 | }, 42 | templates: { 43 | copyright: 'Copyright 2024 Google LLC', 44 | includeDate: false, 45 | sourceFiles: false, 46 | systemName: '@google-cloud/logging', 47 | theme: 'lumen', 48 | default: { 49 | outputSourceFiles: false 50 | } 51 | }, 52 | markdown: { 53 | idInHeadings: true 54 | } 55 | }; 56 | -------------------------------------------------------------------------------- /.kokoro/.gitattributes: -------------------------------------------------------------------------------- 1 | * linguist-generated=true 2 | -------------------------------------------------------------------------------- /.kokoro/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | } 8 | } 9 | 10 | # Download trampoline resources. 11 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 12 | 13 | # Use the trampoline script to run in docker. 14 | build_file: "nodejs-logging/.kokoro/trampoline_v2.sh" 15 | 16 | # Configure the docker image for kokoro-trampoline. 17 | env_vars: { 18 | key: "TRAMPOLINE_IMAGE" 19 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 20 | } 21 | env_vars: { 22 | key: "TRAMPOLINE_BUILD_FILE" 23 | value: "github/nodejs-logging/.kokoro/test.sh" 24 | } 25 | 26 | 27 | ############################################# 28 | # this section merged from .kokoro/common_env_vars.cfg using owlbot.py 29 | 30 | env_vars: { 31 | key: "PRODUCT_AREA_LABEL" 32 | value: "observability" 33 | } 34 | env_vars: { 35 | key: "PRODUCT_LABEL" 36 | value: "logging" 37 | } 38 | env_vars: { 39 | key: "LANGUAGE_LABEL" 40 | value: "nodejs" 41 | } 42 | 43 | ################################################### 44 | 45 | -------------------------------------------------------------------------------- /.kokoro/common_env_vars.cfg: -------------------------------------------------------------------------------- 1 | 2 | ############################################# 3 | # this section merged from .kokoro/common_env_vars.cfg using owlbot.py 4 | 5 | env_vars: { 6 | key: "PRODUCT_AREA_LABEL" 7 | value: "observability" 8 | } 9 | env_vars: { 10 | key: "PRODUCT_LABEL" 11 | value: "logging" 12 | } 13 | env_vars: { 14 | key: "LANGUAGE_LABEL" 15 | value: "nodejs" 16 | } 17 | 18 | ################################################### 19 | 20 | -------------------------------------------------------------------------------- /.kokoro/continuous/node14/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | } 8 | } 9 | 10 | # Download trampoline resources. 11 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 12 | 13 | # Use the trampoline script to run in docker. 14 | build_file: "nodejs-logging/.kokoro/trampoline_v2.sh" 15 | 16 | # Configure the docker image for kokoro-trampoline. 17 | env_vars: { 18 | key: "TRAMPOLINE_IMAGE" 19 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 20 | } 21 | env_vars: { 22 | key: "TRAMPOLINE_BUILD_FILE" 23 | value: "github/nodejs-logging/.kokoro/test.sh" 24 | } 25 | 26 | 27 | ############################################# 28 | # this section merged from .kokoro/common_env_vars.cfg using owlbot.py 29 | 30 | env_vars: { 31 | key: "PRODUCT_AREA_LABEL" 32 | value: "observability" 33 | } 34 | env_vars: { 35 | key: "PRODUCT_LABEL" 36 | value: "logging" 37 | } 38 | env_vars: { 39 | key: "LANGUAGE_LABEL" 40 | value: "nodejs" 41 | } 42 | 43 | ################################################### 44 | 45 | -------------------------------------------------------------------------------- /.kokoro/continuous/node14/lint.cfg: -------------------------------------------------------------------------------- 1 | env_vars: { 2 | key: "TRAMPOLINE_BUILD_FILE" 3 | value: "github/nodejs-logging/.kokoro/lint.sh" 4 | } 5 | -------------------------------------------------------------------------------- /.kokoro/continuous/node14/samples-test.cfg: -------------------------------------------------------------------------------- 1 | # Download resources for system tests (service account key, etc.) 2 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" 3 | 4 | env_vars: { 5 | key: "TRAMPOLINE_BUILD_FILE" 6 | value: "github/nodejs-logging/.kokoro/samples-test.sh" 7 | } 8 | 9 | env_vars: { 10 | key: "SECRET_MANAGER_KEYS" 11 | value: "long-door-651-kokoro-system-test-service-account" 12 | } -------------------------------------------------------------------------------- /.kokoro/continuous/node14/system-test.cfg: -------------------------------------------------------------------------------- 1 | # Download resources for system tests (service account key, etc.) 2 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" 3 | 4 | env_vars: { 5 | key: "TRAMPOLINE_BUILD_FILE" 6 | value: "github/nodejs-logging/.kokoro/system-test.sh" 7 | } 8 | 9 | env_vars: { 10 | key: "SECRET_MANAGER_KEYS" 11 | value: "long-door-651-kokoro-system-test-service-account" 12 | } -------------------------------------------------------------------------------- /.kokoro/continuous/node14/test.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/nodejs-logging/9d1d480406c4d1526c8a7fafd9b18379c0c7fcea/.kokoro/continuous/node14/test.cfg -------------------------------------------------------------------------------- /.kokoro/docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | cd $(dirname $0)/.. 22 | 23 | npm install 24 | 25 | npm run docs-test 26 | -------------------------------------------------------------------------------- /.kokoro/lint.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | cd $(dirname $0)/.. 22 | 23 | npm install 24 | 25 | # Install and link samples 26 | if [ -f samples/package.json ]; then 27 | cd samples/ 28 | npm link ../ 29 | npm install 30 | cd .. 31 | fi 32 | 33 | npm run lint 34 | -------------------------------------------------------------------------------- /.kokoro/populate-secrets.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2020 Google LLC. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # This file is called in the early stage of `trampoline_v2.sh` to 17 | # populate secrets needed for the CI builds. 18 | 19 | set -eo pipefail 20 | 21 | function now { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n' ;} 22 | function msg { println "$*" >&2 ;} 23 | function println { printf '%s\n' "$(now) $*" ;} 24 | 25 | # Populates requested secrets set in SECRET_MANAGER_KEYS 26 | 27 | # In Kokoro CI builds, we use the service account attached to the 28 | # Kokoro VM. This means we need to setup auth on other CI systems. 29 | # For local run, we just use the gcloud command for retrieving the 30 | # secrets. 31 | 32 | if [[ "${RUNNING_IN_CI:-}" == "true" ]]; then 33 | GCLOUD_COMMANDS=( 34 | "docker" 35 | "run" 36 | "--entrypoint=gcloud" 37 | "--volume=${KOKORO_GFILE_DIR}:${KOKORO_GFILE_DIR}" 38 | "gcr.io/google.com/cloudsdktool/cloud-sdk" 39 | ) 40 | if [[ "${TRAMPOLINE_CI:-}" == "kokoro" ]]; then 41 | SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" 42 | else 43 | echo "Authentication for this CI system is not implemented yet." 44 | exit 2 45 | # TODO: Determine appropriate SECRET_LOCATION and the GCLOUD_COMMANDS. 46 | fi 47 | else 48 | # For local run, use /dev/shm or temporary directory for 49 | # KOKORO_GFILE_DIR. 50 | if [[ -d "/dev/shm" ]]; then 51 | export KOKORO_GFILE_DIR=/dev/shm 52 | else 53 | export KOKORO_GFILE_DIR=$(mktemp -d -t ci-XXXXXXXX) 54 | fi 55 | SECRET_LOCATION="${KOKORO_GFILE_DIR}/secret_manager" 56 | GCLOUD_COMMANDS=("gcloud") 57 | fi 58 | 59 | msg "Creating folder on disk for secrets: ${SECRET_LOCATION}" 60 | mkdir -p ${SECRET_LOCATION} 61 | 62 | for key in $(echo ${SECRET_MANAGER_KEYS} | sed "s/,/ /g") 63 | do 64 | msg "Retrieving secret ${key}" 65 | "${GCLOUD_COMMANDS[@]}" \ 66 | secrets versions access latest \ 67 | --project cloud-devrel-kokoro-resources \ 68 | --secret $key > \ 69 | "$SECRET_LOCATION/$key" 70 | if [[ $? == 0 ]]; then 71 | msg "Secret written to ${SECRET_LOCATION}/${key}" 72 | else 73 | msg "Error retrieving secret ${key}" 74 | exit 2 75 | fi 76 | done 77 | -------------------------------------------------------------------------------- /.kokoro/presubmit/node14/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | # Build logs will be here 4 | action { 5 | define_artifacts { 6 | regex: "**/*sponge_log.xml" 7 | } 8 | } 9 | 10 | # Download trampoline resources. 11 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 12 | 13 | # Use the trampoline script to run in docker. 14 | build_file: "nodejs-logging/.kokoro/trampoline_v2.sh" 15 | 16 | # Configure the docker image for kokoro-trampoline. 17 | env_vars: { 18 | key: "TRAMPOLINE_IMAGE" 19 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 20 | } 21 | env_vars: { 22 | key: "TRAMPOLINE_BUILD_FILE" 23 | value: "github/nodejs-logging/.kokoro/test.sh" 24 | } 25 | -------------------------------------------------------------------------------- /.kokoro/presubmit/node14/samples-test.cfg: -------------------------------------------------------------------------------- 1 | # Download resources for system tests (service account key, etc.) 2 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" 3 | 4 | env_vars: { 5 | key: "TRAMPOLINE_BUILD_FILE" 6 | value: "github/nodejs-logging/.kokoro/samples-test.sh" 7 | } 8 | 9 | env_vars: { 10 | key: "SECRET_MANAGER_KEYS" 11 | value: "long-door-651-kokoro-system-test-service-account" 12 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/node14/system-test.cfg: -------------------------------------------------------------------------------- 1 | # Download resources for system tests (service account key, etc.) 2 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/google-cloud-nodejs" 3 | 4 | env_vars: { 5 | key: "TRAMPOLINE_BUILD_FILE" 6 | value: "github/nodejs-logging/.kokoro/system-test.sh" 7 | } 8 | 9 | env_vars: { 10 | key: "SECRET_MANAGER_KEYS" 11 | value: "long-door-651-kokoro-system-test-service-account" 12 | } -------------------------------------------------------------------------------- /.kokoro/presubmit/node14/test.cfg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/googleapis/nodejs-logging/9d1d480406c4d1526c8a7fafd9b18379c0c7fcea/.kokoro/presubmit/node14/test.cfg -------------------------------------------------------------------------------- /.kokoro/presubmit/windows/common.cfg: -------------------------------------------------------------------------------- 1 | # Format: //devtools/kokoro/config/proto/build.proto 2 | 3 | -------------------------------------------------------------------------------- /.kokoro/presubmit/windows/test.cfg: -------------------------------------------------------------------------------- 1 | # Use the test file directly 2 | build_file: "nodejs-logging/.kokoro/test.bat" 3 | -------------------------------------------------------------------------------- /.kokoro/publish-min.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | # `npm postpublish` script that ships an minified version of this library 18 | # Todo(nicolezhu): Eventually deprecate this script for go/nodejs-logging-lite 19 | 20 | set -eo pipefail 21 | 22 | # Uglify /build to publish a smaller package 23 | for d in $(find ./build/ -maxdepth 8 -type d) 24 | do 25 | pushd $d 26 | for f in *.js; do 27 | [ -f "$f" ] || break 28 | 29 | if [ -f "$f.map" ]; then 30 | # Keep original .ts source mappings 31 | uglifyjs --source-map "content='$f.map', url='$f.map'" "$f" --output "$f" 32 | else 33 | uglifyjs "$f" --output "$f" 34 | fi 35 | done 36 | popd 37 | done 38 | 39 | # Change and publish under package name `@google-cloud/logging-min` 40 | sed -i -e 's/"name": "@google-cloud\/logging"/"name": "@google-cloud\/logging-min"/' package.json 41 | if [ -f "package.json-e" ]; then 42 | rm package.json-e 43 | fi 44 | 45 | # Note: ignore the postpublish script here to avoid an endless publish loop. 46 | npm publish --ignore-scripts --access=public --registry=https://wombat-dressing-room.appspot.com 47 | -------------------------------------------------------------------------------- /.kokoro/publish.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | # Start the releasetool reporter 22 | python3 -m releasetool publish-reporter-script > /tmp/publisher-script; source /tmp/publisher-script 23 | 24 | cd $(dirname $0)/.. 25 | 26 | NPM_TOKEN=$(cat $KOKORO_KEYSTORE_DIR/73713_google-cloud-npm-token-1) 27 | echo "//wombat-dressing-room.appspot.com/:_authToken=${NPM_TOKEN}" > ~/.npmrc 28 | 29 | npm install 30 | npm pack . 31 | # npm provides no way to specify, observe, or predict the name of the tarball 32 | # file it generates. We have to look in the current directory for the freshest 33 | # .tgz file. 34 | TARBALL=$(ls -1 -t *.tgz | head -1) 35 | 36 | npm publish --access=public --registry=https://wombat-dressing-room.appspot.com "$TARBALL" 37 | 38 | # Kokoro collects *.tgz and package-lock.json files and stores them in Placer 39 | # so we can generate SBOMs and attestations. 40 | # However, we *don't* want Kokoro to collect package-lock.json and *.tgz files 41 | # that happened to be installed with dependencies. 42 | find node_modules -name package-lock.json -o -name "*.tgz" | xargs rm -f -------------------------------------------------------------------------------- /.kokoro/release/common.cfg: -------------------------------------------------------------------------------- 1 | before_action { 2 | fetch_keystore { 3 | keystore_resource { 4 | keystore_config_id: 73713 5 | keyname: "yoshi-automation-github-key" 6 | } 7 | } 8 | } 9 | 10 | env_vars: { 11 | key: "PRODUCT_AREA_LABEL" 12 | value: "observability" 13 | } 14 | env_vars: { 15 | key: "PRODUCT_LABEL" 16 | value: "logging" 17 | } 18 | env_vars: { 19 | key: "LANGUAGE_LABEL" 20 | value: "nodejs" 21 | } 22 | -------------------------------------------------------------------------------- /.kokoro/release/docs-devsite.cfg: -------------------------------------------------------------------------------- 1 | # service account used to publish up-to-date docs. 2 | before_action { 3 | fetch_keystore { 4 | keystore_resource { 5 | keystore_config_id: 73713 6 | keyname: "docuploader_service_account" 7 | } 8 | } 9 | } 10 | 11 | # doc publications use a Python image. 12 | env_vars: { 13 | key: "TRAMPOLINE_IMAGE" 14 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 15 | } 16 | 17 | # Download trampoline resources. 18 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 19 | 20 | # Use the trampoline script to run in docker. 21 | build_file: "nodejs-logging/.kokoro/trampoline_v2.sh" 22 | 23 | env_vars: { 24 | key: "TRAMPOLINE_BUILD_FILE" 25 | value: "github/nodejs-logging/.kokoro/release/docs-devsite.sh" 26 | } 27 | -------------------------------------------------------------------------------- /.kokoro/release/docs-devsite.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2021 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | if [[ -z "$CREDENTIALS" ]]; then 20 | # if CREDENTIALS are explicitly set, assume we're testing locally 21 | # and don't set NPM_CONFIG_PREFIX. 22 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 23 | export PATH="$PATH:${NPM_CONFIG_PREFIX}/bin" 24 | cd $(dirname $0)/../.. 25 | fi 26 | 27 | npm install 28 | npm install --no-save @google-cloud/cloud-rad@^0.4.0 29 | # publish docs to devsite 30 | npx @google-cloud/cloud-rad . cloud-rad 31 | -------------------------------------------------------------------------------- /.kokoro/release/docs.cfg: -------------------------------------------------------------------------------- 1 | # service account used to publish up-to-date docs. 2 | before_action { 3 | fetch_keystore { 4 | keystore_resource { 5 | keystore_config_id: 73713 6 | keyname: "docuploader_service_account" 7 | } 8 | } 9 | } 10 | 11 | # doc publications use a Python image. 12 | env_vars: { 13 | key: "TRAMPOLINE_IMAGE" 14 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 15 | } 16 | 17 | # Download trampoline resources. 18 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 19 | 20 | # Use the trampoline script to run in docker. 21 | build_file: "nodejs-logging/.kokoro/trampoline_v2.sh" 22 | 23 | env_vars: { 24 | key: "TRAMPOLINE_BUILD_FILE" 25 | value: "github/nodejs-logging/.kokoro/release/docs.sh" 26 | } 27 | -------------------------------------------------------------------------------- /.kokoro/release/docs.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2019 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | # build jsdocs (Python is installed on the Node 10 docker image). 20 | if [[ -z "$CREDENTIALS" ]]; then 21 | # if CREDENTIALS are explicitly set, assume we're testing locally 22 | # and don't set NPM_CONFIG_PREFIX. 23 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 24 | export PATH="$PATH:${NPM_CONFIG_PREFIX}/bin" 25 | cd $(dirname $0)/../.. 26 | fi 27 | npm install 28 | npm run docs 29 | 30 | # create docs.metadata, based on package.json and .repo-metadata.json. 31 | npm i json@9.0.6 -g 32 | python3 -m docuploader create-metadata \ 33 | --name=$(cat .repo-metadata.json | json name) \ 34 | --version=$(cat package.json | json version) \ 35 | --language=$(cat .repo-metadata.json | json language) \ 36 | --distribution-name=$(cat .repo-metadata.json | json distribution_name) \ 37 | --product-page=$(cat .repo-metadata.json | json product_documentation) \ 38 | --github-repository=$(cat .repo-metadata.json | json repo) \ 39 | --issue-tracker=$(cat .repo-metadata.json | json issue_tracker) 40 | cp docs.metadata ./docs/docs.metadata 41 | 42 | # deploy the docs. 43 | if [[ -z "$CREDENTIALS" ]]; then 44 | CREDENTIALS=${KOKORO_KEYSTORE_DIR}/73713_docuploader_service_account 45 | fi 46 | if [[ -z "$BUCKET" ]]; then 47 | BUCKET=docs-staging 48 | fi 49 | python3 -m docuploader upload ./docs --credentials $CREDENTIALS --staging-bucket $BUCKET 50 | -------------------------------------------------------------------------------- /.kokoro/release/publish.cfg: -------------------------------------------------------------------------------- 1 | before_action { 2 | fetch_keystore { 3 | keystore_resource { 4 | keystore_config_id: 73713 5 | keyname: "docuploader_service_account" 6 | } 7 | } 8 | } 9 | 10 | before_action { 11 | fetch_keystore { 12 | keystore_resource { 13 | keystore_config_id: 73713 14 | keyname: "google-cloud-npm-token-1" 15 | } 16 | } 17 | } 18 | 19 | env_vars: { 20 | key: "SECRET_MANAGER_KEYS" 21 | value: "releasetool-publish-reporter-app,releasetool-publish-reporter-googleapis-installation,releasetool-publish-reporter-pem" 22 | } 23 | 24 | # Download trampoline resources. 25 | gfile_resources: "/bigstore/cloud-devrel-kokoro-resources/trampoline" 26 | 27 | # Use the trampoline script to run in docker. 28 | build_file: "nodejs-logging/.kokoro/trampoline_v2.sh" 29 | 30 | # Configure the docker image for kokoro-trampoline. 31 | env_vars: { 32 | key: "TRAMPOLINE_IMAGE" 33 | value: "gcr.io/cloud-devrel-kokoro-resources/node:14-user" 34 | } 35 | 36 | env_vars: { 37 | key: "TRAMPOLINE_BUILD_FILE" 38 | value: "github/nodejs-logging/.kokoro/publish.sh" 39 | } 40 | 41 | # Store the packages we uploaded to npmjs.org and their corresponding 42 | # package-lock.jsons in Placer. That way, we have a record of exactly 43 | # what we published, and which version of which tools we used to publish 44 | # it, which we can use to generate SBOMs and attestations. 45 | action { 46 | define_artifacts { 47 | regex: "github/**/*.tgz" 48 | regex: "github/**/package-lock.json" 49 | strip_prefix: "github" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /.kokoro/samples-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | # Setup service account credentials. 22 | export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account 23 | export GCLOUD_PROJECT=long-door-651 24 | 25 | cd $(dirname $0)/.. 26 | 27 | # Run a pre-test hook, if a pre-samples-test.sh is in the project 28 | if [ -f .kokoro/pre-samples-test.sh ]; then 29 | set +x 30 | . .kokoro/pre-samples-test.sh 31 | set -x 32 | fi 33 | 34 | if [ -f samples/package.json ]; then 35 | npm install 36 | 37 | # Install and link samples 38 | cd samples/ 39 | npm link ../ 40 | npm install 41 | cd .. 42 | # If tests are running against main branch, configure flakybot 43 | # to open issues on failures: 44 | if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then 45 | export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml 46 | export MOCHA_REPORTER=xunit 47 | cleanup() { 48 | chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot 49 | $KOKORO_GFILE_DIR/linux_amd64/flakybot 50 | } 51 | trap cleanup EXIT HUP 52 | fi 53 | 54 | npm run samples-test 55 | fi 56 | 57 | # codecov combines coverage across integration and unit tests. Include 58 | # the logic below for any environment you wish to collect coverage for: 59 | COVERAGE_NODE=14 60 | if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then 61 | NYC_BIN=./node_modules/nyc/bin/nyc.js 62 | if [ -f "$NYC_BIN" ]; then 63 | $NYC_BIN report || true 64 | fi 65 | bash $KOKORO_GFILE_DIR/codecov.sh 66 | else 67 | echo "coverage is only reported for Node $COVERAGE_NODE" 68 | fi 69 | -------------------------------------------------------------------------------- /.kokoro/system-test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | # Setup service account credentials. 22 | export GOOGLE_APPLICATION_CREDENTIALS=${KOKORO_GFILE_DIR}/secret_manager/long-door-651-kokoro-system-test-service-account 23 | export GCLOUD_PROJECT=long-door-651 24 | 25 | cd $(dirname $0)/.. 26 | 27 | # Run a pre-test hook, if a pre-system-test.sh is in the project 28 | if [ -f .kokoro/pre-system-test.sh ]; then 29 | set +x 30 | . .kokoro/pre-system-test.sh 31 | set -x 32 | fi 33 | 34 | npm install 35 | 36 | # If tests are running against main branch, configure flakybot 37 | # to open issues on failures: 38 | if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then 39 | export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml 40 | export MOCHA_REPORTER=xunit 41 | cleanup() { 42 | chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot 43 | $KOKORO_GFILE_DIR/linux_amd64/flakybot 44 | } 45 | trap cleanup EXIT HUP 46 | fi 47 | 48 | npm run system-test 49 | 50 | # codecov combines coverage across integration and unit tests. Include 51 | # the logic below for any environment you wish to collect coverage for: 52 | COVERAGE_NODE=14 53 | if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then 54 | NYC_BIN=./node_modules/nyc/bin/nyc.js 55 | if [ -f "$NYC_BIN" ]; then 56 | $NYC_BIN report || true 57 | fi 58 | bash $KOKORO_GFILE_DIR/codecov.sh 59 | else 60 | echo "coverage is only reported for Node $COVERAGE_NODE" 61 | fi 62 | -------------------------------------------------------------------------------- /.kokoro/test.bat: -------------------------------------------------------------------------------- 1 | @rem Copyright 2018 Google LLC. All rights reserved. 2 | @rem 3 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 4 | @rem you may not use this file except in compliance with the License. 5 | @rem You may obtain a copy of the License at 6 | @rem 7 | @rem http://www.apache.org/licenses/LICENSE-2.0 8 | @rem 9 | @rem Unless required by applicable law or agreed to in writing, software 10 | @rem distributed under the License is distributed on an "AS IS" BASIS, 11 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | @rem See the License for the specific language governing permissions and 13 | @rem limitations under the License. 14 | 15 | @echo "Starting Windows build" 16 | 17 | cd /d %~dp0 18 | cd .. 19 | 20 | @rem npm path is not currently set in our image, we should fix this next time 21 | @rem we upgrade Node.js in the image: 22 | SET PATH=%PATH%;/cygdrive/c/Program Files/nodejs/npm 23 | 24 | call nvm use v14.17.3 25 | call which node 26 | 27 | call npm install || goto :error 28 | call npm run test || goto :error 29 | 30 | goto :EOF 31 | 32 | :error 33 | exit /b 1 34 | -------------------------------------------------------------------------------- /.kokoro/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Copyright 2018 Google LLC 4 | # 5 | # Licensed under the Apache License, Version 2.0 (the "License"); 6 | # you may not use this file except in compliance with the License. 7 | # You may obtain a copy of the License at 8 | # 9 | # https://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | 17 | set -eo pipefail 18 | 19 | export NPM_CONFIG_PREFIX=${HOME}/.npm-global 20 | 21 | cd $(dirname $0)/.. 22 | 23 | npm install 24 | # If tests are running against main branch, configure flakybot 25 | # to open issues on failures: 26 | if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]] || [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"nightly"* ]]; then 27 | export MOCHA_REPORTER_OUTPUT=test_output_sponge_log.xml 28 | export MOCHA_REPORTER=xunit 29 | cleanup() { 30 | chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot 31 | $KOKORO_GFILE_DIR/linux_amd64/flakybot 32 | } 33 | trap cleanup EXIT HUP 34 | fi 35 | # Unit tests exercise the entire API surface, which may include 36 | # deprecation warnings: 37 | export MOCHA_THROW_DEPRECATION=false 38 | npm test 39 | 40 | # codecov combines coverage across integration and unit tests. Include 41 | # the logic below for any environment you wish to collect coverage for: 42 | COVERAGE_NODE=14 43 | if npx check-node-version@3.3.0 --silent --node $COVERAGE_NODE; then 44 | NYC_BIN=./node_modules/nyc/bin/nyc.js 45 | if [ -f "$NYC_BIN" ]; then 46 | $NYC_BIN report || true 47 | fi 48 | bash $KOKORO_GFILE_DIR/codecov.sh 49 | else 50 | echo "coverage is only reported for Node $COVERAGE_NODE" 51 | fi 52 | -------------------------------------------------------------------------------- /.kokoro/trampoline.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # Copyright 2017 Google Inc. 3 | # 4 | # Licensed under the Apache License, Version 2.0 (the "License"); 5 | # you may not use this file except in compliance with the License. 6 | # You may obtain a copy of the License at 7 | # 8 | # http://www.apache.org/licenses/LICENSE-2.0 9 | # 10 | # Unless required by applicable law or agreed to in writing, software 11 | # distributed under the License is distributed on an "AS IS" BASIS, 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | # See the License for the specific language governing permissions and 14 | # limitations under the License. 15 | 16 | # This file is not used any more, but we keep this file for making it 17 | # easy to roll back. 18 | # TODO: Remove this file from the template. 19 | 20 | set -eo pipefail 21 | 22 | # Always run the cleanup script, regardless of the success of bouncing into 23 | # the container. 24 | function cleanup() { 25 | chmod +x ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh 26 | ${KOKORO_GFILE_DIR}/trampoline_cleanup.sh 27 | echo "cleanup"; 28 | } 29 | trap cleanup EXIT 30 | 31 | $(dirname $0)/populate-secrets.sh # Secret Manager secrets. 32 | python3 "${KOKORO_GFILE_DIR}/trampoline_v1.py" 33 | -------------------------------------------------------------------------------- /.mocharc.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | const config = { 15 | "enable-source-maps": true, 16 | "throw-deprecation": true, 17 | "timeout": 10000, 18 | "recursive": true 19 | } 20 | if (process.env.MOCHA_THROW_DEPRECATION === 'false') { 21 | delete config['throw-deprecation']; 22 | } 23 | if (process.env.MOCHA_REPORTER) { 24 | config.reporter = process.env.MOCHA_REPORTER; 25 | } 26 | if (process.env.MOCHA_REPORTER_OUTPUT) { 27 | config['reporter-option'] = `output=${process.env.MOCHA_REPORTER_OUTPUT}`; 28 | } 29 | module.exports = config 30 | -------------------------------------------------------------------------------- /.nycrc: -------------------------------------------------------------------------------- 1 | { 2 | "report-dir": "./.coverage", 3 | "reporter": ["text", "lcov"], 4 | "exclude": [ 5 | "**/*-test", 6 | "**/.coverage", 7 | "**/apis", 8 | "**/benchmark", 9 | "**/conformance", 10 | "**/docs", 11 | "**/samples", 12 | "**/scripts", 13 | "**/protos", 14 | "**/test", 15 | "**/*.d.ts", 16 | ".jsdoc.js", 17 | "**/.jsdoc.js", 18 | "karma.conf.js", 19 | "webpack-tests.config.js", 20 | "webpack.config.js" 21 | ], 22 | "exclude-after-remap": false, 23 | "all": true 24 | } 25 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/node_modules 2 | **/coverage 3 | test/fixtures 4 | build/ 5 | docs/ 6 | protos/ 7 | **/env-tests-logging 8 | -------------------------------------------------------------------------------- /.prettierrc.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | module.exports = { 16 | ...require('gts/.prettierrc.json') 17 | } 18 | -------------------------------------------------------------------------------- /.repo-metadata.json: -------------------------------------------------------------------------------- 1 | { 2 | "client_documentation": "https://cloud.google.com/nodejs/docs/reference/logging/latest", 3 | "product_documentation": "https://cloud.google.com/logging/docs", 4 | "name": "logging", 5 | "codeowner_team": "@googleapis/api-logging", 6 | "release_level": "stable", 7 | "language": "nodejs", 8 | "api_id": "logging.googleapis.com", 9 | "distribution_name": "@google-cloud/logging", 10 | "repo": "googleapis/nodejs-logging", 11 | "issue_tracker": "https://issuetracker.google.com/savedsearches/559764", 12 | "name_pretty": "Cloud Logging", 13 | "default_version": "v2", 14 | "api_shortname": "logging", 15 | "library_type": "GAPIC_COMBO" 16 | } 17 | -------------------------------------------------------------------------------- /.trampolinerc: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | # Template for .trampolinerc 16 | 17 | # Add required env vars here. 18 | required_envvars+=() 19 | 20 | # Add env vars which are passed down into the container here. 21 | pass_down_envvars+=( 22 | "ENVIRONMENT" 23 | "RUNTIME" 24 | "AUTORELEASE_PR" 25 | "VERSION" 26 | ) 27 | 28 | # Prevent unintentional override on the default image. 29 | if [[ "${TRAMPOLINE_IMAGE_UPLOAD:-false}" == "true" ]] && \ 30 | [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then 31 | echo "Please set TRAMPOLINE_IMAGE if you want to upload the Docker image." 32 | exit 1 33 | fi 34 | 35 | # Define the default value if it makes sense. 36 | if [[ -z "${TRAMPOLINE_IMAGE_UPLOAD:-}" ]]; then 37 | TRAMPOLINE_IMAGE_UPLOAD="" 38 | fi 39 | 40 | if [[ -z "${TRAMPOLINE_IMAGE:-}" ]]; then 41 | TRAMPOLINE_IMAGE="" 42 | fi 43 | 44 | if [[ -z "${TRAMPOLINE_DOCKERFILE:-}" ]]; then 45 | TRAMPOLINE_DOCKERFILE="" 46 | fi 47 | 48 | if [[ -z "${TRAMPOLINE_BUILD_FILE:-}" ]]; then 49 | TRAMPOLINE_BUILD_FILE="" 50 | fi 51 | 52 | # Secret Manager secrets. 53 | source ${PROJECT_ROOT}/.kokoro/populate-secrets.sh 54 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to become a contributor and submit your own code 2 | 3 | **Table of contents** 4 | 5 | * [Contributor License Agreements](#contributor-license-agreements) 6 | * [Contributing a patch](#contributing-a-patch) 7 | * [Running the tests](#running-the-tests) 8 | * [Releasing the library](#releasing-the-library) 9 | 10 | ## Contributor License Agreements 11 | 12 | We'd love to accept your sample apps and patches! Before we can take them, we 13 | have to jump a couple of legal hurdles. 14 | 15 | Please fill out either the individual or corporate Contributor License Agreement 16 | (CLA). 17 | 18 | * If you are an individual writing original source code and you're sure you 19 | own the intellectual property, then you'll need to sign an [individual CLA](https://developers.google.com/open-source/cla/individual). 20 | * If you work for a company that wants to allow you to contribute your work, 21 | then you'll need to sign a [corporate CLA](https://developers.google.com/open-source/cla/corporate). 22 | 23 | Follow either of the two links above to access the appropriate CLA and 24 | instructions for how to sign and return it. Once we receive it, we'll be able to 25 | accept your pull requests. 26 | 27 | ## Contributing A Patch 28 | 29 | 1. Submit an issue describing your proposed change to the repo in question. 30 | 1. The repo owner will respond to your issue promptly. 31 | 1. If your proposed change is accepted, and you haven't already done so, sign a 32 | Contributor License Agreement (see details above). 33 | 1. Fork the desired repo, develop and test your code changes. 34 | 1. Ensure that your code adheres to the existing style in the code to which 35 | you are contributing. 36 | 1. Ensure that your code has an appropriate set of tests which all pass. 37 | 1. Title your pull request following [Conventional Commits](https://www.conventionalcommits.org/) styling. 38 | 1. Submit a pull request. 39 | 40 | ### Before you begin 41 | 42 | 1. [Select or create a Cloud Platform project][projects]. 43 | 1. [Enable the Cloud Logging API][enable_api]. 44 | 1. [Set up authentication with a service account][auth] so you can access the 45 | API from your local workstation. 46 | 47 | 48 | ## Running the tests 49 | 50 | 1. [Prepare your environment for Node.js setup][setup]. 51 | 52 | 1. Install dependencies: 53 | 54 | npm install 55 | 56 | 1. Run the tests: 57 | 58 | # Run unit tests. 59 | npm test 60 | 61 | # Run sample integration tests. 62 | npm run samples-test 63 | 64 | # Run all system tests. 65 | npm run system-test 66 | 67 | 1. Lint (and maybe fix) any changes: 68 | 69 | npm run fix 70 | 71 | ## Running the tests in GCP services 72 | 73 | It is possible to end-to-end test this library within specific Google Cloud 74 | Platform environments. The [env-tests-logging](https://github.com/googleapis/env-tests-logging) 75 | submodule contains common tests to ensure correct logging behavior across Google 76 | Cloud Platforms. 77 | 78 | Currently, the following environments are supported: 79 | 80 | | Platform | Runtime | Try it | 81 | | --------------- | -------------- | ------------------------------ | 82 | | Cloud Functions | Nodejs12 | `nox --session "tests(language='nodejs', platform='functions')"` | 83 | | Cloud Run | COMING SOON | `nox --session "tests(language='nodejs', platform='cloudrun')"` | 84 | 85 | [setup]: https://cloud.google.com/nodejs/docs/setup 86 | [projects]: https://console.cloud.google.com/project 87 | [billing]: https://support.google.com/cloud/answer/6293499#enable-billing 88 | [enable_api]: https://console.cloud.google.com/flows/enableapi?apiid=logging.googleapis.com 89 | [auth]: https://cloud.google.com/docs/authentication/getting-started 90 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | To report a security issue, please use [g.co/vulnz](https://g.co/vulnz). 4 | 5 | The Google Security Team will respond within 5 working days of your report on g.co/vulnz. 6 | 7 | We use g.co/vulnz for our intake, and do coordination and disclosure here using GitHub Security Advisory to privately discuss and fix the issue. 8 | -------------------------------------------------------------------------------- /_static/_static/guide-me.svg: -------------------------------------------------------------------------------- 1 | 3 | 9 | 12 | 20 | 21 | 23 | GUIDE ME 29 | 33 | 37 | 41 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /_static/guide-me.svg: -------------------------------------------------------------------------------- 1 | 3 | 9 | 12 | 20 | 21 | 23 | GUIDE ME 29 | 33 | 37 | 41 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /linkinator.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "recurse": true, 3 | "skip": [ 4 | "https://codecov.io/gh/googleapis/", 5 | "www.googleapis.com", 6 | "img.shields.io", 7 | "https://console.cloud.google.com/cloudshell", 8 | "https://support.google.com" 9 | ], 10 | "silent": true, 11 | "concurrency": 5, 12 | "retry": true, 13 | "retryErrors": true, 14 | "retryErrorsCount": 5, 15 | "retryErrorsJitter": 3000 16 | } 17 | -------------------------------------------------------------------------------- /owlbot.py: -------------------------------------------------------------------------------- 1 | # Copyright 2018 Google LLC 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | """This script is used to synthesize generated parts of this library.""" 16 | 17 | import os 18 | import synthtool as s 19 | import synthtool.languages.node as node 20 | 21 | node.owlbot_main( 22 | staging_excludes=[ 23 | ".eslintignore", ".prettierignore", "src/index.ts", "README.md", "package.json", 24 | "system-test/fixtures/sample/src/index.js", 25 | "system-test/fixtures/sample/src/index.ts"], 26 | templates_excludes=[ 27 | "src/index.ts", 28 | ".eslintignore", 29 | ".prettierignore", 30 | "CONTRIBUTING.md", 31 | ".github/auto-label.yaml", 32 | ".github/release-please.yml", 33 | ".github/CODEOWNERS", 34 | ".github/sync-repo-settings.yaml" 35 | ] 36 | ) 37 | 38 | # adjust .trampolinerc for environment tests 39 | s.replace( 40 | ".trampolinerc", 41 | "required_envvars[^\)]*\)", 42 | "required_envvars+=()" 43 | ) 44 | s.replace( 45 | ".trampolinerc", 46 | "pass_down_envvars\+\=\(", 47 | 'pass_down_envvars+=(\n "ENVIRONMENT"\n "RUNTIME"' 48 | ) 49 | 50 | # -------------------------------------------------------------------------- 51 | # Modify test configs 52 | # -------------------------------------------------------------------------- 53 | 54 | # add shared environment variables to test configs 55 | s.move( 56 | ".kokoro/common_env_vars.cfg", 57 | ".kokoro/common.cfg", 58 | merge=lambda src, dst, _, : f"{dst}\n{src}", 59 | ) 60 | 61 | for path, subdirs, files in os.walk(f".kokoro/continuous"): 62 | for name in files: 63 | if name == "common.cfg": 64 | file_path = os.path.join(path, name) 65 | s.move( 66 | ".kokoro/common_env_vars.cfg", 67 | file_path, 68 | merge=lambda src, dst, _, : f"{dst}\n{src}", 69 | ) 70 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@google-cloud/logging", 3 | "version": "11.2.0", 4 | "description": "Cloud Logging Client Library for Node.js", 5 | "keywords": [ 6 | "google apis client", 7 | "google api client", 8 | "google apis", 9 | "google api", 10 | "google", 11 | "google cloud platform", 12 | "google cloud", 13 | "cloud", 14 | "google logging", 15 | "logging", 16 | "stackdriver logging", 17 | "stackdriver" 18 | ], 19 | "repository": "googleapis/nodejs-logging", 20 | "license": "Apache-2.0", 21 | "author": "Google Inc.", 22 | "main": "build/src/index.js", 23 | "files": [ 24 | "build/src", 25 | "build/protos" 26 | ], 27 | "scripts": { 28 | "clean": "gts clean", 29 | "compile": "tsc -p . && cp -r proto* build/", 30 | "compile-protos": "compileProtos src", 31 | "predocs": "npm run compile", 32 | "docs": "jsdoc -c .jsdoc.js", 33 | "predocs-test": "npm run docs", 34 | "docs-test": "linkinator docs", 35 | "fix": "gts fix", 36 | "prelint": "cd samples; npm link ../; npm install", 37 | "lint": "gts check", 38 | "prepare": "npm run compile-protos && npm run compile", 39 | "samples-test": "cd samples/ && npm link ../ && npm test && cd ../", 40 | "presystem-test": "npm run compile", 41 | "system-test": "mocha build/system-test --timeout 600000", 42 | "pretest": "npm run compile", 43 | "test": "c8 mocha build/test", 44 | "precompile": "gts clean", 45 | "postpublish": "./.kokoro/publish-min.sh" 46 | }, 47 | "dependencies": { 48 | "@google-cloud/common": "^5.0.0", 49 | "@google-cloud/paginator": "^5.0.0", 50 | "@google-cloud/projectify": "^4.0.0", 51 | "@google-cloud/promisify": "^4.0.0", 52 | "arrify": "^2.0.1", 53 | "dot-prop": "^6.0.0", 54 | "eventid": "^2.0.0", 55 | "extend": "^3.0.2", 56 | "gcp-metadata": "^6.0.0", 57 | "google-auth-library": "^9.0.0", 58 | "google-gax": "^4.0.3", 59 | "on-finished": "^2.3.0", 60 | "pumpify": "^2.0.1", 61 | "stream-events": "^1.0.5", 62 | "uuid": "^9.0.0", 63 | "@opentelemetry/api": "^1.7.0" 64 | }, 65 | "devDependencies": { 66 | "@google-cloud/bigquery": "^7.0.0", 67 | "@google-cloud/pubsub": "^4.0.0", 68 | "@google-cloud/storage": "^7.0.0", 69 | "@types/extend": "^3.0.1", 70 | "@types/mocha": "^9.0.0", 71 | "@types/node": "^20.4.9", 72 | "@types/on-finished": "^2.3.1", 73 | "@types/proxyquire": "^1.3.28", 74 | "@types/pumpify": "^1.4.1", 75 | "@types/sinon": "^10.0.0", 76 | "@types/uuid": "^9.0.0", 77 | "bignumber.js": "^9.0.0", 78 | "c8": "^9.0.0", 79 | "codecov": "^3.6.5", 80 | "gapic-tools": "^0.4.0", 81 | "gts": "^5.0.0", 82 | "http2spy": "^2.0.0", 83 | "jsdoc": "^4.0.0", 84 | "jsdoc-region-tag": "^3.0.0", 85 | "jsdoc-fresh": "^3.0.0", 86 | "linkinator": "^3.0.0", 87 | "mocha": "^9.2.2", 88 | "nock": "^13.0.0", 89 | "null-loader": "^4.0.0", 90 | "pack-n-play": "^2.0.0", 91 | "proxyquire": "^2.1.3", 92 | "sinon": "^18.0.0", 93 | "ts-loader": "^9.0.0", 94 | "typescript": "^5.1.6", 95 | "uglify-js": "^3.13.5", 96 | "webpack": "^5.0.0", 97 | "webpack-cli": "^5.0.0", 98 | "@opentelemetry/api": "^1.7.0", 99 | "@opentelemetry/sdk-trace-node": "^1.23.0", 100 | "@opentelemetry/sdk-node": "^0.52.0", 101 | "@opentelemetry/semantic-conventions": "^1.23.0", 102 | "@opentelemetry/sdk-trace-base": "^1.23.0", 103 | "@opentelemetry/resources": "^1.23.0", 104 | "@google-cloud/opentelemetry-cloud-trace-exporter": "^2.1.0" 105 | }, 106 | "engines": { 107 | "node": ">=14.0.0" 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /protos/google/cloud/common_resources.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | // This file contains stub messages for common resources in GCP. 16 | // It is not intended to be directly generated, and is instead used by 17 | // other tooling to be able to match common resource patterns. 18 | syntax = "proto3"; 19 | 20 | package google.cloud; 21 | 22 | import "google/api/resource.proto"; 23 | 24 | 25 | option (google.api.resource_definition) = { 26 | type: "cloudresourcemanager.googleapis.com/Project" 27 | pattern: "projects/{project}" 28 | }; 29 | 30 | 31 | option (google.api.resource_definition) = { 32 | type: "cloudresourcemanager.googleapis.com/Organization" 33 | pattern: "organizations/{organization}" 34 | }; 35 | 36 | 37 | option (google.api.resource_definition) = { 38 | type: "cloudresourcemanager.googleapis.com/Folder" 39 | pattern: "folders/{folder}" 40 | }; 41 | 42 | 43 | option (google.api.resource_definition) = { 44 | type: "cloudbilling.googleapis.com/BillingAccount" 45 | pattern: "billingAccounts/{billing_account}" 46 | }; 47 | 48 | option (google.api.resource_definition) = { 49 | type: "locations.googleapis.com/Location" 50 | pattern: "projects/{project}/locations/{location}" 51 | }; 52 | 53 | -------------------------------------------------------------------------------- /protos/google/logging/type/log_severity.proto: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | syntax = "proto3"; 16 | 17 | package google.logging.type; 18 | 19 | option csharp_namespace = "Google.Cloud.Logging.Type"; 20 | option go_package = "google.golang.org/genproto/googleapis/logging/type;ltype"; 21 | option java_multiple_files = true; 22 | option java_outer_classname = "LogSeverityProto"; 23 | option java_package = "com.google.logging.type"; 24 | option objc_class_prefix = "GLOG"; 25 | option php_namespace = "Google\\Cloud\\Logging\\Type"; 26 | option ruby_package = "Google::Cloud::Logging::Type"; 27 | 28 | // The severity of the event described in a log entry, expressed as one of the 29 | // standard severity levels listed below. For your reference, the levels are 30 | // assigned the listed numeric values. The effect of using numeric values other 31 | // than those listed is undefined. 32 | // 33 | // You can filter for log entries by severity. For example, the following 34 | // filter expression will match log entries with severities `INFO`, `NOTICE`, 35 | // and `WARNING`: 36 | // 37 | // severity > DEBUG AND severity <= WARNING 38 | // 39 | // If you are writing log entries, you should map other severity encodings to 40 | // one of these standard levels. For example, you might map all of Java's FINE, 41 | // FINER, and FINEST levels to `LogSeverity.DEBUG`. You can preserve the 42 | // original severity level in the log entry payload if you wish. 43 | enum LogSeverity { 44 | // (0) The log entry has no assigned severity level. 45 | DEFAULT = 0; 46 | 47 | // (100) Debug or trace information. 48 | DEBUG = 100; 49 | 50 | // (200) Routine information, such as ongoing status or performance. 51 | INFO = 200; 52 | 53 | // (300) Normal but significant events, such as start up, shut down, or 54 | // a configuration change. 55 | NOTICE = 300; 56 | 57 | // (400) Warning events might cause problems. 58 | WARNING = 400; 59 | 60 | // (500) Error events are likely to cause problems. 61 | ERROR = 500; 62 | 63 | // (600) Critical events cause more severe problems or outages. 64 | CRITICAL = 600; 65 | 66 | // (700) A person must take an action immediately. 67 | ALERT = 700; 68 | 69 | // (800) One or more systems are unusable. 70 | EMERGENCY = 800; 71 | } 72 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base", 4 | "docker:disable", 5 | ":disableDependencyDashboard" 6 | ], 7 | "pinVersions": false, 8 | "rebaseStalePrs": true, 9 | "schedule": [ 10 | "after 9am and before 3pm" 11 | ], 12 | "gitAuthor": null, 13 | "packageRules": [ 14 | { 15 | "extends": "packages:linters", 16 | "groupName": "linters" 17 | } 18 | ], 19 | "ignoreDeps": ["typescript"] 20 | } 21 | -------------------------------------------------------------------------------- /samples/.eslintrc.yml: -------------------------------------------------------------------------------- 1 | --- 2 | rules: 3 | no-console: off 4 | -------------------------------------------------------------------------------- /samples/fluent.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | const express = require('express'); 18 | const app = express(); 19 | 20 | app.get('*', (req, res, next) => { 21 | return next('oops'); 22 | }); 23 | 24 | // [START fluent] 25 | const structuredLogger = require('fluent-logger').createFluentSender('myapp', { 26 | host: 'localhost', 27 | port: 24224, 28 | timeout: 3.0, 29 | }); 30 | 31 | const report = (err, req) => { 32 | const payload = { 33 | serviceContext: { 34 | service: 'myapp', 35 | }, 36 | message: err.stack, 37 | context: { 38 | httpRequest: { 39 | url: req.originalUrl, 40 | method: req.method, 41 | referrer: req.header('Referer'), 42 | userAgent: req.header('User-Agent'), 43 | remoteIp: req.ip, 44 | responseStatusCode: 500, 45 | }, 46 | }, 47 | }; 48 | structuredLogger.emit('errors', payload); 49 | }; 50 | 51 | // Handle errors (the following uses the Express framework) 52 | // eslint-disable-next-line no-unused-vars 53 | app.use((err, req, res, next) => { 54 | report(err, req); 55 | res.status(500).send(err.response || 'Something broke!'); 56 | }); 57 | // [END fluent] 58 | 59 | module.exports = app; 60 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.copy_log_entries.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name, destination) { 22 | // [START logging_v2_generated_ConfigServiceV2_CopyLogEntries_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. Log bucket from which to copy log entries. 31 | * For example: 32 | * `"projects/my-project/locations/global/buckets/my-source-bucket"` 33 | */ 34 | // const name = 'abc123' 35 | /** 36 | * Optional. A filter specifying which log entries to copy. The filter must be 37 | * no more than 20k characters. An empty filter matches all log entries. 38 | */ 39 | // const filter = 'abc123' 40 | /** 41 | * Required. Destination to which to copy log entries. 42 | */ 43 | // const destination = 'abc123' 44 | 45 | // Imports the Logging library 46 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 47 | 48 | // Instantiates a client 49 | const loggingClient = new ConfigServiceV2Client(); 50 | 51 | async function callCopyLogEntries() { 52 | // Construct request 53 | const request = { 54 | name, 55 | destination, 56 | }; 57 | 58 | // Run request 59 | const [operation] = await loggingClient.copyLogEntries(request); 60 | const [response] = await operation.promise(); 61 | console.log(response); 62 | } 63 | 64 | callCopyLogEntries(); 65 | // [END logging_v2_generated_ConfigServiceV2_CopyLogEntries_async] 66 | } 67 | 68 | process.on('unhandledRejection', err => { 69 | console.error(err.message); 70 | process.exitCode = 1; 71 | }); 72 | main(...process.argv.slice(2)); 73 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.create_bucket.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent, bucketId, bucket) { 22 | // [START logging_v2_generated_ConfigServiceV2_CreateBucket_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource in which to create the log bucket: 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" 32 | * For example: 33 | * `"projects/my-project/locations/global"` 34 | */ 35 | // const parent = 'abc123' 36 | /** 37 | * Required. A client-assigned identifier such as `"my-bucket"`. Identifiers 38 | * are limited to 100 characters and can include only letters, digits, 39 | * underscores, hyphens, and periods. 40 | */ 41 | // const bucketId = 'abc123' 42 | /** 43 | * Required. The new bucket. The region specified in the new bucket must be 44 | * compliant with any Location Restriction Org Policy. The name field in the 45 | * bucket is ignored. 46 | */ 47 | // const bucket = {} 48 | 49 | // Imports the Logging library 50 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 51 | 52 | // Instantiates a client 53 | const loggingClient = new ConfigServiceV2Client(); 54 | 55 | async function callCreateBucket() { 56 | // Construct request 57 | const request = { 58 | parent, 59 | bucketId, 60 | bucket, 61 | }; 62 | 63 | // Run request 64 | const response = await loggingClient.createBucket(request); 65 | console.log(response); 66 | } 67 | 68 | callCreateBucket(); 69 | // [END logging_v2_generated_ConfigServiceV2_CreateBucket_async] 70 | } 71 | 72 | process.on('unhandledRejection', err => { 73 | console.error(err.message); 74 | process.exitCode = 1; 75 | }); 76 | main(...process.argv.slice(2)); 77 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.create_bucket_async.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent, bucketId, bucket) { 22 | // [START logging_v2_generated_ConfigServiceV2_CreateBucketAsync_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource in which to create the log bucket: 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" 32 | * For example: 33 | * `"projects/my-project/locations/global"` 34 | */ 35 | // const parent = 'abc123' 36 | /** 37 | * Required. A client-assigned identifier such as `"my-bucket"`. Identifiers 38 | * are limited to 100 characters and can include only letters, digits, 39 | * underscores, hyphens, and periods. 40 | */ 41 | // const bucketId = 'abc123' 42 | /** 43 | * Required. The new bucket. The region specified in the new bucket must be 44 | * compliant with any Location Restriction Org Policy. The name field in the 45 | * bucket is ignored. 46 | */ 47 | // const bucket = {} 48 | 49 | // Imports the Logging library 50 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 51 | 52 | // Instantiates a client 53 | const loggingClient = new ConfigServiceV2Client(); 54 | 55 | async function callCreateBucketAsync() { 56 | // Construct request 57 | const request = { 58 | parent, 59 | bucketId, 60 | bucket, 61 | }; 62 | 63 | // Run request 64 | const [operation] = await loggingClient.createBucketAsync(request); 65 | const [response] = await operation.promise(); 66 | console.log(response); 67 | } 68 | 69 | callCreateBucketAsync(); 70 | // [END logging_v2_generated_ConfigServiceV2_CreateBucketAsync_async] 71 | } 72 | 73 | process.on('unhandledRejection', err => { 74 | console.error(err.message); 75 | process.exitCode = 1; 76 | }); 77 | main(...process.argv.slice(2)); 78 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.create_exclusion.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent, exclusion) { 22 | // [START logging_v2_generated_ConfigServiceV2_CreateExclusion_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The parent resource in which to create the exclusion: 31 | * "projects/[PROJECT_ID]" 32 | * "organizations/[ORGANIZATION_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]" 34 | * "folders/[FOLDER_ID]" 35 | * For examples: 36 | * `"projects/my-logging-project"` 37 | * `"organizations/123456789"` 38 | */ 39 | // const parent = 'abc123' 40 | /** 41 | * Required. The new exclusion, whose `name` parameter is an exclusion name 42 | * that is not already used in the parent resource. 43 | */ 44 | // const exclusion = {} 45 | 46 | // Imports the Logging library 47 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 48 | 49 | // Instantiates a client 50 | const loggingClient = new ConfigServiceV2Client(); 51 | 52 | async function callCreateExclusion() { 53 | // Construct request 54 | const request = { 55 | parent, 56 | exclusion, 57 | }; 58 | 59 | // Run request 60 | const response = await loggingClient.createExclusion(request); 61 | console.log(response); 62 | } 63 | 64 | callCreateExclusion(); 65 | // [END logging_v2_generated_ConfigServiceV2_CreateExclusion_async] 66 | } 67 | 68 | process.on('unhandledRejection', err => { 69 | console.error(err.message); 70 | process.exitCode = 1; 71 | }); 72 | main(...process.argv.slice(2)); 73 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.create_link.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent, link, linkId) { 22 | // [START logging_v2_generated_ConfigServiceV2_CreateLink_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The full resource name of the bucket to create a link for. 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 35 | */ 36 | // const parent = 'abc123' 37 | /** 38 | * Required. The new link. 39 | */ 40 | // const link = {} 41 | /** 42 | * Required. The ID to use for the link. The link_id can have up to 100 43 | * characters. A valid link_id must only have alphanumeric characters and 44 | * underscores within it. 45 | */ 46 | // const linkId = 'abc123' 47 | 48 | // Imports the Logging library 49 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 50 | 51 | // Instantiates a client 52 | const loggingClient = new ConfigServiceV2Client(); 53 | 54 | async function callCreateLink() { 55 | // Construct request 56 | const request = { 57 | parent, 58 | link, 59 | linkId, 60 | }; 61 | 62 | // Run request 63 | const [operation] = await loggingClient.createLink(request); 64 | const [response] = await operation.promise(); 65 | console.log(response); 66 | } 67 | 68 | callCreateLink(); 69 | // [END logging_v2_generated_ConfigServiceV2_CreateLink_async] 70 | } 71 | 72 | process.on('unhandledRejection', err => { 73 | console.error(err.message); 74 | process.exitCode = 1; 75 | }); 76 | main(...process.argv.slice(2)); 77 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.create_sink.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent, sink) { 22 | // [START logging_v2_generated_ConfigServiceV2_CreateSink_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource in which to create the sink: 31 | * "projects/[PROJECT_ID]" 32 | * "organizations/[ORGANIZATION_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]" 34 | * "folders/[FOLDER_ID]" 35 | * For examples: 36 | * `"projects/my-project"` 37 | * `"organizations/123456789"` 38 | */ 39 | // const parent = 'abc123' 40 | /** 41 | * Required. The new sink, whose `name` parameter is a sink identifier that 42 | * is not already in use. 43 | */ 44 | // const sink = {} 45 | /** 46 | * Optional. Determines the kind of IAM identity returned as `writer_identity` 47 | * in the new sink. If this value is omitted or set to false, and if the 48 | * sink's parent is a project, then the value returned as `writer_identity` is 49 | * the same group or service account used by Cloud Logging before the addition 50 | * of writer identities to this API. The sink's destination must be in the 51 | * same project as the sink itself. 52 | * If this field is set to true, or if the sink is owned by a non-project 53 | * resource such as an organization, then the value of `writer_identity` will 54 | * be a unique service account used only for exports from the new sink. For 55 | * more information, see `writer_identity` in 56 | * LogSink google.logging.v2.LogSink. 57 | */ 58 | // const uniqueWriterIdentity = true 59 | 60 | // Imports the Logging library 61 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 62 | 63 | // Instantiates a client 64 | const loggingClient = new ConfigServiceV2Client(); 65 | 66 | async function callCreateSink() { 67 | // Construct request 68 | const request = { 69 | parent, 70 | sink, 71 | }; 72 | 73 | // Run request 74 | const response = await loggingClient.createSink(request); 75 | console.log(response); 76 | } 77 | 78 | callCreateSink(); 79 | // [END logging_v2_generated_ConfigServiceV2_CreateSink_async] 80 | } 81 | 82 | process.on('unhandledRejection', err => { 83 | console.error(err.message); 84 | process.exitCode = 1; 85 | }); 86 | main(...process.argv.slice(2)); 87 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.create_view.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent, viewId, view) { 22 | // [START logging_v2_generated_ConfigServiceV2_CreateView_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The bucket in which to create the view 31 | * `"projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]"` 32 | * For example: 33 | * `"projects/my-project/locations/global/buckets/my-bucket"` 34 | */ 35 | // const parent = 'abc123' 36 | /** 37 | * Required. A client-assigned identifier such as `"my-view"`. Identifiers are 38 | * limited to 100 characters and can include only letters, digits, 39 | * underscores, hyphens, and periods. 40 | */ 41 | // const viewId = 'abc123' 42 | /** 43 | * Required. The new view. 44 | */ 45 | // const view = {} 46 | 47 | // Imports the Logging library 48 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 49 | 50 | // Instantiates a client 51 | const loggingClient = new ConfigServiceV2Client(); 52 | 53 | async function callCreateView() { 54 | // Construct request 55 | const request = { 56 | parent, 57 | viewId, 58 | view, 59 | }; 60 | 61 | // Run request 62 | const response = await loggingClient.createView(request); 63 | console.log(response); 64 | } 65 | 66 | callCreateView(); 67 | // [END logging_v2_generated_ConfigServiceV2_CreateView_async] 68 | } 69 | 70 | process.on('unhandledRejection', err => { 71 | console.error(err.message); 72 | process.exitCode = 1; 73 | }); 74 | main(...process.argv.slice(2)); 75 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.delete_bucket.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_DeleteBucket_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The full resource name of the bucket to delete. 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 35 | * For example: 36 | * `"projects/my-project/locations/global/buckets/my-bucket"` 37 | */ 38 | // const name = 'abc123' 39 | 40 | // Imports the Logging library 41 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 42 | 43 | // Instantiates a client 44 | const loggingClient = new ConfigServiceV2Client(); 45 | 46 | async function callDeleteBucket() { 47 | // Construct request 48 | const request = { 49 | name, 50 | }; 51 | 52 | // Run request 53 | const response = await loggingClient.deleteBucket(request); 54 | console.log(response); 55 | } 56 | 57 | callDeleteBucket(); 58 | // [END logging_v2_generated_ConfigServiceV2_DeleteBucket_async] 59 | } 60 | 61 | process.on('unhandledRejection', err => { 62 | console.error(err.message); 63 | process.exitCode = 1; 64 | }); 65 | main(...process.argv.slice(2)); 66 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.delete_exclusion.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_DeleteExclusion_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of an existing exclusion to delete: 31 | * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 32 | * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 34 | * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 35 | * For example: 36 | * `"projects/my-project/exclusions/my-exclusion"` 37 | */ 38 | // const name = 'abc123' 39 | 40 | // Imports the Logging library 41 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 42 | 43 | // Instantiates a client 44 | const loggingClient = new ConfigServiceV2Client(); 45 | 46 | async function callDeleteExclusion() { 47 | // Construct request 48 | const request = { 49 | name, 50 | }; 51 | 52 | // Run request 53 | const response = await loggingClient.deleteExclusion(request); 54 | console.log(response); 55 | } 56 | 57 | callDeleteExclusion(); 58 | // [END logging_v2_generated_ConfigServiceV2_DeleteExclusion_async] 59 | } 60 | 61 | process.on('unhandledRejection', err => { 62 | console.error(err.message); 63 | process.exitCode = 1; 64 | }); 65 | main(...process.argv.slice(2)); 66 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.delete_link.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_DeleteLink_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The full resource name of the link to delete. 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 35 | */ 36 | // const name = 'abc123' 37 | 38 | // Imports the Logging library 39 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 40 | 41 | // Instantiates a client 42 | const loggingClient = new ConfigServiceV2Client(); 43 | 44 | async function callDeleteLink() { 45 | // Construct request 46 | const request = { 47 | name, 48 | }; 49 | 50 | // Run request 51 | const [operation] = await loggingClient.deleteLink(request); 52 | const [response] = await operation.promise(); 53 | console.log(response); 54 | } 55 | 56 | callDeleteLink(); 57 | // [END logging_v2_generated_ConfigServiceV2_DeleteLink_async] 58 | } 59 | 60 | process.on('unhandledRejection', err => { 61 | console.error(err.message); 62 | process.exitCode = 1; 63 | }); 64 | main(...process.argv.slice(2)); 65 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.delete_sink.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(sinkName) { 22 | // [START logging_v2_generated_ConfigServiceV2_DeleteSink_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The full resource name of the sink to delete, including the 31 | * parent resource and the sink identifier: 32 | * "projects/[PROJECT_ID]/sinks/[SINK_ID]" 33 | * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" 34 | * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" 35 | * "folders/[FOLDER_ID]/sinks/[SINK_ID]" 36 | * For example: 37 | * `"projects/my-project/sinks/my-sink"` 38 | */ 39 | // const sinkName = 'abc123' 40 | 41 | // Imports the Logging library 42 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 43 | 44 | // Instantiates a client 45 | const loggingClient = new ConfigServiceV2Client(); 46 | 47 | async function callDeleteSink() { 48 | // Construct request 49 | const request = { 50 | sinkName, 51 | }; 52 | 53 | // Run request 54 | const response = await loggingClient.deleteSink(request); 55 | console.log(response); 56 | } 57 | 58 | callDeleteSink(); 59 | // [END logging_v2_generated_ConfigServiceV2_DeleteSink_async] 60 | } 61 | 62 | process.on('unhandledRejection', err => { 63 | console.error(err.message); 64 | process.exitCode = 1; 65 | }); 66 | main(...process.argv.slice(2)); 67 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.delete_view.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_DeleteView_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The full resource name of the view to delete: 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" 32 | * For example: 33 | * `"projects/my-project/locations/global/buckets/my-bucket/views/my-view"` 34 | */ 35 | // const name = 'abc123' 36 | 37 | // Imports the Logging library 38 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 39 | 40 | // Instantiates a client 41 | const loggingClient = new ConfigServiceV2Client(); 42 | 43 | async function callDeleteView() { 44 | // Construct request 45 | const request = { 46 | name, 47 | }; 48 | 49 | // Run request 50 | const response = await loggingClient.deleteView(request); 51 | console.log(response); 52 | } 53 | 54 | callDeleteView(); 55 | // [END logging_v2_generated_ConfigServiceV2_DeleteView_async] 56 | } 57 | 58 | process.on('unhandledRejection', err => { 59 | console.error(err.message); 60 | process.exitCode = 1; 61 | }); 62 | main(...process.argv.slice(2)); 63 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.get_bucket.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_GetBucket_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the bucket: 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 35 | * For example: 36 | * `"projects/my-project/locations/global/buckets/my-bucket"` 37 | */ 38 | // const name = 'abc123' 39 | 40 | // Imports the Logging library 41 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 42 | 43 | // Instantiates a client 44 | const loggingClient = new ConfigServiceV2Client(); 45 | 46 | async function callGetBucket() { 47 | // Construct request 48 | const request = { 49 | name, 50 | }; 51 | 52 | // Run request 53 | const response = await loggingClient.getBucket(request); 54 | console.log(response); 55 | } 56 | 57 | callGetBucket(); 58 | // [END logging_v2_generated_ConfigServiceV2_GetBucket_async] 59 | } 60 | 61 | process.on('unhandledRejection', err => { 62 | console.error(err.message); 63 | process.exitCode = 1; 64 | }); 65 | main(...process.argv.slice(2)); 66 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.get_cmek_settings.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_GetCmekSettings_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource for which to retrieve CMEK settings. 31 | * "projects/[PROJECT_ID]/cmekSettings" 32 | * "organizations/[ORGANIZATION_ID]/cmekSettings" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/cmekSettings" 34 | * "folders/[FOLDER_ID]/cmekSettings" 35 | * For example: 36 | * `"organizations/12345/cmekSettings"` 37 | * Note: CMEK for the Log Router can be configured for Google Cloud projects, 38 | * folders, organizations and billing accounts. Once configured for an 39 | * organization, it applies to all projects and folders in the Google Cloud 40 | * organization. 41 | */ 42 | // const name = 'abc123' 43 | 44 | // Imports the Logging library 45 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 46 | 47 | // Instantiates a client 48 | const loggingClient = new ConfigServiceV2Client(); 49 | 50 | async function callGetCmekSettings() { 51 | // Construct request 52 | const request = { 53 | name, 54 | }; 55 | 56 | // Run request 57 | const response = await loggingClient.getCmekSettings(request); 58 | console.log(response); 59 | } 60 | 61 | callGetCmekSettings(); 62 | // [END logging_v2_generated_ConfigServiceV2_GetCmekSettings_async] 63 | } 64 | 65 | process.on('unhandledRejection', err => { 66 | console.error(err.message); 67 | process.exitCode = 1; 68 | }); 69 | main(...process.argv.slice(2)); 70 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.get_exclusion.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_GetExclusion_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of an existing exclusion: 31 | * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 32 | * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 34 | * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 35 | * For example: 36 | * `"projects/my-project/exclusions/my-exclusion"` 37 | */ 38 | // const name = 'abc123' 39 | 40 | // Imports the Logging library 41 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 42 | 43 | // Instantiates a client 44 | const loggingClient = new ConfigServiceV2Client(); 45 | 46 | async function callGetExclusion() { 47 | // Construct request 48 | const request = { 49 | name, 50 | }; 51 | 52 | // Run request 53 | const response = await loggingClient.getExclusion(request); 54 | console.log(response); 55 | } 56 | 57 | callGetExclusion(); 58 | // [END logging_v2_generated_ConfigServiceV2_GetExclusion_async] 59 | } 60 | 61 | process.on('unhandledRejection', err => { 62 | console.error(err.message); 63 | process.exitCode = 1; 64 | }); 65 | main(...process.argv.slice(2)); 66 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.get_link.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_GetLink_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the link: 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID]" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/[LINK_ID] 35 | */ 36 | // const name = 'abc123' 37 | 38 | // Imports the Logging library 39 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 40 | 41 | // Instantiates a client 42 | const loggingClient = new ConfigServiceV2Client(); 43 | 44 | async function callGetLink() { 45 | // Construct request 46 | const request = { 47 | name, 48 | }; 49 | 50 | // Run request 51 | const response = await loggingClient.getLink(request); 52 | console.log(response); 53 | } 54 | 55 | callGetLink(); 56 | // [END logging_v2_generated_ConfigServiceV2_GetLink_async] 57 | } 58 | 59 | process.on('unhandledRejection', err => { 60 | console.error(err.message); 61 | process.exitCode = 1; 62 | }); 63 | main(...process.argv.slice(2)); 64 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.get_settings.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_GetSettings_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource for which to retrieve settings. 31 | * "projects/[PROJECT_ID]/settings" 32 | * "organizations/[ORGANIZATION_ID]/settings" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/settings" 34 | * "folders/[FOLDER_ID]/settings" 35 | * For example: 36 | * `"organizations/12345/settings"` 37 | * Note: Settings for the Log Router can be get for Google Cloud projects, 38 | * folders, organizations and billing accounts. Currently it can only be 39 | * configured for organizations. Once configured for an organization, it 40 | * applies to all projects and folders in the Google Cloud organization. 41 | */ 42 | // const name = 'abc123' 43 | 44 | // Imports the Logging library 45 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 46 | 47 | // Instantiates a client 48 | const loggingClient = new ConfigServiceV2Client(); 49 | 50 | async function callGetSettings() { 51 | // Construct request 52 | const request = { 53 | name, 54 | }; 55 | 56 | // Run request 57 | const response = await loggingClient.getSettings(request); 58 | console.log(response); 59 | } 60 | 61 | callGetSettings(); 62 | // [END logging_v2_generated_ConfigServiceV2_GetSettings_async] 63 | } 64 | 65 | process.on('unhandledRejection', err => { 66 | console.error(err.message); 67 | process.exitCode = 1; 68 | }); 69 | main(...process.argv.slice(2)); 70 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.get_sink.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(sinkName) { 22 | // [START logging_v2_generated_ConfigServiceV2_GetSink_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the sink: 31 | * "projects/[PROJECT_ID]/sinks/[SINK_ID]" 32 | * "organizations/[ORGANIZATION_ID]/sinks/[SINK_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/sinks/[SINK_ID]" 34 | * "folders/[FOLDER_ID]/sinks/[SINK_ID]" 35 | * For example: 36 | * `"projects/my-project/sinks/my-sink"` 37 | */ 38 | // const sinkName = 'abc123' 39 | 40 | // Imports the Logging library 41 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 42 | 43 | // Instantiates a client 44 | const loggingClient = new ConfigServiceV2Client(); 45 | 46 | async function callGetSink() { 47 | // Construct request 48 | const request = { 49 | sinkName, 50 | }; 51 | 52 | // Run request 53 | const response = await loggingClient.getSink(request); 54 | console.log(response); 55 | } 56 | 57 | callGetSink(); 58 | // [END logging_v2_generated_ConfigServiceV2_GetSink_async] 59 | } 60 | 61 | process.on('unhandledRejection', err => { 62 | console.error(err.message); 63 | process.exitCode = 1; 64 | }); 65 | main(...process.argv.slice(2)); 66 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.get_view.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_GetView_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the policy: 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" 32 | * For example: 33 | * `"projects/my-project/locations/global/buckets/my-bucket/views/my-view"` 34 | */ 35 | // const name = 'abc123' 36 | 37 | // Imports the Logging library 38 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 39 | 40 | // Instantiates a client 41 | const loggingClient = new ConfigServiceV2Client(); 42 | 43 | async function callGetView() { 44 | // Construct request 45 | const request = { 46 | name, 47 | }; 48 | 49 | // Run request 50 | const response = await loggingClient.getView(request); 51 | console.log(response); 52 | } 53 | 54 | callGetView(); 55 | // [END logging_v2_generated_ConfigServiceV2_GetView_async] 56 | } 57 | 58 | process.on('unhandledRejection', err => { 59 | console.error(err.message); 60 | process.exitCode = 1; 61 | }); 62 | main(...process.argv.slice(2)); 63 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.list_buckets.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent) { 22 | // [START logging_v2_generated_ConfigServiceV2_ListBuckets_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The parent resource whose buckets are to be listed: 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]" 35 | * Note: The locations portion of the resource must be specified, but 36 | * supplying the character `-` in place of LOCATION_ID will return all 37 | * buckets. 38 | */ 39 | // const parent = 'abc123' 40 | /** 41 | * Optional. If present, then retrieve the next batch of results from the 42 | * preceding call to this method. `pageToken` must be the value of 43 | * `nextPageToken` from the previous response. The values of other method 44 | * parameters should be identical to those in the previous call. 45 | */ 46 | // const pageToken = 'abc123' 47 | /** 48 | * Optional. The maximum number of results to return from this request. 49 | * Non-positive values are ignored. The presence of `nextPageToken` in the 50 | * response indicates that more results might be available. 51 | */ 52 | // const pageSize = 1234 53 | 54 | // Imports the Logging library 55 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 56 | 57 | // Instantiates a client 58 | const loggingClient = new ConfigServiceV2Client(); 59 | 60 | async function callListBuckets() { 61 | // Construct request 62 | const request = { 63 | parent, 64 | }; 65 | 66 | // Run request 67 | const iterable = loggingClient.listBucketsAsync(request); 68 | for await (const response of iterable) { 69 | console.log(response); 70 | } 71 | } 72 | 73 | callListBuckets(); 74 | // [END logging_v2_generated_ConfigServiceV2_ListBuckets_async] 75 | } 76 | 77 | process.on('unhandledRejection', err => { 78 | console.error(err.message); 79 | process.exitCode = 1; 80 | }); 81 | main(...process.argv.slice(2)); 82 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.list_exclusions.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent) { 22 | // [START logging_v2_generated_ConfigServiceV2_ListExclusions_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The parent resource whose exclusions are to be listed. 31 | * "projects/[PROJECT_ID]" 32 | * "organizations/[ORGANIZATION_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]" 34 | * "folders/[FOLDER_ID]" 35 | */ 36 | // const parent = 'abc123' 37 | /** 38 | * Optional. If present, then retrieve the next batch of results from the 39 | * preceding call to this method. `pageToken` must be the value of 40 | * `nextPageToken` from the previous response. The values of other method 41 | * parameters should be identical to those in the previous call. 42 | */ 43 | // const pageToken = 'abc123' 44 | /** 45 | * Optional. The maximum number of results to return from this request. 46 | * Non-positive values are ignored. The presence of `nextPageToken` in the 47 | * response indicates that more results might be available. 48 | */ 49 | // const pageSize = 1234 50 | 51 | // Imports the Logging library 52 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 53 | 54 | // Instantiates a client 55 | const loggingClient = new ConfigServiceV2Client(); 56 | 57 | async function callListExclusions() { 58 | // Construct request 59 | const request = { 60 | parent, 61 | }; 62 | 63 | // Run request 64 | const iterable = loggingClient.listExclusionsAsync(request); 65 | for await (const response of iterable) { 66 | console.log(response); 67 | } 68 | } 69 | 70 | callListExclusions(); 71 | // [END logging_v2_generated_ConfigServiceV2_ListExclusions_async] 72 | } 73 | 74 | process.on('unhandledRejection', err => { 75 | console.error(err.message); 76 | process.exitCode = 1; 77 | }); 78 | main(...process.argv.slice(2)); 79 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.list_links.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent) { 22 | // [START logging_v2_generated_ConfigServiceV2_ListLinks_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The parent resource whose links are to be listed: 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/links/" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/ 35 | */ 36 | // const parent = 'abc123' 37 | /** 38 | * Optional. If present, then retrieve the next batch of results from the 39 | * preceding call to this method. `pageToken` must be the value of 40 | * `nextPageToken` from the previous response. 41 | */ 42 | // const pageToken = 'abc123' 43 | /** 44 | * Optional. The maximum number of results to return from this request. 45 | */ 46 | // const pageSize = 1234 47 | 48 | // Imports the Logging library 49 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 50 | 51 | // Instantiates a client 52 | const loggingClient = new ConfigServiceV2Client(); 53 | 54 | async function callListLinks() { 55 | // Construct request 56 | const request = { 57 | parent, 58 | }; 59 | 60 | // Run request 61 | const iterable = loggingClient.listLinksAsync(request); 62 | for await (const response of iterable) { 63 | console.log(response); 64 | } 65 | } 66 | 67 | callListLinks(); 68 | // [END logging_v2_generated_ConfigServiceV2_ListLinks_async] 69 | } 70 | 71 | process.on('unhandledRejection', err => { 72 | console.error(err.message); 73 | process.exitCode = 1; 74 | }); 75 | main(...process.argv.slice(2)); 76 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.list_sinks.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent) { 22 | // [START logging_v2_generated_ConfigServiceV2_ListSinks_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The parent resource whose sinks are to be listed: 31 | * "projects/[PROJECT_ID]" 32 | * "organizations/[ORGANIZATION_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]" 34 | * "folders/[FOLDER_ID]" 35 | */ 36 | // const parent = 'abc123' 37 | /** 38 | * Optional. If present, then retrieve the next batch of results from the 39 | * preceding call to this method. `pageToken` must be the value of 40 | * `nextPageToken` from the previous response. The values of other method 41 | * parameters should be identical to those in the previous call. 42 | */ 43 | // const pageToken = 'abc123' 44 | /** 45 | * Optional. The maximum number of results to return from this request. 46 | * Non-positive values are ignored. The presence of `nextPageToken` in the 47 | * response indicates that more results might be available. 48 | */ 49 | // const pageSize = 1234 50 | 51 | // Imports the Logging library 52 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 53 | 54 | // Instantiates a client 55 | const loggingClient = new ConfigServiceV2Client(); 56 | 57 | async function callListSinks() { 58 | // Construct request 59 | const request = { 60 | parent, 61 | }; 62 | 63 | // Run request 64 | const iterable = loggingClient.listSinksAsync(request); 65 | for await (const response of iterable) { 66 | console.log(response); 67 | } 68 | } 69 | 70 | callListSinks(); 71 | // [END logging_v2_generated_ConfigServiceV2_ListSinks_async] 72 | } 73 | 74 | process.on('unhandledRejection', err => { 75 | console.error(err.message); 76 | process.exitCode = 1; 77 | }); 78 | main(...process.argv.slice(2)); 79 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.list_views.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent) { 22 | // [START logging_v2_generated_ConfigServiceV2_ListViews_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The bucket whose views are to be listed: 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 32 | */ 33 | // const parent = 'abc123' 34 | /** 35 | * Optional. If present, then retrieve the next batch of results from the 36 | * preceding call to this method. `pageToken` must be the value of 37 | * `nextPageToken` from the previous response. The values of other method 38 | * parameters should be identical to those in the previous call. 39 | */ 40 | // const pageToken = 'abc123' 41 | /** 42 | * Optional. The maximum number of results to return from this request. 43 | * Non-positive values are ignored. The presence of `nextPageToken` in the 44 | * response indicates that more results might be available. 45 | */ 46 | // const pageSize = 1234 47 | 48 | // Imports the Logging library 49 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 50 | 51 | // Instantiates a client 52 | const loggingClient = new ConfigServiceV2Client(); 53 | 54 | async function callListViews() { 55 | // Construct request 56 | const request = { 57 | parent, 58 | }; 59 | 60 | // Run request 61 | const iterable = loggingClient.listViewsAsync(request); 62 | for await (const response of iterable) { 63 | console.log(response); 64 | } 65 | } 66 | 67 | callListViews(); 68 | // [END logging_v2_generated_ConfigServiceV2_ListViews_async] 69 | } 70 | 71 | process.on('unhandledRejection', err => { 72 | console.error(err.message); 73 | process.exitCode = 1; 74 | }); 75 | main(...process.argv.slice(2)); 76 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.undelete_bucket.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name) { 22 | // [START logging_v2_generated_ConfigServiceV2_UndeleteBucket_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The full resource name of the bucket to undelete. 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 35 | * For example: 36 | * `"projects/my-project/locations/global/buckets/my-bucket"` 37 | */ 38 | // const name = 'abc123' 39 | 40 | // Imports the Logging library 41 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 42 | 43 | // Instantiates a client 44 | const loggingClient = new ConfigServiceV2Client(); 45 | 46 | async function callUndeleteBucket() { 47 | // Construct request 48 | const request = { 49 | name, 50 | }; 51 | 52 | // Run request 53 | const response = await loggingClient.undeleteBucket(request); 54 | console.log(response); 55 | } 56 | 57 | callUndeleteBucket(); 58 | // [END logging_v2_generated_ConfigServiceV2_UndeleteBucket_async] 59 | } 60 | 61 | process.on('unhandledRejection', err => { 62 | console.error(err.message); 63 | process.exitCode = 1; 64 | }); 65 | main(...process.argv.slice(2)); 66 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.update_bucket.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name, bucket, updateMask) { 22 | // [START logging_v2_generated_ConfigServiceV2_UpdateBucket_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The full resource name of the bucket to update. 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 35 | * For example: 36 | * `"projects/my-project/locations/global/buckets/my-bucket"` 37 | */ 38 | // const name = 'abc123' 39 | /** 40 | * Required. The updated bucket. 41 | */ 42 | // const bucket = {} 43 | /** 44 | * Required. Field mask that specifies the fields in `bucket` that need an 45 | * update. A bucket field will be overwritten if, and only if, it is in the 46 | * update mask. `name` and output only fields cannot be updated. 47 | * For a detailed `FieldMask` definition, see: 48 | * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask 49 | * For example: `updateMask=retention_days` 50 | */ 51 | // const updateMask = {} 52 | 53 | // Imports the Logging library 54 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 55 | 56 | // Instantiates a client 57 | const loggingClient = new ConfigServiceV2Client(); 58 | 59 | async function callUpdateBucket() { 60 | // Construct request 61 | const request = { 62 | name, 63 | bucket, 64 | updateMask, 65 | }; 66 | 67 | // Run request 68 | const response = await loggingClient.updateBucket(request); 69 | console.log(response); 70 | } 71 | 72 | callUpdateBucket(); 73 | // [END logging_v2_generated_ConfigServiceV2_UpdateBucket_async] 74 | } 75 | 76 | process.on('unhandledRejection', err => { 77 | console.error(err.message); 78 | process.exitCode = 1; 79 | }); 80 | main(...process.argv.slice(2)); 81 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.update_bucket_async.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name, bucket, updateMask) { 22 | // [START logging_v2_generated_ConfigServiceV2_UpdateBucketAsync_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The full resource name of the bucket to update. 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 32 | * "organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 34 | * "folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]" 35 | * For example: 36 | * `"projects/my-project/locations/global/buckets/my-bucket"` 37 | */ 38 | // const name = 'abc123' 39 | /** 40 | * Required. The updated bucket. 41 | */ 42 | // const bucket = {} 43 | /** 44 | * Required. Field mask that specifies the fields in `bucket` that need an 45 | * update. A bucket field will be overwritten if, and only if, it is in the 46 | * update mask. `name` and output only fields cannot be updated. 47 | * For a detailed `FieldMask` definition, see: 48 | * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask 49 | * For example: `updateMask=retention_days` 50 | */ 51 | // const updateMask = {} 52 | 53 | // Imports the Logging library 54 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 55 | 56 | // Instantiates a client 57 | const loggingClient = new ConfigServiceV2Client(); 58 | 59 | async function callUpdateBucketAsync() { 60 | // Construct request 61 | const request = { 62 | name, 63 | bucket, 64 | updateMask, 65 | }; 66 | 67 | // Run request 68 | const [operation] = await loggingClient.updateBucketAsync(request); 69 | const [response] = await operation.promise(); 70 | console.log(response); 71 | } 72 | 73 | callUpdateBucketAsync(); 74 | // [END logging_v2_generated_ConfigServiceV2_UpdateBucketAsync_async] 75 | } 76 | 77 | process.on('unhandledRejection', err => { 78 | console.error(err.message); 79 | process.exitCode = 1; 80 | }); 81 | main(...process.argv.slice(2)); 82 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.update_cmek_settings.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name, cmekSettings) { 22 | // [START logging_v2_generated_ConfigServiceV2_UpdateCmekSettings_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name for the CMEK settings to update. 31 | * "projects/[PROJECT_ID]/cmekSettings" 32 | * "organizations/[ORGANIZATION_ID]/cmekSettings" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/cmekSettings" 34 | * "folders/[FOLDER_ID]/cmekSettings" 35 | * For example: 36 | * `"organizations/12345/cmekSettings"` 37 | * Note: CMEK for the Log Router can currently only be configured for Google 38 | * Cloud organizations. Once configured, it applies to all projects and 39 | * folders in the Google Cloud organization. 40 | */ 41 | // const name = 'abc123' 42 | /** 43 | * Required. The CMEK settings to update. 44 | * See Enabling CMEK for Log 45 | * Router (https://cloud.google.com/logging/docs/routing/managed-encryption) 46 | * for more information. 47 | */ 48 | // const cmekSettings = {} 49 | /** 50 | * Optional. Field mask identifying which fields from `cmek_settings` should 51 | * be updated. A field will be overwritten if and only if it is in the update 52 | * mask. Output only fields cannot be updated. 53 | * See FieldMask google.protobuf.FieldMask for more information. 54 | * For example: `"updateMask=kmsKeyName"` 55 | */ 56 | // const updateMask = {} 57 | 58 | // Imports the Logging library 59 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 60 | 61 | // Instantiates a client 62 | const loggingClient = new ConfigServiceV2Client(); 63 | 64 | async function callUpdateCmekSettings() { 65 | // Construct request 66 | const request = { 67 | name, 68 | cmekSettings, 69 | }; 70 | 71 | // Run request 72 | const response = await loggingClient.updateCmekSettings(request); 73 | console.log(response); 74 | } 75 | 76 | callUpdateCmekSettings(); 77 | // [END logging_v2_generated_ConfigServiceV2_UpdateCmekSettings_async] 78 | } 79 | 80 | process.on('unhandledRejection', err => { 81 | console.error(err.message); 82 | process.exitCode = 1; 83 | }); 84 | main(...process.argv.slice(2)); 85 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.update_exclusion.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name, exclusion, updateMask) { 22 | // [START logging_v2_generated_ConfigServiceV2_UpdateExclusion_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the exclusion to update: 31 | * "projects/[PROJECT_ID]/exclusions/[EXCLUSION_ID]" 32 | * "organizations/[ORGANIZATION_ID]/exclusions/[EXCLUSION_ID]" 33 | * "billingAccounts/[BILLING_ACCOUNT_ID]/exclusions/[EXCLUSION_ID]" 34 | * "folders/[FOLDER_ID]/exclusions/[EXCLUSION_ID]" 35 | * For example: 36 | * `"projects/my-project/exclusions/my-exclusion"` 37 | */ 38 | // const name = 'abc123' 39 | /** 40 | * Required. New values for the existing exclusion. Only the fields specified 41 | * in `update_mask` are relevant. 42 | */ 43 | // const exclusion = {} 44 | /** 45 | * Required. A non-empty list of fields to change in the existing exclusion. 46 | * New values for the fields are taken from the corresponding fields in the 47 | * LogExclusion google.logging.v2.LogExclusion included in this request. 48 | * Fields not mentioned in `update_mask` are not changed and are ignored in 49 | * the request. 50 | * For example, to change the filter and description of an exclusion, 51 | * specify an `update_mask` of `"filter,description"`. 52 | */ 53 | // const updateMask = {} 54 | 55 | // Imports the Logging library 56 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 57 | 58 | // Instantiates a client 59 | const loggingClient = new ConfigServiceV2Client(); 60 | 61 | async function callUpdateExclusion() { 62 | // Construct request 63 | const request = { 64 | name, 65 | exclusion, 66 | updateMask, 67 | }; 68 | 69 | // Run request 70 | const response = await loggingClient.updateExclusion(request); 71 | console.log(response); 72 | } 73 | 74 | callUpdateExclusion(); 75 | // [END logging_v2_generated_ConfigServiceV2_UpdateExclusion_async] 76 | } 77 | 78 | process.on('unhandledRejection', err => { 79 | console.error(err.message); 80 | process.exitCode = 1; 81 | }); 82 | main(...process.argv.slice(2)); 83 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.update_settings.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name, settings) { 22 | // [START logging_v2_generated_ConfigServiceV2_UpdateSettings_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name for the settings to update. 31 | * "organizations/[ORGANIZATION_ID]/settings" 32 | * For example: 33 | * `"organizations/12345/settings"` 34 | * Note: Settings for the Log Router can currently only be configured for 35 | * Google Cloud organizations. Once configured, it applies to all projects and 36 | * folders in the Google Cloud organization. 37 | */ 38 | // const name = 'abc123' 39 | /** 40 | * Required. The settings to update. 41 | * See Enabling CMEK for Log 42 | * Router (https://cloud.google.com/logging/docs/routing/managed-encryption) 43 | * for more information. 44 | */ 45 | // const settings = {} 46 | /** 47 | * Optional. Field mask identifying which fields from `settings` should 48 | * be updated. A field will be overwritten if and only if it is in the update 49 | * mask. Output only fields cannot be updated. 50 | * See FieldMask google.protobuf.FieldMask for more information. 51 | * For example: `"updateMask=kmsKeyName"` 52 | */ 53 | // const updateMask = {} 54 | 55 | // Imports the Logging library 56 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 57 | 58 | // Instantiates a client 59 | const loggingClient = new ConfigServiceV2Client(); 60 | 61 | async function callUpdateSettings() { 62 | // Construct request 63 | const request = { 64 | name, 65 | settings, 66 | }; 67 | 68 | // Run request 69 | const response = await loggingClient.updateSettings(request); 70 | console.log(response); 71 | } 72 | 73 | callUpdateSettings(); 74 | // [END logging_v2_generated_ConfigServiceV2_UpdateSettings_async] 75 | } 76 | 77 | process.on('unhandledRejection', err => { 78 | console.error(err.message); 79 | process.exitCode = 1; 80 | }); 81 | main(...process.argv.slice(2)); 82 | -------------------------------------------------------------------------------- /samples/generated/v2/config_service_v2.update_view.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(name, view) { 22 | // [START logging_v2_generated_ConfigServiceV2_UpdateView_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The full resource name of the view to update 31 | * "projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]" 32 | * For example: 33 | * `"projects/my-project/locations/global/buckets/my-bucket/views/my-view"` 34 | */ 35 | // const name = 'abc123' 36 | /** 37 | * Required. The updated view. 38 | */ 39 | // const view = {} 40 | /** 41 | * Optional. Field mask that specifies the fields in `view` that need 42 | * an update. A field will be overwritten if, and only if, it is 43 | * in the update mask. `name` and output only fields cannot be updated. 44 | * For a detailed `FieldMask` definition, see 45 | * https://developers.google.com/protocol-buffers/docs/reference/google.protobuf#google.protobuf.FieldMask 46 | * For example: `updateMask=filter` 47 | */ 48 | // const updateMask = {} 49 | 50 | // Imports the Logging library 51 | const {ConfigServiceV2Client} = require('@google-cloud/logging').v2; 52 | 53 | // Instantiates a client 54 | const loggingClient = new ConfigServiceV2Client(); 55 | 56 | async function callUpdateView() { 57 | // Construct request 58 | const request = { 59 | name, 60 | view, 61 | }; 62 | 63 | // Run request 64 | const response = await loggingClient.updateView(request); 65 | console.log(response); 66 | } 67 | 68 | callUpdateView(); 69 | // [END logging_v2_generated_ConfigServiceV2_UpdateView_async] 70 | } 71 | 72 | process.on('unhandledRejection', err => { 73 | console.error(err.message); 74 | process.exitCode = 1; 75 | }); 76 | main(...process.argv.slice(2)); 77 | -------------------------------------------------------------------------------- /samples/generated/v2/logging_service_v2.delete_log.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(logName) { 22 | // [START logging_v2_generated_LoggingServiceV2_DeleteLog_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the log to delete: 31 | * * `projects/[PROJECT_ID]/logs/[LOG_ID]` 32 | * * `organizations/[ORGANIZATION_ID]/logs/[LOG_ID]` 33 | * * `billingAccounts/[BILLING_ACCOUNT_ID]/logs/[LOG_ID]` 34 | * * `folders/[FOLDER_ID]/logs/[LOG_ID]` 35 | * `[LOG_ID]` must be URL-encoded. For example, 36 | * `"projects/my-project-id/logs/syslog"`, 37 | * `"organizations/123/logs/cloudaudit.googleapis.com%2Factivity"`. 38 | * For more information about log names, see 39 | * LogEntry google.logging.v2.LogEntry. 40 | */ 41 | // const logName = 'abc123' 42 | 43 | // Imports the Logging library 44 | const {LoggingServiceV2Client} = require('@google-cloud/logging').v2; 45 | 46 | // Instantiates a client 47 | const loggingClient = new LoggingServiceV2Client(); 48 | 49 | async function callDeleteLog() { 50 | // Construct request 51 | const request = { 52 | logName, 53 | }; 54 | 55 | // Run request 56 | const response = await loggingClient.deleteLog(request); 57 | console.log(response); 58 | } 59 | 60 | callDeleteLog(); 61 | // [END logging_v2_generated_LoggingServiceV2_DeleteLog_async] 62 | } 63 | 64 | process.on('unhandledRejection', err => { 65 | console.error(err.message); 66 | process.exitCode = 1; 67 | }); 68 | main(...process.argv.slice(2)); 69 | -------------------------------------------------------------------------------- /samples/generated/v2/logging_service_v2.list_logs.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent) { 22 | // [START logging_v2_generated_LoggingServiceV2_ListLogs_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name to list logs for: 31 | * * `projects/[PROJECT_ID]` 32 | * * `organizations/[ORGANIZATION_ID]` 33 | * * `billingAccounts/[BILLING_ACCOUNT_ID]` 34 | * * `folders/[FOLDER_ID]` 35 | */ 36 | // const parent = 'abc123' 37 | /** 38 | * Optional. List of resource names to list logs for: 39 | * * `projects/[PROJECT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 40 | * * `organizations/[ORGANIZATION_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 41 | * * `billingAccounts/[BILLING_ACCOUNT_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 42 | * * `folders/[FOLDER_ID]/locations/[LOCATION_ID]/buckets/[BUCKET_ID]/views/[VIEW_ID]` 43 | * To support legacy queries, it could also be: 44 | * * `projects/[PROJECT_ID]` 45 | * * `organizations/[ORGANIZATION_ID]` 46 | * * `billingAccounts/[BILLING_ACCOUNT_ID]` 47 | * * `folders/[FOLDER_ID]` 48 | * The resource name in the `parent` field is added to this list. 49 | */ 50 | // const resourceNames = ['abc','def'] 51 | /** 52 | * Optional. The maximum number of results to return from this request. 53 | * Non-positive values are ignored. The presence of `nextPageToken` in the 54 | * response indicates that more results might be available. 55 | */ 56 | // const pageSize = 1234 57 | /** 58 | * Optional. If present, then retrieve the next batch of results from the 59 | * preceding call to this method. `pageToken` must be the value of 60 | * `nextPageToken` from the previous response. The values of other method 61 | * parameters should be identical to those in the previous call. 62 | */ 63 | // const pageToken = 'abc123' 64 | 65 | // Imports the Logging library 66 | const {LoggingServiceV2Client} = require('@google-cloud/logging').v2; 67 | 68 | // Instantiates a client 69 | const loggingClient = new LoggingServiceV2Client(); 70 | 71 | async function callListLogs() { 72 | // Construct request 73 | const request = { 74 | parent, 75 | }; 76 | 77 | // Run request 78 | const iterable = loggingClient.listLogsAsync(request); 79 | for await (const response of iterable) { 80 | console.log(response); 81 | } 82 | } 83 | 84 | callListLogs(); 85 | // [END logging_v2_generated_LoggingServiceV2_ListLogs_async] 86 | } 87 | 88 | process.on('unhandledRejection', err => { 89 | console.error(err.message); 90 | process.exitCode = 1; 91 | }); 92 | main(...process.argv.slice(2)); 93 | -------------------------------------------------------------------------------- /samples/generated/v2/logging_service_v2.list_monitored_resource_descriptors.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main() { 22 | // [START logging_v2_generated_LoggingServiceV2_ListMonitoredResourceDescriptors_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Optional. The maximum number of results to return from this request. 31 | * Non-positive values are ignored. The presence of `nextPageToken` in the 32 | * response indicates that more results might be available. 33 | */ 34 | // const pageSize = 1234 35 | /** 36 | * Optional. If present, then retrieve the next batch of results from the 37 | * preceding call to this method. `pageToken` must be the value of 38 | * `nextPageToken` from the previous response. The values of other method 39 | * parameters should be identical to those in the previous call. 40 | */ 41 | // const pageToken = 'abc123' 42 | 43 | // Imports the Logging library 44 | const {LoggingServiceV2Client} = require('@google-cloud/logging').v2; 45 | 46 | // Instantiates a client 47 | const loggingClient = new LoggingServiceV2Client(); 48 | 49 | async function callListMonitoredResourceDescriptors() { 50 | // Construct request 51 | const request = {}; 52 | 53 | // Run request 54 | const iterable = 55 | loggingClient.listMonitoredResourceDescriptorsAsync(request); 56 | for await (const response of iterable) { 57 | console.log(response); 58 | } 59 | } 60 | 61 | callListMonitoredResourceDescriptors(); 62 | // [END logging_v2_generated_LoggingServiceV2_ListMonitoredResourceDescriptors_async] 63 | } 64 | 65 | process.on('unhandledRejection', err => { 66 | console.error(err.message); 67 | process.exitCode = 1; 68 | }); 69 | main(...process.argv.slice(2)); 70 | -------------------------------------------------------------------------------- /samples/generated/v2/metrics_service_v2.create_log_metric.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent, metric) { 22 | // [START logging_v2_generated_MetricsServiceV2_CreateLogMetric_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the project in which to create the metric: 31 | * "projects/[PROJECT_ID]" 32 | * The new metric must be provided in the request. 33 | */ 34 | // const parent = 'abc123' 35 | /** 36 | * Required. The new logs-based metric, which must not have an identifier that 37 | * already exists. 38 | */ 39 | // const metric = {} 40 | 41 | // Imports the Logging library 42 | const {MetricsServiceV2Client} = require('@google-cloud/logging').v2; 43 | 44 | // Instantiates a client 45 | const loggingClient = new MetricsServiceV2Client(); 46 | 47 | async function callCreateLogMetric() { 48 | // Construct request 49 | const request = { 50 | parent, 51 | metric, 52 | }; 53 | 54 | // Run request 55 | const response = await loggingClient.createLogMetric(request); 56 | console.log(response); 57 | } 58 | 59 | callCreateLogMetric(); 60 | // [END logging_v2_generated_MetricsServiceV2_CreateLogMetric_async] 61 | } 62 | 63 | process.on('unhandledRejection', err => { 64 | console.error(err.message); 65 | process.exitCode = 1; 66 | }); 67 | main(...process.argv.slice(2)); 68 | -------------------------------------------------------------------------------- /samples/generated/v2/metrics_service_v2.delete_log_metric.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(metricName) { 22 | // [START logging_v2_generated_MetricsServiceV2_DeleteLogMetric_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the metric to delete: 31 | * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" 32 | */ 33 | // const metricName = 'abc123' 34 | 35 | // Imports the Logging library 36 | const {MetricsServiceV2Client} = require('@google-cloud/logging').v2; 37 | 38 | // Instantiates a client 39 | const loggingClient = new MetricsServiceV2Client(); 40 | 41 | async function callDeleteLogMetric() { 42 | // Construct request 43 | const request = { 44 | metricName, 45 | }; 46 | 47 | // Run request 48 | const response = await loggingClient.deleteLogMetric(request); 49 | console.log(response); 50 | } 51 | 52 | callDeleteLogMetric(); 53 | // [END logging_v2_generated_MetricsServiceV2_DeleteLogMetric_async] 54 | } 55 | 56 | process.on('unhandledRejection', err => { 57 | console.error(err.message); 58 | process.exitCode = 1; 59 | }); 60 | main(...process.argv.slice(2)); 61 | -------------------------------------------------------------------------------- /samples/generated/v2/metrics_service_v2.get_log_metric.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(metricName) { 22 | // [START logging_v2_generated_MetricsServiceV2_GetLogMetric_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the desired metric: 31 | * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" 32 | */ 33 | // const metricName = 'abc123' 34 | 35 | // Imports the Logging library 36 | const {MetricsServiceV2Client} = require('@google-cloud/logging').v2; 37 | 38 | // Instantiates a client 39 | const loggingClient = new MetricsServiceV2Client(); 40 | 41 | async function callGetLogMetric() { 42 | // Construct request 43 | const request = { 44 | metricName, 45 | }; 46 | 47 | // Run request 48 | const response = await loggingClient.getLogMetric(request); 49 | console.log(response); 50 | } 51 | 52 | callGetLogMetric(); 53 | // [END logging_v2_generated_MetricsServiceV2_GetLogMetric_async] 54 | } 55 | 56 | process.on('unhandledRejection', err => { 57 | console.error(err.message); 58 | process.exitCode = 1; 59 | }); 60 | main(...process.argv.slice(2)); 61 | -------------------------------------------------------------------------------- /samples/generated/v2/metrics_service_v2.list_log_metrics.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(parent) { 22 | // [START logging_v2_generated_MetricsServiceV2_ListLogMetrics_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The name of the project containing the metrics: 31 | * "projects/[PROJECT_ID]" 32 | */ 33 | // const parent = 'abc123' 34 | /** 35 | * Optional. If present, then retrieve the next batch of results from the 36 | * preceding call to this method. `pageToken` must be the value of 37 | * `nextPageToken` from the previous response. The values of other method 38 | * parameters should be identical to those in the previous call. 39 | */ 40 | // const pageToken = 'abc123' 41 | /** 42 | * Optional. The maximum number of results to return from this request. 43 | * Non-positive values are ignored. The presence of `nextPageToken` in the 44 | * response indicates that more results might be available. 45 | */ 46 | // const pageSize = 1234 47 | 48 | // Imports the Logging library 49 | const {MetricsServiceV2Client} = require('@google-cloud/logging').v2; 50 | 51 | // Instantiates a client 52 | const loggingClient = new MetricsServiceV2Client(); 53 | 54 | async function callListLogMetrics() { 55 | // Construct request 56 | const request = { 57 | parent, 58 | }; 59 | 60 | // Run request 61 | const iterable = loggingClient.listLogMetricsAsync(request); 62 | for await (const response of iterable) { 63 | console.log(response); 64 | } 65 | } 66 | 67 | callListLogMetrics(); 68 | // [END logging_v2_generated_MetricsServiceV2_ListLogMetrics_async] 69 | } 70 | 71 | process.on('unhandledRejection', err => { 72 | console.error(err.message); 73 | process.exitCode = 1; 74 | }); 75 | main(...process.argv.slice(2)); 76 | -------------------------------------------------------------------------------- /samples/generated/v2/metrics_service_v2.update_log_metric.js: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | 'use strict'; 20 | 21 | function main(metricName, metric) { 22 | // [START logging_v2_generated_MetricsServiceV2_UpdateLogMetric_async] 23 | /** 24 | * This snippet has been automatically generated and should be regarded as a code template only. 25 | * It will require modifications to work. 26 | * It may require correct/in-range values for request initialization. 27 | * TODO(developer): Uncomment these variables before running the sample. 28 | */ 29 | /** 30 | * Required. The resource name of the metric to update: 31 | * "projects/[PROJECT_ID]/metrics/[METRIC_ID]" 32 | * The updated metric must be provided in the request and it's 33 | * `name` field must be the same as `[METRIC_ID]` If the metric 34 | * does not exist in `[PROJECT_ID]`, then a new metric is created. 35 | */ 36 | // const metricName = 'abc123' 37 | /** 38 | * Required. The updated metric. 39 | */ 40 | // const metric = {} 41 | 42 | // Imports the Logging library 43 | const {MetricsServiceV2Client} = require('@google-cloud/logging').v2; 44 | 45 | // Instantiates a client 46 | const loggingClient = new MetricsServiceV2Client(); 47 | 48 | async function callUpdateLogMetric() { 49 | // Construct request 50 | const request = { 51 | metricName, 52 | metric, 53 | }; 54 | 55 | // Run request 56 | const response = await loggingClient.updateLogMetric(request); 57 | console.log(response); 58 | } 59 | 60 | callUpdateLogMetric(); 61 | // [END logging_v2_generated_MetricsServiceV2_UpdateLogMetric_async] 62 | } 63 | 64 | process.on('unhandledRejection', err => { 65 | console.error(err.message); 66 | process.exitCode = 1; 67 | }); 68 | main(...process.argv.slice(2)); 69 | -------------------------------------------------------------------------------- /samples/http-request.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | // sample-metadata: 18 | // title: Log HTTP Request 19 | // description: Log a message with httpRequest metadata. 20 | // usage: node http-request my-project-id 21 | async function logHttpRequest( 22 | projectId = 'YOUR_PROJECT_ID', // Your Google Cloud Platform project ID 23 | logName = 'my-log', // The name of the log to write to 24 | requestMethod = 'GET', // GET, POST, PUT, etc. 25 | requestUrl = 'http://www.google.com', 26 | status = 200, 27 | userAgent = 'my-user-agent/1.0.0', 28 | latencySeconds = 3, 29 | responseSize = 256 // response size in bytes. 30 | ) { 31 | // [START logging_write_log_entry_advanced] 32 | // [START logging_http_request] 33 | /* 34 | const projectId = 'YOUR_PROJECT_ID'; // Your Google Cloud Platform project ID 35 | const logName = 'my-log'; // The name of the log to write to 36 | const requestMethod = 'GET'; // GET, POST, PUT, etc. 37 | const requestUrl = 'http://www.google.com'; 38 | const status = 200; 39 | const userAgent = `my-user-agent/1.0.0`; 40 | const latencySeconds = 3; 41 | const responseSize = 256; // response size in bytes. 42 | */ 43 | 44 | // Imports the Google Cloud client library 45 | const {Logging} = require('@google-cloud/logging'); 46 | 47 | // Creates a client 48 | const logging = new Logging({projectId}); 49 | 50 | // Selects the log to write to 51 | const log = logging.log(logName); 52 | 53 | // The data to write to the log 54 | const text = 'Hello, world!'; 55 | 56 | // The metadata associated with the entry 57 | const metadata = { 58 | resource: {type: 'global'}, 59 | httpRequest: { 60 | requestMethod, 61 | requestUrl, 62 | status, 63 | userAgent, 64 | latency: { 65 | seconds: latencySeconds, 66 | }, 67 | responseSize, 68 | }, 69 | }; 70 | 71 | // Prepares a log entry 72 | const entry = log.entry(metadata, text); 73 | 74 | // Writes the log entry 75 | async function writeLog() { 76 | await log.write(entry); 77 | console.log(`Logged: ${text}`); 78 | } 79 | writeLog(); 80 | // [END logging_http_request] 81 | // [END logging_write_log_entry_advanced] 82 | } 83 | 84 | const args = process.argv.slice(2); 85 | logHttpRequest(...args).catch(console.error); 86 | -------------------------------------------------------------------------------- /samples/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-docs-samples-logging", 3 | "private": true, 4 | "license": "Apache-2.0", 5 | "author": "Google Inc.", 6 | "repository": "googleapis/nodejs-logging", 7 | "files": [ 8 | "*.js" 9 | ], 10 | "engines": { 11 | "node": ">=14.0.0" 12 | }, 13 | "scripts": { 14 | "test": "mocha --timeout 60000" 15 | }, 16 | "dependencies": { 17 | "@google-cloud/logging": "^11.2.0", 18 | "@google-cloud/storage": "^6.0.0", 19 | "express": "^4.16.3", 20 | "fluent-logger": "^3.0.0", 21 | "yargs": "^17.0.0" 22 | }, 23 | "devDependencies": { 24 | "chai": "^4.2.0", 25 | "mocha": "^8.0.0", 26 | "proxyquire": "^2.1.0", 27 | "supertest": "^7.0.0", 28 | "uuid": "^9.0.0" 29 | } 30 | } -------------------------------------------------------------------------------- /samples/quickstart.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | // [START logging_quickstart] 18 | // Imports the Google Cloud client library 19 | const {Logging} = require('@google-cloud/logging'); 20 | 21 | async function quickstart( 22 | projectId = 'YOUR_PROJECT_ID', // Your Google Cloud Platform project ID 23 | logName = 'my-log' // The name of the log to write to 24 | ) { 25 | // Creates a client 26 | const logging = new Logging({projectId}); 27 | 28 | // Selects the log to write to 29 | const log = logging.log(logName); 30 | 31 | // The data to write to the log 32 | const text = 'Hello, world!'; 33 | 34 | // The metadata associated with the entry 35 | const metadata = { 36 | resource: {type: 'global'}, 37 | // See: https://cloud.google.com/logging/docs/reference/v2/rest/v2/LogEntry#logseverity 38 | severity: 'INFO', 39 | }; 40 | 41 | // Prepares a log entry 42 | const entry = log.entry(metadata, text); 43 | 44 | async function writeLog() { 45 | // Writes the log entry 46 | await log.write(entry); 47 | console.log(`Logged: ${text}`); 48 | } 49 | writeLog(); 50 | } 51 | // [END logging_quickstart] 52 | 53 | const args = process.argv.slice(2); 54 | quickstart(...args).catch(console.error); 55 | -------------------------------------------------------------------------------- /samples/test/fluent.test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | const proxyquire = require('proxyquire'); 18 | const request = require('supertest'); 19 | const {assert} = require('chai'); 20 | const {describe, it} = require('mocha'); 21 | 22 | describe('fluent', () => { 23 | it('should log error', done => { 24 | let loggerCalled = false; 25 | 26 | const structuredLogger = { 27 | emit: name => { 28 | loggerCalled = true; 29 | assert.strictEqual(name, 'errors'); 30 | }, 31 | }; 32 | 33 | const app = proxyquire('../fluent', { 34 | 'fluent-logger': { 35 | createFluentSender: (name, options) => { 36 | assert.strictEqual(name, 'myapp'); 37 | assert.deepStrictEqual(options, { 38 | host: 'localhost', 39 | port: 24224, 40 | timeout: 3.0, 41 | }); 42 | return structuredLogger; 43 | }, 44 | }, 45 | }); 46 | 47 | request(app) 48 | .get('/') 49 | .expect(500) 50 | .expect(() => { 51 | assert(loggerCalled, 'structuredLogger.emit should have been called'); 52 | }) 53 | .end(done); 54 | }); 55 | }); 56 | -------------------------------------------------------------------------------- /samples/test/http-request.test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2019 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | const {assert} = require('chai'); 18 | const {describe, it} = require('mocha'); 19 | const uuid = require('uuid'); 20 | const cp = require('child_process'); 21 | 22 | const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); 23 | 24 | const TESTS_PREFIX = 'nodejs-docs-samples-test'; 25 | const logName = `${TESTS_PREFIX}-${Date.now()}-${uuid.v4().split('-').pop()}`; 26 | const projectId = process.env.GCLOUD_PROJECT; 27 | const cmd = 'node http-request'; 28 | 29 | describe('http-request', () => { 30 | it('should log an entry', () => { 31 | const stdout = execSync(`${cmd} ${projectId} ${logName}`); 32 | assert.include(stdout, 'Logged: Hello, world!'); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /samples/test/logs.test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | const {assert} = require('chai'); 18 | const {describe, it, after} = require('mocha'); 19 | const cp = require('child_process'); 20 | const uuid = require('uuid'); 21 | 22 | const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); 23 | const cmd = 'node logs'; 24 | const TESTS_PREFIX = 'nodejs-docs-samples-test'; 25 | const logName = `${TESTS_PREFIX}-${Date.now()}-${uuid.v4().split('-').pop()}`; 26 | 27 | describe('logs', () => { 28 | after(async () => { 29 | const oneHourAgo = new Date(); 30 | oneHourAgo.setHours(oneHourAgo.getHours() - 1); 31 | }); 32 | 33 | it('should write a simple log entry', () => { 34 | const output = execSync(`${cmd} write-simple ${logName}`); 35 | assert.include(output, `Wrote to ${logName}`); 36 | }); 37 | }); 38 | -------------------------------------------------------------------------------- /samples/test/quickstart.test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | const {assert} = require('chai'); 18 | const {describe, it} = require('mocha'); 19 | const uuid = require('uuid'); 20 | const cp = require('child_process'); 21 | 22 | const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); 23 | 24 | const TESTS_PREFIX = 'nodejs-docs-samples-test'; 25 | const logName = `${TESTS_PREFIX}-${Date.now()}-${uuid.v4().split('-').pop()}`; 26 | const projectId = process.env.GCLOUD_PROJECT; 27 | const cmd = 'node quickstart'; 28 | 29 | describe('quickstart', () => { 30 | it('should log an entry', () => { 31 | const stdout = execSync(`${cmd} ${projectId} ${logName}`); 32 | assert.include(stdout, 'Logged: Hello, world!'); 33 | }); 34 | }); 35 | -------------------------------------------------------------------------------- /samples/test/sinks.test.js: -------------------------------------------------------------------------------- 1 | // Copyright 2017 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | 'use strict'; 16 | 17 | const {Logging} = new require('@google-cloud/logging'); 18 | const {Storage} = new require('@google-cloud/storage'); 19 | const {assert} = require('chai'); 20 | const {describe, it, before, after} = require('mocha'); 21 | assert.rejects = require('assert').rejects; 22 | const cp = require('child_process'); 23 | const uuid = require('uuid'); 24 | 25 | const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'}); 26 | 27 | const cmd = 'node sinks.js'; 28 | const TESTS_PREFIX = 'nodejs-logging-sinks-test-'; 29 | const bucketName = `${TESTS_PREFIX}${uuid.v4()}`; 30 | const sinkName = `${TESTS_PREFIX}${uuid.v4()}`; 31 | const filter = 'severity > WARNING'; 32 | const logging = new Logging(); 33 | const storage = new Storage(); 34 | 35 | describe('sinks', () => { 36 | before(async () => { 37 | await storage.createBucket(bucketName); 38 | }); 39 | 40 | after(async () => { 41 | // Only delete log buckets that are at least 2 days old 42 | // Fixes: https://github.com/googleapis/nodejs-logging/issues/976 43 | const twoDaysAgo = new Date(); 44 | twoDaysAgo.setDate(twoDaysAgo.getDate() - 2); 45 | 46 | const [buckets] = await storage.getBuckets({prefix: TESTS_PREFIX}); 47 | const bucketsToDelete = buckets.filter(bucket => { 48 | return new Date(bucket.metadata.timeCreated) < twoDaysAgo; 49 | }); 50 | 51 | for (const bucket of bucketsToDelete) { 52 | await bucket.deleteFiles(); 53 | await bucket.delete(); 54 | } 55 | }); 56 | 57 | it('should create a sink', async () => { 58 | const output = execSync( 59 | `${cmd} create ${sinkName} ${bucketName} "${filter}"` 60 | ); 61 | assert.include(output, `Created sink ${sinkName} to ${bucketName}`); 62 | const [metadata] = await logging.sink(sinkName).getMetadata(); 63 | assert.include(metadata.name, sinkName); 64 | assert.include(metadata.destination, bucketName); 65 | assert.include(metadata.filter, filter); 66 | }); 67 | 68 | it('should get a sink', () => { 69 | const output = execSync(`${cmd} get ${sinkName}`); 70 | assert.include(output, sinkName); 71 | }); 72 | 73 | it('should list sinks', () => { 74 | const output = execSync(`${cmd} list`); 75 | assert.include(output, 'Sinks:'); 76 | assert.include(output, sinkName); 77 | }); 78 | 79 | it('should update a sink', async () => { 80 | const newFilter = 'severity >= WARNING'; 81 | const output = execSync(`${cmd} update ${sinkName} "${newFilter}"`); 82 | assert.include(output, `Sink ${sinkName} updated.`); 83 | const [metadata] = await logging.sink(sinkName).getMetadata(); 84 | assert.include(metadata.name, sinkName); 85 | assert.include(metadata.destination, bucketName); 86 | assert.include(metadata.filter, newFilter); 87 | }); 88 | 89 | it('should delete a sink', async () => { 90 | const output = execSync(`${cmd} delete ${sinkName}`); 91 | assert.include(output, `Sink ${sinkName} deleted.`); 92 | await assert.rejects(logging.sink(sinkName).getMetadata()); 93 | }); 94 | }); 95 | -------------------------------------------------------------------------------- /src/middleware/express/index.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | export * from './make-middleware'; 18 | -------------------------------------------------------------------------------- /src/middleware/express/make-middleware.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as http from 'http'; 18 | import onFinished = require('on-finished'); 19 | import {getOrInjectContext} from '../../utils/context'; 20 | import { 21 | makeHttpRequestData, 22 | ServerRequest, 23 | CloudLoggingHttpRequest, 24 | } from '../../utils/http-request'; 25 | 26 | interface AnnotatedRequestType extends ServerRequest { 27 | log: LoggerType; 28 | } 29 | 30 | /** 31 | * Generates an express middleware that installs a request-specific logger on 32 | * the `request` object. It optionally can do HttpRequest timing that can be 33 | * used for generating request logs. This can be used to integrate with logging 34 | * libraries such as winston and bunyan. 35 | * 36 | * @param projectId Generated traceIds will be associated with this project. 37 | * @param makeChildLogger A function that generates logger instances that will 38 | * be installed onto `req` as `req.log`. The logger should include the trace in 39 | * each log entry's metadata (associated with the LOGGING_TRACE_KEY property. 40 | * @param emitRequestLog Optional. A function that will emit a parent request 41 | * log. While some environments like GAE and GCF emit parent request logs 42 | * automatically, other environments do not. When provided this function will be 43 | * called with a populated `CloudLoggingHttpRequest` which can be emitted as 44 | * request log. 45 | */ 46 | export function makeMiddleware( 47 | projectId: string, 48 | makeChildLogger: ( 49 | trace: string, 50 | span?: string, 51 | traceSampled?: boolean 52 | ) => LoggerType, 53 | emitRequestLog?: ( 54 | httpRequest: CloudLoggingHttpRequest, 55 | trace: string, 56 | span?: string, 57 | traceSampled?: boolean 58 | ) => void 59 | ) { 60 | return (req: ServerRequest, res: http.ServerResponse, next: Function) => { 61 | // TODO(ofrobots): use high-resolution timer. 62 | const requestStartMs = Date.now(); 63 | 64 | // Detect & establish context if we were the first actor to detect lack of 65 | // context so traceContext is always available when using middleware. 66 | const traceContext = getOrInjectContext(req, projectId, true); 67 | 68 | // Install a child logger on the request object, with detected trace and 69 | // span. 70 | (req as AnnotatedRequestType).log = makeChildLogger( 71 | traceContext.trace, 72 | traceContext.spanId, 73 | traceContext.traceSampled 74 | ); 75 | 76 | // Emit a 'Request Log' on the parent logger, with detected trace and 77 | // span. 78 | if (emitRequestLog) { 79 | onFinished(res, () => { 80 | const latencyMs = Date.now() - requestStartMs; 81 | const httpRequest = makeHttpRequestData(req, res, latencyMs); 82 | emitRequestLog( 83 | httpRequest, 84 | traceContext.trace, 85 | traceContext.spanId, 86 | traceContext.traceSampled 87 | ); 88 | }); 89 | } 90 | 91 | next(); 92 | }; 93 | } 94 | -------------------------------------------------------------------------------- /src/middleware/index.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * Copyright 2018 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import * as express from './express'; 18 | 19 | export {express}; 20 | -------------------------------------------------------------------------------- /src/utils/log-common.ts: -------------------------------------------------------------------------------- 1 | /*! 2 | * Copyright 2021 Google LLC 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | /** 18 | * Common construct and functions used by both Log and LogSync 19 | */ 20 | 21 | import {Entry} from '../entry'; 22 | import * as extend from 'extend'; 23 | import arrify = require('arrify'); 24 | import {google} from '../../protos/protos'; 25 | 26 | export interface WriteOptions { 27 | labels?: {[index: string]: string}; 28 | resource?: MonitoredResource; 29 | } 30 | 31 | export type MonitoredResource = google.api.IMonitoredResource; 32 | 33 | export enum Severity { 34 | emergency, 35 | alert, 36 | critical, 37 | error, 38 | warning, 39 | notice, 40 | info, 41 | debug, 42 | } 43 | export type SeverityNames = keyof typeof Severity; 44 | 45 | // Mapped types are only supported in type aliases and not in interfaces and 46 | // classes. 47 | export type LogSeverityFunctions = { 48 | // FIXME: the following can be made more precise. 49 | [P in SeverityNames]: Function; 50 | }; 51 | 52 | /** 53 | * snakecaseKeys turns label keys from camel case to snake case. 54 | * @param labels 55 | */ 56 | export function snakecaseKeys( 57 | labels: {[p: string]: string} | null | undefined 58 | ) { 59 | for (const key in labels) { 60 | const replaced = key.replace( 61 | /[A-Z]/g, 62 | letter => `_${letter.toLowerCase()}` 63 | ); 64 | Object.defineProperty( 65 | labels, 66 | replaced, 67 | Object.getOwnPropertyDescriptor(labels, key) as PropertyDescriptor 68 | ); 69 | if (replaced !== key) { 70 | delete labels[key]; 71 | } 72 | } 73 | return labels; 74 | } 75 | 76 | /** 77 | * Return an array of log entries with the desired severity assigned. 78 | * 79 | * @private 80 | * 81 | * @param {object|object[]} entries - Log entries. 82 | * @param {string} severity - The desired severity level. 83 | */ 84 | export function assignSeverityToEntries( 85 | entries: Entry | Entry[], 86 | severity: string 87 | ): Entry[] { 88 | return (arrify(entries) as Entry[]).map(entry => { 89 | const metadata = extend(true, {}, entry.metadata, { 90 | severity, 91 | }); 92 | return extend(new Entry(), entry, { 93 | metadata, 94 | }); 95 | }); 96 | } 97 | 98 | /** 99 | * Format the name of a log. A log's full name is in the format of 100 | * 'projects/{projectId}/logs/{logName}'. 101 | * 102 | * @param projectId 103 | * @param name 104 | */ 105 | export function formatLogName(projectId: string, name: string) { 106 | const path = 'projects/' + projectId + '/logs/'; 107 | name = name.replace(path, ''); 108 | if (decodeURIComponent(name) === name) { 109 | // The name has not been encoded yet. 110 | name = encodeURIComponent(name); 111 | } 112 | return path + name; 113 | } 114 | -------------------------------------------------------------------------------- /src/v2/config_service_v2_proto_list.json: -------------------------------------------------------------------------------- 1 | [ 2 | "../../protos/google/logging/type/http_request.proto", 3 | "../../protos/google/logging/type/log_severity.proto", 4 | "../../protos/google/logging/v2/log_entry.proto", 5 | "../../protos/google/logging/v2/logging.proto", 6 | "../../protos/google/logging/v2/logging_config.proto", 7 | "../../protos/google/logging/v2/logging_metrics.proto" 8 | ] 9 | -------------------------------------------------------------------------------- /src/v2/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | export {ConfigServiceV2Client} from './config_service_v2_client'; 20 | export {LoggingServiceV2Client} from './logging_service_v2_client'; 21 | export {MetricsServiceV2Client} from './metrics_service_v2_client'; 22 | -------------------------------------------------------------------------------- /src/v2/logging_service_v2_client_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "interfaces": { 3 | "google.logging.v2.LoggingServiceV2": { 4 | "retry_codes": { 5 | "non_idempotent": [], 6 | "idempotent": [ 7 | "DEADLINE_EXCEEDED", 8 | "UNAVAILABLE" 9 | ], 10 | "deadline_exceeded_internal_unavailable": [ 11 | "DEADLINE_EXCEEDED", 12 | "INTERNAL", 13 | "UNAVAILABLE" 14 | ] 15 | }, 16 | "retry_params": { 17 | "default": { 18 | "initial_retry_delay_millis": 100, 19 | "retry_delay_multiplier": 1.3, 20 | "max_retry_delay_millis": 60000, 21 | "initial_rpc_timeout_millis": 60000, 22 | "rpc_timeout_multiplier": 1, 23 | "max_rpc_timeout_millis": 60000, 24 | "total_timeout_millis": 600000 25 | } 26 | }, 27 | "methods": { 28 | "DeleteLog": { 29 | "timeout_millis": 60000, 30 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 31 | "retry_params_name": "default" 32 | }, 33 | "WriteLogEntries": { 34 | "timeout_millis": 60000, 35 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 36 | "retry_params_name": "default", 37 | "bundling": { 38 | "element_count_threshold": 1000, 39 | "request_byte_threshold": 1048576, 40 | "delay_threshold_millis": 50, 41 | "element_count_limit": 1000000 42 | } 43 | }, 44 | "ListLogEntries": { 45 | "timeout_millis": 60000, 46 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 47 | "retry_params_name": "default" 48 | }, 49 | "ListMonitoredResourceDescriptors": { 50 | "timeout_millis": 60000, 51 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 52 | "retry_params_name": "default" 53 | }, 54 | "ListLogs": { 55 | "timeout_millis": 60000, 56 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 57 | "retry_params_name": "default" 58 | }, 59 | "TailLogEntries": { 60 | "timeout_millis": 3600000, 61 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 62 | "retry_params_name": "default" 63 | } 64 | } 65 | } 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/v2/logging_service_v2_proto_list.json: -------------------------------------------------------------------------------- 1 | [ 2 | "../../protos/google/logging/type/http_request.proto", 3 | "../../protos/google/logging/type/log_severity.proto", 4 | "../../protos/google/logging/v2/log_entry.proto", 5 | "../../protos/google/logging/v2/logging.proto", 6 | "../../protos/google/logging/v2/logging_config.proto", 7 | "../../protos/google/logging/v2/logging_metrics.proto" 8 | ] 9 | -------------------------------------------------------------------------------- /src/v2/metrics_service_v2_client_config.json: -------------------------------------------------------------------------------- 1 | { 2 | "interfaces": { 3 | "google.logging.v2.MetricsServiceV2": { 4 | "retry_codes": { 5 | "non_idempotent": [], 6 | "idempotent": [ 7 | "DEADLINE_EXCEEDED", 8 | "UNAVAILABLE" 9 | ], 10 | "deadline_exceeded_internal_unavailable": [ 11 | "DEADLINE_EXCEEDED", 12 | "INTERNAL", 13 | "UNAVAILABLE" 14 | ] 15 | }, 16 | "retry_params": { 17 | "default": { 18 | "initial_retry_delay_millis": 100, 19 | "retry_delay_multiplier": 1.3, 20 | "max_retry_delay_millis": 60000, 21 | "initial_rpc_timeout_millis": 60000, 22 | "rpc_timeout_multiplier": 1, 23 | "max_rpc_timeout_millis": 60000, 24 | "total_timeout_millis": 600000 25 | } 26 | }, 27 | "methods": { 28 | "ListLogMetrics": { 29 | "timeout_millis": 60000, 30 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 31 | "retry_params_name": "default" 32 | }, 33 | "GetLogMetric": { 34 | "timeout_millis": 60000, 35 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 36 | "retry_params_name": "default" 37 | }, 38 | "CreateLogMetric": { 39 | "timeout_millis": 60000, 40 | "retry_codes_name": "non_idempotent", 41 | "retry_params_name": "default" 42 | }, 43 | "UpdateLogMetric": { 44 | "timeout_millis": 60000, 45 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 46 | "retry_params_name": "default" 47 | }, 48 | "DeleteLogMetric": { 49 | "timeout_millis": 60000, 50 | "retry_codes_name": "deadline_exceeded_internal_unavailable", 51 | "retry_params_name": "default" 52 | } 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/v2/metrics_service_v2_proto_list.json: -------------------------------------------------------------------------------- 1 | [ 2 | "../../protos/google/logging/type/http_request.proto", 3 | "../../protos/google/logging/type/log_severity.proto", 4 | "../../protos/google/logging/v2/log_entry.proto", 5 | "../../protos/google/logging/v2/logging.proto", 6 | "../../protos/google/logging/v2/logging_config.proto", 7 | "../../protos/google/logging/v2/logging_metrics.proto" 8 | ] 9 | -------------------------------------------------------------------------------- /system-test/fixtures/sample/src/index.js: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | /* eslint-disable n/no-missing-require, no-unused-vars */ 20 | const logging = require('@google-cloud/logging'); 21 | 22 | function main() { 23 | new logging.Logging(); 24 | } 25 | 26 | main(); 27 | -------------------------------------------------------------------------------- /system-test/fixtures/sample/src/index.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2020 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | import {Logging} from '@google-cloud/logging'; 20 | 21 | function main() { 22 | new Logging(); 23 | } 24 | 25 | main(); 26 | -------------------------------------------------------------------------------- /system-test/install.ts: -------------------------------------------------------------------------------- 1 | // Copyright 2024 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | // 15 | // ** This file is automatically generated by gapic-generator-typescript. ** 16 | // ** https://github.com/googleapis/gapic-generator-typescript ** 17 | // ** All changes to this file may be overwritten. ** 18 | 19 | import {packNTest} from 'pack-n-play'; 20 | import {readFileSync} from 'fs'; 21 | import {describe, it} from 'mocha'; 22 | 23 | describe('📦 pack-n-play test', () => { 24 | it('TypeScript code', async function () { 25 | this.timeout(300000); 26 | const options = { 27 | packageDir: process.cwd(), 28 | sample: { 29 | description: 'TypeScript user can use the type definitions', 30 | ts: readFileSync( 31 | './system-test/fixtures/sample/src/index.ts' 32 | ).toString(), 33 | }, 34 | }; 35 | await packNTest(options); 36 | }); 37 | 38 | it('JavaScript code', async function () { 39 | this.timeout(300000); 40 | const options = { 41 | packageDir: process.cwd(), 42 | sample: { 43 | description: 'JavaScript user can use the library', 44 | ts: readFileSync( 45 | './system-test/fixtures/sample/src/index.js' 46 | ).toString(), 47 | }, 48 | }; 49 | await packNTest(options); 50 | }); 51 | }); 52 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./node_modules/gts/tsconfig-google.json", 3 | "compilerOptions": { 4 | "rootDir": ".", 5 | "outDir": "build", 6 | "resolveJsonModule": true, 7 | "lib": [ 8 | "es2018", 9 | "dom" 10 | ] 11 | }, 12 | "include": [ 13 | "src/*.ts", 14 | "src/**/*.ts", 15 | "test/*.ts", 16 | "test/**/*.ts", 17 | "system-test/*.ts" 18 | ] 19 | } 20 | -------------------------------------------------------------------------------- /webpack.config.js: -------------------------------------------------------------------------------- 1 | // Copyright 2021 Google LLC 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // https://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | const path = require('path'); 16 | 17 | module.exports = { 18 | entry: './src/index.ts', 19 | output: { 20 | library: 'logging', 21 | filename: './logging.js', 22 | }, 23 | node: { 24 | child_process: 'empty', 25 | fs: 'empty', 26 | crypto: 'empty', 27 | }, 28 | resolve: { 29 | alias: { 30 | '../../../package.json': path.resolve(__dirname, 'package.json'), 31 | }, 32 | extensions: ['.js', '.json', '.ts'], 33 | }, 34 | module: { 35 | rules: [ 36 | { 37 | test: /\.tsx?$/, 38 | use: 'ts-loader', 39 | exclude: /node_modules/, 40 | }, 41 | { 42 | test: /node_modules[\\/]@grpc[\\/]grpc-js/, 43 | use: 'null-loader', 44 | }, 45 | { 46 | test: /node_modules[\\/]grpc/, 47 | use: 'null-loader', 48 | }, 49 | { 50 | test: /node_modules[\\/]retry-request/, 51 | use: 'null-loader', 52 | }, 53 | { 54 | test: /node_modules[\\/]https?-proxy-agent/, 55 | use: 'null-loader', 56 | }, 57 | { 58 | test: /node_modules[\\/]gtoken/, 59 | use: 'null-loader', 60 | }, 61 | ], 62 | }, 63 | mode: 'production', 64 | }; 65 | --------------------------------------------------------------------------------