├── .github ├── CODEOWNERS ├── CODE_OF_CONDUCT.md ├── ISSUE_TEMPLATE.md ├── header-checker-lint.yml ├── release-please.yml ├── release-trigger.yml ├── sync-repo-settings.yaml └── workflows │ ├── generate.yml │ ├── test-generator-fallback.yml │ └── test-generator.yml ├── .gitignore ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── SECURITY.md ├── cloud ├── alloydbdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── apigatewaydata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── apigeeregistrydata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── auditdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── batchdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── beyondcorp │ ├── appconnectionsdata │ │ ├── data.pb.go │ │ ├── data_test.go │ │ └── doc.go │ ├── appconnectorsdata │ │ ├── data.pb.go │ │ ├── data_test.go │ │ └── doc.go │ ├── appgatewaysdata │ │ ├── data.pb.go │ │ ├── data_test.go │ │ └── doc.go │ ├── clientconnectorservicesdata │ │ ├── data.pb.go │ │ ├── data_test.go │ │ └── doc.go │ └── clientgatewaysdata │ │ ├── data.pb.go │ │ ├── data_test.go │ │ └── doc.go ├── certificatemanagerdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── cloudbuilddata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── clouddmsdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── dataflowdatav1beta3 │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── datafusiondata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── dataplexdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── datastoredata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── datastreamdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── deploydata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── eventarcdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── firestoredata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── functionsdatav2 │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── gkebackupdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── gkehubdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── iotdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── memcachedata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── metastoredata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── networkconnectivitydata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── networkmanagementdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── networkservicesdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── notebooksdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── redisdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── schedulerdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── speechdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── storagedata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── video │ └── transcoderdata │ │ ├── data.pb.go │ │ ├── data_test.go │ │ └── doc.go ├── visionaidata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── vmmigrationdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go └── workflowsdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── examples ├── example_storage_test.go ├── go.mod └── go.sum ├── firebase ├── analyticsdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── authdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── databasedata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── firebasealertsdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── remoteconfigdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go └── testlabdata │ ├── data.pb.go │ ├── data_test.go │ └── doc.go ├── generate-code.sh ├── generators ├── protoc-gen-go-googlecetypes │ ├── generator.go │ ├── go.mod │ └── go.sum └── templates │ └── validationtest.gotpl ├── go.mod ├── go.sum ├── internal └── testhelper │ ├── prepare.go │ └── testhelper.go ├── renovate.json ├── third_party └── googleapis │ └── google │ └── api │ └── monitored_resource.pb.go └── tools └── setup-generator.sh /.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 | * @googleapis/torus-dpe 8 | -------------------------------------------------------------------------------- /.github/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Google Open Source Community Guidelines 2 | 3 | At Google, we recognize and celebrate the creativity and collaboration of open 4 | source contributors and the diversity of skills, experiences, cultures, and 5 | opinions they bring to the projects and communities they participate in. 6 | 7 | Every one of Google's open source projects and communities are inclusive 8 | environments, based on treating all individuals respectfully, regardless of 9 | gender identity and expression, sexual orientation, disabilities, 10 | neurodiversity, physical appearance, body size, ethnicity, nationality, race, 11 | age, religion, or similar personal characteristic. 12 | 13 | We value diverse opinions, but we value respectful behavior more. 14 | 15 | Respectful behavior includes: 16 | 17 | * Being considerate, kind, constructive, and helpful. 18 | * Not engaging in demeaning, discriminatory, harassing, hateful, sexualized, or 19 | physically threatening behavior, speech, and imagery. 20 | * Not engaging in unwanted physical contact. 21 | 22 | Some Google open source projects [may adopt][] an explicit project code of 23 | conduct, which may have additional detailed expectations for participants. Most 24 | of those projects will use our [modified Contributor Covenant][]. 25 | 26 | [may adopt]: https://opensource.google/docs/releasing/preparing/#conduct 27 | [modified Contributor Covenant]: https://opensource.google/docs/releasing/template/CODE_OF_CONDUCT/ 28 | 29 | ## Resolve peacefully 30 | 31 | We do not believe that all conflict is necessarily bad; healthy debate and 32 | disagreement often yields positive results. However, it is never okay to be 33 | disrespectful. 34 | 35 | If you see someone behaving disrespectfully, you are encouraged to address the 36 | behavior directly with those involved. Many issues can be resolved quickly and 37 | easily, and this gives people more control over the outcome of their dispute. 38 | If you are unable to resolve the matter for any reason, or if the behavior is 39 | threatening or harassing, report it. We are dedicated to providing an 40 | environment where participants feel welcome and safe. 41 | 42 | ## Reporting problems 43 | 44 | Some Google open source projects may adopt a project-specific code of conduct. 45 | In those cases, a Google employee will be identified as the Project Steward, 46 | who will receive and handle reports of code of conduct violations. In the event 47 | that a project hasn’t identified a Project Steward, you can report problems by 48 | emailing opensource@google.com. 49 | 50 | We will investigate every complaint, but you may not receive a direct response. 51 | We will use our discretion in determining when and how to follow up on reported 52 | incidents, which may range from not taking action to permanent expulsion from 53 | the project and project-sponsored spaces. We will notify the accused of the 54 | report and provide them an opportunity to discuss it before any action is 55 | taken. The identity of the reporter will be omitted from the details of the 56 | report supplied to the accused. In potentially harmful situations, such as 57 | ongoing harassment or threats to anyone's safety, we may take action without 58 | notice. 59 | 60 | *This document was adapted from the [IndieWeb Code of Conduct][] and can also 61 | be found at .* 62 | 63 | [IndieWeb Code of Conduct]: https://indieweb.org/code-of-conduct 64 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | ## Expected Behavior 2 | 3 | 4 | ## Actual Behavior 5 | 6 | 7 | ## Steps to Reproduce the Problem 8 | 9 | -------------------------------------------------------------------------------- /.github/header-checker-lint.yml: -------------------------------------------------------------------------------- 1 | allowedCopyrightHolders: 2 | - 'Google LLC' 3 | allowedLicenses: 4 | - 'Apache-2.0' 5 | sourceFileExtensions: 6 | - 'go' 7 | - 'sh' 8 | - 'yml' 9 | - 'yaml' 10 | -------------------------------------------------------------------------------- /.github/release-please.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2023 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 | handleGHRelease: true 16 | releaseType: go 17 | releaseLabel: "autorelease: published" 18 | bumpMinorPreMajor: true 19 | tagPullRequestNumber: true 20 | -------------------------------------------------------------------------------- /.github/release-trigger.yml: -------------------------------------------------------------------------------- 1 | enabled: true 2 | multiScmName: google-cloudevents-go -------------------------------------------------------------------------------- /.github/sync-repo-settings.yaml: -------------------------------------------------------------------------------- 1 | # Copyright 2023 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 | rebaseMergeAllowed: true 16 | squashMergeAllowed: true 17 | mergeCommitAllowed: false 18 | branchProtectionRules: 19 | - pattern: master 20 | requiredStatusCheckContexts: 21 | - 'cla/google' 22 | requiredApprovingReviewCount: 1 23 | requiresCodeOwnerReviews: true 24 | requiresStrictStatusChecks: true 25 | permissionRules: 26 | - team: cloudevents-admins 27 | permission: push 28 | - team: torus-dpe 29 | permission: admin 30 | -------------------------------------------------------------------------------- /.github/workflows/generate.yml: -------------------------------------------------------------------------------- 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 | 15 | name: Generate Library & Open Pull Request 16 | 17 | # Uses protos from HEAD of https://github.com/googleapis/google-cloudevents 18 | # and tooling from HEAD of this repository to update all generated code. 19 | # 20 | # Creates a PR whose branch will include an unmodified snapshot of the 21 | # tooling used to generate changes. 22 | 23 | on: 24 | schedule: 25 | # Run at the end of every day. (10:10pm PT, 5:10am UTC) 26 | - cron: 10 5 * * * 27 | workflow_dispatch: 28 | 29 | jobs: 30 | # Create a pull request. 31 | create-pr: 32 | runs-on: ubuntu-latest 33 | permissions: 34 | contents: read 35 | issues: write 36 | pull-requests: write 37 | concurrency: 38 | group: ${{ github.workflow }} 39 | cancel-in-progress: true 40 | env: 41 | # Library & Data Source repos using side-by-side checkout. 42 | LIBRARY_CHECKOUT_PATH: library # sync with defaults.run.working-directory 43 | DATA_SOURCE_CHECKOUT_PATH: protos-source-repo 44 | 45 | steps: 46 | - name: Go Library > Checkout Repository 47 | uses: actions/checkout@v4 48 | with: 49 | path: ${{ env.LIBRARY_CHECKOUT_PATH }} 50 | 51 | - name: Proto Schemas > Checkout Repository 52 | uses: actions/checkout@v4 53 | with: 54 | repository: googleapis/google-cloudevents 55 | path: ${{ env.DATA_SOURCE_CHECKOUT_PATH }} 56 | 57 | - name: Set Environment 58 | # Validation Test execution requires absolute path to testdata. 59 | run: echo "GENERATE_DATA_SOURCE=${PWD}/${DATA_SOURCE_CHECKOUT_PATH}" | tee -a $GITHUB_ENV 60 | 61 | - name: Setup Go 62 | uses: actions/setup-go@v5 63 | with: 64 | go-version: 1.23.x 65 | 66 | - name: Install the generator 67 | run: bash tools/setup-generator.sh 68 | working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }} 69 | 70 | - name: Run the generator 71 | run: bash ./generate-code.sh 72 | working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }} 73 | env: 74 | GENERATE_PROTOC_PATH: tmp/protobuf/bin/protoc 75 | GOFLAGS: "-v" 76 | 77 | - name: View generator output 78 | if: ${{ failure() }} 79 | working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }} 80 | run: | 81 | git add -N . # Needed if files are untracked 82 | git diff 83 | 84 | # This step identifies the github revision of the data source repository. 85 | # This is used to create a detailed Pull Request description. 86 | - name: Source Version 87 | id: source-version 88 | if: ${{ always() }} 89 | run: | 90 | rev=$(git rev-parse --short HEAD) 91 | echo "revision=${rev}" | tee -a $GITHUB_OUTPUT 92 | working-directory: ${{ env.DATA_SOURCE_CHECKOUT_PATH }} 93 | 94 | - name: Create a pull request with updates 95 | # https://github.com/googleapis/code-suggester#Action 96 | uses: googleapis/code-suggester@v5 97 | env: 98 | # Provided by the GitHub Automation team 99 | ACCESS_TOKEN: ${{ secrets.YOSHI_CODE_BOT_TOKEN }} 100 | with: 101 | command: pr 102 | upstream_owner: ${{ github.repository_owner }} 103 | upstream_repo: 'google-cloudevents-go' 104 | 105 | # Pull Request Title 106 | title: 'feat: Run the code generator' 107 | # Commit Message 108 | message: 'feat: Run the code generator (${{ steps.source-version.outputs.revision }})' 109 | description: | 110 | :robot: Auto-generated Pull Request. 111 | 112 | This PR was created from a recent update in the [google-cloudevents](https://github.com/googleapis/google-cloudevents) repository. 113 | Specifically, the change at https://github.com/googleapis/google-cloudevents/commit/${{ steps.source-version.outputs.revision }}. 114 | 115 | Future updates to the protos in that repository made before this PR is 116 | merged will lead to a force push update of this Pull Request with 117 | the latest changes. 118 | 119 | * **Generator configuration:** https://github.com/${{ github.repository }}/blob/${{ steps.source-version.outputs.revision }}/.github/workflows/generate.yml 120 | * **Generator Setup Script:** https://github.com/${{ github.repository }}/blob/${{ github.sha }}/tools/setup-generator.sh 121 | * **Generator script:** https://github.com/${{ github.repository }}/blob/${{ github.sha }}/generate-code.sh 122 | 123 | # A static branch name and force pushes are meant to create 124 | # a single open PR with all pending updates. 125 | branch: 'generator' 126 | force: true 127 | 128 | fork: true # action automatically forks repo 129 | git_dir: ${{ env.LIBRARY_CHECKOUT_PATH }} 130 | primary: 'main' 131 | 132 | - name: Notify for failure 133 | if: ${{ failure() && github.event_name == 'schedule' }} 134 | uses: actions/github-script@v7 135 | with: 136 | script: | 137 | github.rest.issues.create({ 138 | owner: context.repo.owner, 139 | repo: context.repo.repo, 140 | title: 'Library generation failed (${{ steps.source-version.outputs.revision }})', 141 | body: `See [failed job](https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId})`, 142 | }); 143 | -------------------------------------------------------------------------------- /.github/workflows/test-generator-fallback.yml: -------------------------------------------------------------------------------- 1 | # Copyright 2023 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 | name: Test Library Generation > Fallback 16 | 17 | # This workflow defines fallback handling for required 'test-generator' check. 18 | # This workflow defines a no-op check so PRs without build impact will be passed. 19 | # https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/troubleshooting-required-status-checks#handling-skipped-but-required-checks 20 | 21 | on: 22 | pull_request: 23 | # Sync with test-generator.yml on.pull_request.paths 24 | paths-ignore: 25 | - '.github/workflows/test-generator.yml' 26 | - 'generate-code.sh' 27 | - 'generators/**' 28 | - 'internal/**' 29 | - 'tools/**' 30 | 31 | jobs: 32 | test-generator: 33 | runs-on: ubuntu-latest 34 | permissions: 35 | contents: none 36 | 37 | steps: 38 | - run: 'echo "No build required"' 39 | -------------------------------------------------------------------------------- /.github/workflows/test-generator.yml: -------------------------------------------------------------------------------- 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 | 15 | name: Test Library Generation 16 | 17 | # Uses protos from HEAD of https://github.com/googleapis/google-cloudevents 18 | # and tooling from the current branch to check library generation. 19 | # 20 | # If the generator fails, the check will fail. If the generator succeeds 21 | # tests will run to establish changes in the tooling, event schemas, and testdata 22 | # have not fallen out of sync. 23 | 24 | on: 25 | pull_request: 26 | # Sync with test-generator-fallback.yml on.pull_request.paths-ignore 27 | paths: 28 | - '.github/workflows/test-generator.yml' 29 | - 'generate-code.sh' 30 | - 'generators/**' 31 | - 'internal/**' 32 | - 'tools/**' 33 | 34 | jobs: 35 | 36 | test-generator: 37 | runs-on: ubuntu-latest 38 | permissions: 39 | contents: read 40 | concurrency: 41 | group: ${{ github.workflow }}-${{ github.ref }} 42 | cancel-in-progress: true 43 | env: 44 | # Library & Data Source repos using side-by-side checkout. 45 | LIBRARY_CHECKOUT_PATH: library # sync with defaults.run.working-directory 46 | DATA_SOURCE_CHECKOUT_PATH: protos-source-repo 47 | 48 | steps: 49 | - name: Go Library > Checkout Repository 50 | uses: actions/checkout@v4 51 | with: 52 | path: ${{ env.LIBRARY_CHECKOUT_PATH }} 53 | 54 | - name: Proto Schemas > Checkout Repository 55 | uses: actions/checkout@v4 56 | with: 57 | repository: googleapis/google-cloudevents 58 | path: ${{ env.DATA_SOURCE_CHECKOUT_PATH }} 59 | 60 | - name: Set Environment 61 | # Validation Test execution requires absolute path to testdata. 62 | run: echo "GENERATE_DATA_SOURCE=${PWD}/${DATA_SOURCE_CHECKOUT_PATH}" | tee -a $GITHUB_ENV 63 | 64 | - name: Setup Go 65 | uses: actions/setup-go@v5 66 | with: 67 | go-version: 1.23.x 68 | 69 | - name: Install the generator 70 | run: bash tools/setup-generator.sh 71 | working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }} 72 | 73 | - name: Run the generator 74 | run: bash ./generate-code.sh 75 | working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }} 76 | env: 77 | GENERATE_PROTOC_PATH: tmp/protobuf/bin/protoc 78 | GOFLAGS: "-v" 79 | 80 | - name: View generator output 81 | if: ${{ always() }} 82 | working-directory: ${{ env.LIBRARY_CHECKOUT_PATH }} 83 | run: | 84 | git add -N . # Needed if files are untracked 85 | git diff --ignore-all-space --ignore-blank-lines -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | tmp/ 2 | generated.txt 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute 2 | 3 | We'd love to accept your patches and contributions to this project. There are 4 | just a few small guidelines you need to follow. 5 | 6 | ## Contributor License Agreement 7 | 8 | Contributions to this project must be accompanied by a Contributor License 9 | Agreement. You (or your employer) retain the copyright to your contribution; 10 | this simply gives us permission to use and redistribute your contributions as 11 | part of the project. Head over to to see 12 | your current agreements on file or to sign a new one. 13 | 14 | You generally only need to submit a CLA once, so if you've already submitted one 15 | (even if it was for a different project), you probably don't need to do it 16 | again. 17 | 18 | ## Code reviews 19 | 20 | All submissions, including submissions by project members, require review. We 21 | use GitHub pull requests for this purpose. Consult 22 | [GitHub Help](https://help.github.com/articles/about-pull-requests/) for more 23 | information on using pull requests. 24 | 25 | ## Community Guidelines 26 | 27 | This project follows [Google's Open Source Community 28 | Guidelines](https://opensource.google/conduct/). 29 | 30 | ## Seeing Changes in this Library 31 | 32 | Most of this library is created via code generation. Changes merged that affect 33 | the code generation tooling will not be seen until: 34 | 35 | * The nightly job that evaluates changes is run and opens a PR 36 | * The PR is reviewed and merged 37 | 38 | ## Making Changes 39 | 40 | ### Modifying Data Types 41 | 42 | The data types offered by this library are generated from protobuf. Changes will 43 | not be accepted. 44 | 45 | ### Modifying Validation Tests 46 | 47 | Validation tests are generated based on metadata in the protos that are used to 48 | define the event data types. This is a custom generator that can be modified. 49 | 50 | Once test generation is modified, the code update made by running the generator 51 | will include the test updates. 52 | 53 | * **Modify the template code:** generators/templates/validationtest.gotpl 54 | * **Modify the template parameter creation**: generators/protoc-gen-go-googlecetypes/generator.go 55 | 56 | If you modify the protoc-gen-go-googlecetypes Go code, the generator will not pick 57 | up your changes unless you run `go install` from inside the `protoc-gen-go-googlecetypes` 58 | directory. 59 | 60 | ### Adding Validation Test Cases 61 | 62 | Send a PR to the [google-cloudevents parent repository](https://github.com/googleapis/google-cloudevents) 63 | to add or update a complete JSON test case in the testdata directory. 64 | 65 | ## Generating the Library Locally 66 | 67 | Generate the library using protobuf-based tooling. 68 | 69 | ```sh 70 | git clone https://github.com/googleapis/google-cloudevents-go 71 | cd google-cloudevents-go 72 | sh ./tools/setup-generator.sh 73 | export GENERATE_DATA_SOURCE="${PWD}/tmp/google-cloudevents" 74 | export GENERATE_PROTOC_PATH=tmp/protobuf/bin/protoc 75 | sh ./generate-code.sh 76 | ``` 77 | 78 | ### Generating the Library Locally (With local protos) 79 | 80 | The "data source" for code generation is a collection of protos maintained in 81 | [googleapis/google-cloudevets](https://github.com/googleapis/google-cloudevents). 82 | 83 | If you have a local copy of this repository, such as for trying modifications to 84 | those protos, you can use these instructions to use that copy instead of 85 | retrieving a new clone. 86 | 87 | ```sh 88 | cd /path/to/shared/repositories 89 | git clone https://github.com/googleapis/google-cloudevents --depth 1 90 | 91 | cd path/to/the/project 92 | git clone https://github.com/googleapis/google-cloudevents-go 93 | 94 | # Configure this before running the setup script to reuse the repository. 95 | export GENERATE_DATA_SOURCE=/absolute/path/to/shared/repositories/google-cloudevents 96 | sh ./tools/setup-generator.sh 97 | export GENERATE_PROTOC_PATH=tmp/protobuf/bin/protoc 98 | sh ./generate-code.sh 99 | ``` 100 | 101 | ### Troubleshooting 102 | 103 | #### Support in `realpath` for `--relative-to` 104 | 105 | Running the `generate-code.sh` script might result in an error similar to: 106 | 107 | ``` 108 | /bin/realpath: illegal option -- - 109 | ``` 110 | 111 | OSX and other environments do not have a version of the `realpath` command 112 | that includes support for `--relative-to`. 113 | 114 | On OSX, this can be fixed by installing `coreutils`, such as via this 115 | [homebrew formulae](https://formulae.brew.sh/formula/coreutils). 116 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Google CloudEvents - Go 2 | 3 | [![GoDoc](https://img.shields.io/badge/go-documentation-blue.svg?style=flat-square)](https://pkg.go.dev/mod/github.com/googleapis/google-cloudevents-go) [![Preview](https://img.shields.io/badge/stability-preview-orange?style=flat-square)](https://cloud.google.com/products#section-22) 4 | 5 | This library provides Go types for Google CloudEvent data. 6 | 7 | ## Features 8 | 9 | - Simple import and interface 10 | - Inline documentation for Go structs 11 | - Automatic decoding of base64 data 12 | - Enum support 13 | - Protobuf bindings 14 | 15 | ## Installation 16 | 17 | To install this package, run: 18 | 19 | ``` sh 20 | go get -u github.com/googleapis/google-cloudevents-go 21 | ``` 22 | 23 | This library requires Go 1.17+ and is tested with Go 1.19. 24 | 25 | ## Usage 26 | 27 | Unmarshal a CloudEvent data payload from raw bytes. 28 | 29 | 30 | ```golang 31 | package examples 32 | 33 | import ( 34 | "fmt" 35 | "log" 36 | "time" 37 | 38 | "github.com/googleapis/google-cloudevents-go/cloud/storagedata" 39 | "google.golang.org/protobuf/encoding/protojson" 40 | ) 41 | 42 | // cloudEventPayload is initialized with an example CloudEvent data payload. 43 | // Source: github.com/googleapis/google-cloudevents/tree/main/examples/binary/storage/StorageObjectData-simple.json 44 | var cloudEventPayload = []byte(` 45 | { 46 | "bucket": "sample-bucket", 47 | "contentType": "text/plain", 48 | "crc32c": "rTVTeQ==", 49 | "etag": "CNHZkbuF/ugCEAE=", 50 | "generation": "1587627537231057", 51 | "id": "sample-bucket/folder/Test.cs/1587627537231057", 52 | "kind": "storage#object", 53 | "md5Hash": "kF8MuJ5+CTJxvyhHS1xzRg==", 54 | "mediaLink": "https://www.googleapis.com/download/storage/v1/b/sample-bucket/o/folder%2FTest.cs?generation=1587627537231057\u0026alt=media", 55 | "metageneration": "1", 56 | "name": "folder/Test.cs", 57 | "selfLink": "https://www.googleapis.com/storage/v1/b/sample-bucket/o/folder/Test.cs", 58 | "size": "352", 59 | "storageClass": "MULTI_REGIONAL", 60 | "timeCreated": "2020-04-23T07:38:57.230Z", 61 | "timeStorageClassUpdated": "2020-04-23T07:38:57.230Z", 62 | "updated": "2020-04-23T07:38:57.230Z" 63 | }`) 64 | 65 | func Example() { 66 | data := storagedata.StorageObjectData{} 67 | 68 | // If you omit `DiscardUnknown`, protojson.Unmarshal returns an error 69 | // when encountering a new or unknown field. 70 | options := protojson.UnmarshalOptions{ 71 | DiscardUnknown: true, 72 | } 73 | if err := options.Unmarshal(cloudEventPayload, &data); err != nil { 74 | log.Fatal("protojson.Unmarshal: ", err) 75 | } 76 | 77 | updated := data.Updated.AsTime().Format(time.UnixDate) 78 | fmt.Printf("Bucket: %s, Object: %s, Updated: %s", data.Bucket, data.Name, updated) 79 | 80 | // Output: Bucket: sample-bucket, Object: folder/Test.cs, Updated: Thu Apr 23 07:38:57 UTC 2020 81 | } 82 | ``` 83 | 84 | ## Contributing 85 | 86 | Contributions to this library are always welcome and highly encouraged. 87 | 88 | See [CONTRIBUTING](./CONTRIBUTING.md) for more information how to get started. 89 | 90 | Please note that this project is released with a Contributor Code of Conduct. 91 | By participating in this project you agree to abide by its terms. 92 | See Code of Conduct for more information. 93 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /cloud/alloydbdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/alloydb/v1/events.proto 20 | 21 | package alloydbdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/alloydbdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingBackupEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "BackupEventData", "google/events/cloud/alloydb/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := alloydbdata.BackupEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := alloydbdata.BackupEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingClusterEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "ClusterEventData", "google/events/cloud/alloydb/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := alloydbdata.ClusterEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := alloydbdata.ClusterEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | 111 | // Validate the type can parse test data. 112 | // Goals: 113 | // - "Loose" parsing confirms the expected library experience 114 | // - "Strict" parsing confirms: 115 | // - no deleted or renamed fields in protos covered in test data 116 | // - test data does not carry unknown fields 117 | func TestParsingInstanceEventData(t *testing.T) { 118 | cases := testhelper.FindTestData(t, "InstanceEventData", "google/events/cloud/alloydb/v1") 119 | 120 | for name, file := range cases { 121 | t.Run(name, func(t *testing.T) { 122 | data, err := os.ReadFile(file) 123 | if err != nil { 124 | t.Fatal("os.ReadFile:", err) 125 | } 126 | 127 | if ext := filepath.Ext(file); ext != ".json" { 128 | t.Fatalf("test support for %q data not implemented", ext) 129 | } 130 | 131 | t.Run("loose", func(t *testing.T) { 132 | out := alloydbdata.InstanceEventData{} 133 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 134 | if err := pj.Unmarshal(data, &out); err != nil { 135 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 136 | } 137 | }) 138 | 139 | t.Run("strict", func(t *testing.T) { 140 | out := alloydbdata.InstanceEventData{} 141 | if err := protojson.Unmarshal(data, &out); err != nil { 142 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 143 | } 144 | }) 145 | 146 | }) 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /cloud/alloydbdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package alloydbdata provides AlloyDB for PostgreSQL type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.alloydb.cluster.v1.created 6 | // - google.cloud.alloydb.cluster.v1.updated 7 | // - google.cloud.alloydb.cluster.v1.deleted 8 | // - google.cloud.alloydb.instance.v1.created 9 | // - google.cloud.alloydb.instance.v1.updated 10 | // - google.cloud.alloydb.instance.v1.deleted 11 | // - google.cloud.alloydb.backup.v1.created 12 | // - google.cloud.alloydb.backup.v1.updated 13 | // - google.cloud.alloydb.backup.v1.deleted 14 | package alloydbdata 15 | -------------------------------------------------------------------------------- /cloud/apigatewaydata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/apigateway/v1/events.proto 20 | 21 | package apigatewaydata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/apigatewaydata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingApiConfigEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "ApiConfigEventData", "google/events/cloud/apigateway/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := apigatewaydata.ApiConfigEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := apigatewaydata.ApiConfigEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingApiEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "ApiEventData", "google/events/cloud/apigateway/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := apigatewaydata.ApiEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := apigatewaydata.ApiEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | 111 | // Validate the type can parse test data. 112 | // Goals: 113 | // - "Loose" parsing confirms the expected library experience 114 | // - "Strict" parsing confirms: 115 | // - no deleted or renamed fields in protos covered in test data 116 | // - test data does not carry unknown fields 117 | func TestParsingGatewayEventData(t *testing.T) { 118 | cases := testhelper.FindTestData(t, "GatewayEventData", "google/events/cloud/apigateway/v1") 119 | 120 | for name, file := range cases { 121 | t.Run(name, func(t *testing.T) { 122 | data, err := os.ReadFile(file) 123 | if err != nil { 124 | t.Fatal("os.ReadFile:", err) 125 | } 126 | 127 | if ext := filepath.Ext(file); ext != ".json" { 128 | t.Fatalf("test support for %q data not implemented", ext) 129 | } 130 | 131 | t.Run("loose", func(t *testing.T) { 132 | out := apigatewaydata.GatewayEventData{} 133 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 134 | if err := pj.Unmarshal(data, &out); err != nil { 135 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 136 | } 137 | }) 138 | 139 | t.Run("strict", func(t *testing.T) { 140 | out := apigatewaydata.GatewayEventData{} 141 | if err := protojson.Unmarshal(data, &out); err != nil { 142 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 143 | } 144 | }) 145 | 146 | }) 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /cloud/apigatewaydata/doc.go: -------------------------------------------------------------------------------- 1 | // Package apigatewaydata provides API Gateway type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.apigateway.gateway.v1.created 6 | // - google.cloud.apigateway.gateway.v1.updated 7 | // - google.cloud.apigateway.gateway.v1.deleted 8 | // - google.cloud.apigateway.api.v1.created 9 | // - google.cloud.apigateway.api.v1.updated 10 | // - google.cloud.apigateway.api.v1.deleted 11 | // - google.cloud.apigateway.apiConfig.v1.created 12 | // - google.cloud.apigateway.apiConfig.v1.updated 13 | // - google.cloud.apigateway.apiConfig.v1.deleted 14 | package apigatewaydata 15 | -------------------------------------------------------------------------------- /cloud/apigeeregistrydata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/apigeeregistry/v1/events.proto 20 | 21 | package apigeeregistrydata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/apigeeregistrydata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingApiDeploymentEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "ApiDeploymentEventData", "google/events/cloud/apigeeregistry/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := apigeeregistrydata.ApiDeploymentEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := apigeeregistrydata.ApiDeploymentEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingApiEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "ApiEventData", "google/events/cloud/apigeeregistry/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := apigeeregistrydata.ApiEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := apigeeregistrydata.ApiEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | 111 | // Validate the type can parse test data. 112 | // Goals: 113 | // - "Loose" parsing confirms the expected library experience 114 | // - "Strict" parsing confirms: 115 | // - no deleted or renamed fields in protos covered in test data 116 | // - test data does not carry unknown fields 117 | func TestParsingApiSpecEventData(t *testing.T) { 118 | cases := testhelper.FindTestData(t, "ApiSpecEventData", "google/events/cloud/apigeeregistry/v1") 119 | 120 | for name, file := range cases { 121 | t.Run(name, func(t *testing.T) { 122 | data, err := os.ReadFile(file) 123 | if err != nil { 124 | t.Fatal("os.ReadFile:", err) 125 | } 126 | 127 | if ext := filepath.Ext(file); ext != ".json" { 128 | t.Fatalf("test support for %q data not implemented", ext) 129 | } 130 | 131 | t.Run("loose", func(t *testing.T) { 132 | out := apigeeregistrydata.ApiSpecEventData{} 133 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 134 | if err := pj.Unmarshal(data, &out); err != nil { 135 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 136 | } 137 | }) 138 | 139 | t.Run("strict", func(t *testing.T) { 140 | out := apigeeregistrydata.ApiSpecEventData{} 141 | if err := protojson.Unmarshal(data, &out); err != nil { 142 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 143 | } 144 | }) 145 | 146 | }) 147 | } 148 | } 149 | 150 | // Validate the type can parse test data. 151 | // Goals: 152 | // - "Loose" parsing confirms the expected library experience 153 | // - "Strict" parsing confirms: 154 | // - no deleted or renamed fields in protos covered in test data 155 | // - test data does not carry unknown fields 156 | func TestParsingApiVersionEventData(t *testing.T) { 157 | cases := testhelper.FindTestData(t, "ApiVersionEventData", "google/events/cloud/apigeeregistry/v1") 158 | 159 | for name, file := range cases { 160 | t.Run(name, func(t *testing.T) { 161 | data, err := os.ReadFile(file) 162 | if err != nil { 163 | t.Fatal("os.ReadFile:", err) 164 | } 165 | 166 | if ext := filepath.Ext(file); ext != ".json" { 167 | t.Fatalf("test support for %q data not implemented", ext) 168 | } 169 | 170 | t.Run("loose", func(t *testing.T) { 171 | out := apigeeregistrydata.ApiVersionEventData{} 172 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 173 | if err := pj.Unmarshal(data, &out); err != nil { 174 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 175 | } 176 | }) 177 | 178 | t.Run("strict", func(t *testing.T) { 179 | out := apigeeregistrydata.ApiVersionEventData{} 180 | if err := protojson.Unmarshal(data, &out); err != nil { 181 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 182 | } 183 | }) 184 | 185 | }) 186 | } 187 | } 188 | 189 | // Validate the type can parse test data. 190 | // Goals: 191 | // - "Loose" parsing confirms the expected library experience 192 | // - "Strict" parsing confirms: 193 | // - no deleted or renamed fields in protos covered in test data 194 | // - test data does not carry unknown fields 195 | func TestParsingInstanceEventData(t *testing.T) { 196 | cases := testhelper.FindTestData(t, "InstanceEventData", "google/events/cloud/apigeeregistry/v1") 197 | 198 | for name, file := range cases { 199 | t.Run(name, func(t *testing.T) { 200 | data, err := os.ReadFile(file) 201 | if err != nil { 202 | t.Fatal("os.ReadFile:", err) 203 | } 204 | 205 | if ext := filepath.Ext(file); ext != ".json" { 206 | t.Fatalf("test support for %q data not implemented", ext) 207 | } 208 | 209 | t.Run("loose", func(t *testing.T) { 210 | out := apigeeregistrydata.InstanceEventData{} 211 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 212 | if err := pj.Unmarshal(data, &out); err != nil { 213 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 214 | } 215 | }) 216 | 217 | t.Run("strict", func(t *testing.T) { 218 | out := apigeeregistrydata.InstanceEventData{} 219 | if err := protojson.Unmarshal(data, &out); err != nil { 220 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 221 | } 222 | }) 223 | 224 | }) 225 | } 226 | } 227 | -------------------------------------------------------------------------------- /cloud/apigeeregistrydata/doc.go: -------------------------------------------------------------------------------- 1 | // Package apigeeregistrydata provides Apigee Registry type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.apigeeregistry.instance.v1.created 6 | // - google.cloud.apigeeregistry.instance.v1.deleted 7 | // - google.cloud.apigeeregistry.api.v1.created 8 | // - google.cloud.apigeeregistry.api.v1.updated 9 | // - google.cloud.apigeeregistry.api.v1.deleted 10 | // - google.cloud.apigeeregistry.apiVersion.v1.created 11 | // - google.cloud.apigeeregistry.apiVersion.v1.updated 12 | // - google.cloud.apigeeregistry.apiVersion.v1.deleted 13 | // - google.cloud.apigeeregistry.apiSpec.v1.created 14 | // - google.cloud.apigeeregistry.apiSpec.v1.updated 15 | // - google.cloud.apigeeregistry.apiSpec.v1.deleted 16 | // - google.cloud.apigeeregistry.apiDeployment.v1.created 17 | // - google.cloud.apigeeregistry.apiDeployment.v1.updated 18 | // - google.cloud.apigeeregistry.apiDeployment.v1.deleted 19 | package apigeeregistrydata 20 | -------------------------------------------------------------------------------- /cloud/auditdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/audit/v1/events.proto 20 | 21 | package auditdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/auditdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingLogEntryData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "LogEntryData", "google/events/cloud/audit/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := auditdata.LogEntryData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | t.Skip("Data is not compatible with strict processing.") 63 | }) 64 | 65 | t.Run("compatibility", func(t *testing.T) { 66 | cleanData, err := testhelper.PrepareAuditLogEntryData(data) 67 | if err != nil { 68 | t.Errorf("could not prepare data for strict validation: %v", err) 69 | } 70 | 71 | out := auditdata.LogEntryData{} 72 | if err := protojson.Unmarshal(cleanData, &out); err != nil { 73 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 74 | } 75 | }) 76 | }) 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /cloud/auditdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package auditdata provides Cloud Audit Logs type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.audit.log.v1.written 6 | package auditdata 7 | -------------------------------------------------------------------------------- /cloud/batchdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/batch/v1/events.proto 20 | 21 | package batchdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/batchdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingJobEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "JobEventData", "google/events/cloud/batch/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := batchdata.JobEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := batchdata.JobEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/batchdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package batchdata provides Batch type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.batch.job.v1.created 6 | // - google.cloud.batch.job.v1.deleted 7 | package batchdata 8 | -------------------------------------------------------------------------------- /cloud/beyondcorp/appconnectionsdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/beyondcorp/appconnections/v1/events.proto 20 | 21 | package appconnectionsdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/beyondcorp/appconnectionsdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingAppConnectionEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "AppConnectionEventData", "google/events/cloud/beyondcorp/appconnections/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := appconnectionsdata.AppConnectionEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := appconnectionsdata.AppConnectionEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/beyondcorp/appconnectionsdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package appconnectionsdata provides BeyondCorp type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.beyondcorp.appconnections.appConnection.v1.created 6 | // - google.cloud.beyondcorp.appconnections.appConnection.v1.updated 7 | // - google.cloud.beyondcorp.appconnections.appConnection.v1.deleted 8 | package appconnectionsdata 9 | -------------------------------------------------------------------------------- /cloud/beyondcorp/appconnectorsdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/beyondcorp/appconnectors/v1/events.proto 20 | 21 | package appconnectorsdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/beyondcorp/appconnectorsdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingAppConnectorEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "AppConnectorEventData", "google/events/cloud/beyondcorp/appconnectors/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := appconnectorsdata.AppConnectorEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := appconnectorsdata.AppConnectorEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/beyondcorp/appconnectorsdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package appconnectorsdata provides BeyondCorp type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.beyondcorp.appconnectors.appConnector.v1.created 6 | // - google.cloud.beyondcorp.appconnectors.appConnector.v1.updated 7 | // - google.cloud.beyondcorp.appconnectors.appConnector.v1.deleted 8 | package appconnectorsdata 9 | -------------------------------------------------------------------------------- /cloud/beyondcorp/appgatewaysdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/beyondcorp/appgateways/v1/events.proto 20 | 21 | package appgatewaysdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/beyondcorp/appgatewaysdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingAppGatewayEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "AppGatewayEventData", "google/events/cloud/beyondcorp/appgateways/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := appgatewaysdata.AppGatewayEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := appgatewaysdata.AppGatewayEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/beyondcorp/appgatewaysdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package appgatewaysdata provides BeyondCorp type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.beyondcorp.appgateways.appGateway.v1.created 6 | // - google.cloud.beyondcorp.appgateways.appGateway.v1.deleted 7 | package appgatewaysdata 8 | -------------------------------------------------------------------------------- /cloud/beyondcorp/clientconnectorservicesdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/beyondcorp/clientconnectorservices/v1/events.proto 20 | 21 | package clientconnectorservicesdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/beyondcorp/clientconnectorservicesdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingClientConnectorServiceEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "ClientConnectorServiceEventData", "google/events/cloud/beyondcorp/clientconnectorservices/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := clientconnectorservicesdata.ClientConnectorServiceEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := clientconnectorservicesdata.ClientConnectorServiceEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/beyondcorp/clientconnectorservicesdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package clientconnectorservicesdata provides BeyondCorp type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.beyondcorp.clientconnectorservices.clientConnectorService.v1.created 6 | // - google.cloud.beyondcorp.clientconnectorservices.clientConnectorService.v1.updated 7 | // - google.cloud.beyondcorp.clientconnectorservices.clientConnectorService.v1.deleted 8 | package clientconnectorservicesdata 9 | -------------------------------------------------------------------------------- /cloud/beyondcorp/clientgatewaysdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/beyondcorp/clientgateways/v1/events.proto 20 | 21 | package clientgatewaysdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/beyondcorp/clientgatewaysdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingClientGatewayEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "ClientGatewayEventData", "google/events/cloud/beyondcorp/clientgateways/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := clientgatewaysdata.ClientGatewayEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := clientgatewaysdata.ClientGatewayEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/beyondcorp/clientgatewaysdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package clientgatewaysdata provides BeyondCorp type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.beyondcorp.clientgateways.clientGateway.v1.created 6 | // - google.cloud.beyondcorp.clientgateways.clientGateway.v1.deleted 7 | package clientgatewaysdata 8 | -------------------------------------------------------------------------------- /cloud/certificatemanagerdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package certificatemanagerdata provides Certificate Manager type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.certificatemanager.certificate.v1.created 6 | // - google.cloud.certificatemanager.certificate.v1.updated 7 | // - google.cloud.certificatemanager.certificate.v1.deleted 8 | // - google.cloud.certificatemanager.certificateMap.v1.created 9 | // - google.cloud.certificatemanager.certificateMap.v1.updated 10 | // - google.cloud.certificatemanager.certificateMap.v1.deleted 11 | // - google.cloud.certificatemanager.certificateMapEntry.v1.created 12 | // - google.cloud.certificatemanager.certificateMapEntry.v1.updated 13 | // - google.cloud.certificatemanager.certificateMapEntry.v1.deleted 14 | // - google.cloud.certificatemanager.dnsAuthorization.v1.created 15 | // - google.cloud.certificatemanager.dnsAuthorization.v1.updated 16 | // - google.cloud.certificatemanager.dnsAuthorization.v1.deleted 17 | // - google.cloud.certificatemanager.certificateIssuanceConfig.v1.created 18 | // - google.cloud.certificatemanager.certificateIssuanceConfig.v1.deleted 19 | package certificatemanagerdata 20 | -------------------------------------------------------------------------------- /cloud/cloudbuilddata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/cloudbuild/v1/events.proto 20 | 21 | package cloudbuilddata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/cloudbuilddata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingBuildEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "BuildEventData", "google/events/cloud/cloudbuild/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := cloudbuilddata.BuildEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := cloudbuilddata.BuildEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/cloudbuilddata/doc.go: -------------------------------------------------------------------------------- 1 | // Package cloudbuilddata provides Cloud Build type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.cloudbuild.build.v1.statusChanged 6 | package cloudbuilddata 7 | -------------------------------------------------------------------------------- /cloud/clouddmsdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/clouddms/v1/events.proto 20 | 21 | package clouddmsdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/clouddmsdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingConnectionProfileEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "ConnectionProfileEventData", "google/events/cloud/clouddms/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := clouddmsdata.ConnectionProfileEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := clouddmsdata.ConnectionProfileEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingMigrationJobEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "MigrationJobEventData", "google/events/cloud/clouddms/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := clouddmsdata.MigrationJobEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := clouddmsdata.MigrationJobEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /cloud/clouddmsdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package clouddmsdata provides Database Migration type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.clouddms.migrationJob.v1.created 6 | // - google.cloud.clouddms.migrationJob.v1.updated 7 | // - google.cloud.clouddms.migrationJob.v1.deleted 8 | // - google.cloud.clouddms.connectionProfile.v1.created 9 | // - google.cloud.clouddms.connectionProfile.v1.updated 10 | // - google.cloud.clouddms.connectionProfile.v1.deleted 11 | package clouddmsdata 12 | -------------------------------------------------------------------------------- /cloud/dataflowdatav1beta3/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/dataflow/v1beta3/events.proto 20 | 21 | package dataflowdatav1beta3_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/dataflowdatav1beta3" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingJobEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "JobEventData", "google/events/cloud/dataflow/v1beta3") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := dataflowdatav1beta3.JobEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := dataflowdatav1beta3.JobEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/dataflowdatav1beta3/doc.go: -------------------------------------------------------------------------------- 1 | // Package dataflowdatav1beta3 provides Dataflow type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.dataflow.job.v1beta3.statusChanged 6 | package dataflowdatav1beta3 7 | -------------------------------------------------------------------------------- /cloud/datafusiondata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/datafusion/v1/events.proto 20 | 21 | package datafusiondata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/datafusiondata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingDnsPeeringEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "DnsPeeringEventData", "google/events/cloud/datafusion/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := datafusiondata.DnsPeeringEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := datafusiondata.DnsPeeringEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingInstanceEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "InstanceEventData", "google/events/cloud/datafusion/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := datafusiondata.InstanceEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := datafusiondata.InstanceEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /cloud/datafusiondata/doc.go: -------------------------------------------------------------------------------- 1 | // Package datafusiondata provides Cloud Data Fusion type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.datafusion.instance.v1.created 6 | // - google.cloud.datafusion.instance.v1.deleted 7 | // - google.cloud.datafusion.instance.v1.updated 8 | // - google.cloud.datafusion.dnsPeering.v1.created 9 | // - google.cloud.datafusion.dnsPeering.v1.deleted 10 | package datafusiondata 11 | -------------------------------------------------------------------------------- /cloud/dataplexdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package dataplexdata provides Cloud Dataplex type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.dataplex.dataTaxonomy.v1.created 6 | // - google.cloud.dataplex.dataTaxonomy.v1.updated 7 | // - google.cloud.dataplex.dataTaxonomy.v1.deleted 8 | // - google.cloud.dataplex.dataAttributeBinding.v1.created 9 | // - google.cloud.dataplex.dataAttributeBinding.v1.updated 10 | // - google.cloud.dataplex.dataAttributeBinding.v1.deleted 11 | // - google.cloud.dataplex.dataAttribute.v1.created 12 | // - google.cloud.dataplex.dataAttribute.v1.updated 13 | // - google.cloud.dataplex.dataAttribute.v1.deleted 14 | // - google.cloud.dataplex.dataScan.v1.created 15 | // - google.cloud.dataplex.dataScan.v1.updated 16 | // - google.cloud.dataplex.dataScan.v1.deleted 17 | // - google.cloud.dataplex.lake.v1.created 18 | // - google.cloud.dataplex.lake.v1.updated 19 | // - google.cloud.dataplex.lake.v1.deleted 20 | // - google.cloud.dataplex.zone.v1.created 21 | // - google.cloud.dataplex.zone.v1.updated 22 | // - google.cloud.dataplex.zone.v1.deleted 23 | // - google.cloud.dataplex.asset.v1.created 24 | // - google.cloud.dataplex.asset.v1.updated 25 | // - google.cloud.dataplex.asset.v1.deleted 26 | // - google.cloud.dataplex.task.v1.created 27 | // - google.cloud.dataplex.task.v1.updated 28 | // - google.cloud.dataplex.task.v1.deleted 29 | // - google.cloud.dataplex.environment.v1.created 30 | // - google.cloud.dataplex.environment.v1.updated 31 | // - google.cloud.dataplex.environment.v1.deleted 32 | package dataplexdata 33 | -------------------------------------------------------------------------------- /cloud/datastoredata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/datastore/v1/events.proto 20 | 21 | package datastoredata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/datastoredata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingEntityEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "EntityEventData", "google/events/cloud/datastore/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := datastoredata.EntityEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := datastoredata.EntityEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/datastoredata/doc.go: -------------------------------------------------------------------------------- 1 | // Package datastoredata provides Cloud Firestore type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.datastore.entity.v1.created 6 | // - google.cloud.datastore.entity.v1.updated 7 | // - google.cloud.datastore.entity.v1.deleted 8 | // - google.cloud.datastore.entity.v1.written 9 | // - google.cloud.datastore.entity.v1.created.withAuthContext 10 | // - google.cloud.datastore.entity.v1.updated.withAuthContext 11 | // - google.cloud.datastore.entity.v1.deleted.withAuthContext 12 | // - google.cloud.datastore.entity.v1.written.withAuthContext 13 | package datastoredata 14 | -------------------------------------------------------------------------------- /cloud/datastreamdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/datastream/v1/events.proto 20 | 21 | package datastreamdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/datastreamdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingConnectionProfileEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "ConnectionProfileEventData", "google/events/cloud/datastream/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := datastreamdata.ConnectionProfileEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := datastreamdata.ConnectionProfileEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingPrivateConnectionEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "PrivateConnectionEventData", "google/events/cloud/datastream/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := datastreamdata.PrivateConnectionEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := datastreamdata.PrivateConnectionEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | 111 | // Validate the type can parse test data. 112 | // Goals: 113 | // - "Loose" parsing confirms the expected library experience 114 | // - "Strict" parsing confirms: 115 | // - no deleted or renamed fields in protos covered in test data 116 | // - test data does not carry unknown fields 117 | func TestParsingRouteEventData(t *testing.T) { 118 | cases := testhelper.FindTestData(t, "RouteEventData", "google/events/cloud/datastream/v1") 119 | 120 | for name, file := range cases { 121 | t.Run(name, func(t *testing.T) { 122 | data, err := os.ReadFile(file) 123 | if err != nil { 124 | t.Fatal("os.ReadFile:", err) 125 | } 126 | 127 | if ext := filepath.Ext(file); ext != ".json" { 128 | t.Fatalf("test support for %q data not implemented", ext) 129 | } 130 | 131 | t.Run("loose", func(t *testing.T) { 132 | out := datastreamdata.RouteEventData{} 133 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 134 | if err := pj.Unmarshal(data, &out); err != nil { 135 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 136 | } 137 | }) 138 | 139 | t.Run("strict", func(t *testing.T) { 140 | out := datastreamdata.RouteEventData{} 141 | if err := protojson.Unmarshal(data, &out); err != nil { 142 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 143 | } 144 | }) 145 | 146 | }) 147 | } 148 | } 149 | 150 | // Validate the type can parse test data. 151 | // Goals: 152 | // - "Loose" parsing confirms the expected library experience 153 | // - "Strict" parsing confirms: 154 | // - no deleted or renamed fields in protos covered in test data 155 | // - test data does not carry unknown fields 156 | func TestParsingStreamEventData(t *testing.T) { 157 | cases := testhelper.FindTestData(t, "StreamEventData", "google/events/cloud/datastream/v1") 158 | 159 | for name, file := range cases { 160 | t.Run(name, func(t *testing.T) { 161 | data, err := os.ReadFile(file) 162 | if err != nil { 163 | t.Fatal("os.ReadFile:", err) 164 | } 165 | 166 | if ext := filepath.Ext(file); ext != ".json" { 167 | t.Fatalf("test support for %q data not implemented", ext) 168 | } 169 | 170 | t.Run("loose", func(t *testing.T) { 171 | out := datastreamdata.StreamEventData{} 172 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 173 | if err := pj.Unmarshal(data, &out); err != nil { 174 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 175 | } 176 | }) 177 | 178 | t.Run("strict", func(t *testing.T) { 179 | out := datastreamdata.StreamEventData{} 180 | if err := protojson.Unmarshal(data, &out); err != nil { 181 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 182 | } 183 | }) 184 | 185 | }) 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /cloud/datastreamdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package datastreamdata provides Datastream type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.datastream.connectionProfile.v1.created 6 | // - google.cloud.datastream.connectionProfile.v1.updated 7 | // - google.cloud.datastream.connectionProfile.v1.deleted 8 | // - google.cloud.datastream.stream.v1.created 9 | // - google.cloud.datastream.stream.v1.updated 10 | // - google.cloud.datastream.stream.v1.deleted 11 | // - google.cloud.datastream.privateConnection.v1.created 12 | // - google.cloud.datastream.privateConnection.v1.deleted 13 | // - google.cloud.datastream.route.v1.created 14 | // - google.cloud.datastream.route.v1.deleted 15 | package datastreamdata 16 | -------------------------------------------------------------------------------- /cloud/deploydata/doc.go: -------------------------------------------------------------------------------- 1 | // Package deploydata provides Cloud Deploy type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.deploy.deliveryPipeline.v1.created 6 | // - google.cloud.deploy.deliveryPipeline.v1.updated 7 | // - google.cloud.deploy.deliveryPipeline.v1.deleted 8 | // - google.cloud.deploy.target.v1.created 9 | // - google.cloud.deploy.target.v1.updated 10 | // - google.cloud.deploy.target.v1.deleted 11 | // - google.cloud.deploy.customTargetType.v1.created 12 | // - google.cloud.deploy.customTargetType.v1.updated 13 | // - google.cloud.deploy.customTargetType.v1.deleted 14 | // - google.cloud.deploy.release.v1.created 15 | // - google.cloud.deploy.rollout.v1.created 16 | // - google.cloud.deploy.automation.v1.created 17 | // - google.cloud.deploy.automation.v1.updated 18 | // - google.cloud.deploy.automation.v1.deleted 19 | package deploydata 20 | -------------------------------------------------------------------------------- /cloud/eventarcdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/eventarc/v1/events.proto 20 | 21 | package eventarcdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/eventarcdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingChannelConnectionEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "ChannelConnectionEventData", "google/events/cloud/eventarc/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := eventarcdata.ChannelConnectionEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := eventarcdata.ChannelConnectionEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingChannelEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "ChannelEventData", "google/events/cloud/eventarc/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := eventarcdata.ChannelEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := eventarcdata.ChannelEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | 111 | // Validate the type can parse test data. 112 | // Goals: 113 | // - "Loose" parsing confirms the expected library experience 114 | // - "Strict" parsing confirms: 115 | // - no deleted or renamed fields in protos covered in test data 116 | // - test data does not carry unknown fields 117 | func TestParsingTriggerEventData(t *testing.T) { 118 | cases := testhelper.FindTestData(t, "TriggerEventData", "google/events/cloud/eventarc/v1") 119 | 120 | for name, file := range cases { 121 | t.Run(name, func(t *testing.T) { 122 | data, err := os.ReadFile(file) 123 | if err != nil { 124 | t.Fatal("os.ReadFile:", err) 125 | } 126 | 127 | if ext := filepath.Ext(file); ext != ".json" { 128 | t.Fatalf("test support for %q data not implemented", ext) 129 | } 130 | 131 | t.Run("loose", func(t *testing.T) { 132 | out := eventarcdata.TriggerEventData{} 133 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 134 | if err := pj.Unmarshal(data, &out); err != nil { 135 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 136 | } 137 | }) 138 | 139 | t.Run("strict", func(t *testing.T) { 140 | out := eventarcdata.TriggerEventData{} 141 | if err := protojson.Unmarshal(data, &out); err != nil { 142 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 143 | } 144 | }) 145 | 146 | }) 147 | } 148 | } 149 | -------------------------------------------------------------------------------- /cloud/eventarcdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package eventarcdata provides Eventarc type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.eventarc.trigger.v1.created 6 | // - google.cloud.eventarc.trigger.v1.updated 7 | // - google.cloud.eventarc.trigger.v1.deleted 8 | // - google.cloud.eventarc.channel.v1.created 9 | // - google.cloud.eventarc.channel.v1.updated 10 | // - google.cloud.eventarc.channel.v1.deleted 11 | // - google.cloud.eventarc.channelConnection.v1.created 12 | // - google.cloud.eventarc.channelConnection.v1.deleted 13 | package eventarcdata 14 | -------------------------------------------------------------------------------- /cloud/firestoredata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/firestore/v1/events.proto 20 | 21 | package firestoredata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/firestoredata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingDocumentEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "DocumentEventData", "google/events/cloud/firestore/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := firestoredata.DocumentEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := firestoredata.DocumentEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/firestoredata/doc.go: -------------------------------------------------------------------------------- 1 | // Package firestoredata provides Cloud Firestore type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.firestore.document.v1.created 6 | // - google.cloud.firestore.document.v1.updated 7 | // - google.cloud.firestore.document.v1.deleted 8 | // - google.cloud.firestore.document.v1.written 9 | // - google.cloud.firestore.document.v1.created.withAuthContext 10 | // - google.cloud.firestore.document.v1.updated.withAuthContext 11 | // - google.cloud.firestore.document.v1.deleted.withAuthContext 12 | // - google.cloud.firestore.document.v1.written.withAuthContext 13 | package firestoredata 14 | -------------------------------------------------------------------------------- /cloud/functionsdatav2/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/functions/v2/events.proto 20 | 21 | package functionsdatav2_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/functionsdatav2" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingFunctionEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "FunctionEventData", "google/events/cloud/functions/v2") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := functionsdatav2.FunctionEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := functionsdatav2.FunctionEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/functionsdatav2/doc.go: -------------------------------------------------------------------------------- 1 | // Package functionsdatav2 provides Cloud Functions type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.functions.function.v2.created 6 | // - google.cloud.functions.function.v2.updated 7 | // - google.cloud.functions.function.v2.deleted 8 | package functionsdatav2 9 | -------------------------------------------------------------------------------- /cloud/gkebackupdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/gkebackup/v1/events.proto 20 | 21 | package gkebackupdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/gkebackupdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingBackupEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "BackupEventData", "google/events/cloud/gkebackup/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := gkebackupdata.BackupEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := gkebackupdata.BackupEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingBackupPlanEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "BackupPlanEventData", "google/events/cloud/gkebackup/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := gkebackupdata.BackupPlanEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := gkebackupdata.BackupPlanEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | 111 | // Validate the type can parse test data. 112 | // Goals: 113 | // - "Loose" parsing confirms the expected library experience 114 | // - "Strict" parsing confirms: 115 | // - no deleted or renamed fields in protos covered in test data 116 | // - test data does not carry unknown fields 117 | func TestParsingRestoreEventData(t *testing.T) { 118 | cases := testhelper.FindTestData(t, "RestoreEventData", "google/events/cloud/gkebackup/v1") 119 | 120 | for name, file := range cases { 121 | t.Run(name, func(t *testing.T) { 122 | data, err := os.ReadFile(file) 123 | if err != nil { 124 | t.Fatal("os.ReadFile:", err) 125 | } 126 | 127 | if ext := filepath.Ext(file); ext != ".json" { 128 | t.Fatalf("test support for %q data not implemented", ext) 129 | } 130 | 131 | t.Run("loose", func(t *testing.T) { 132 | out := gkebackupdata.RestoreEventData{} 133 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 134 | if err := pj.Unmarshal(data, &out); err != nil { 135 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 136 | } 137 | }) 138 | 139 | t.Run("strict", func(t *testing.T) { 140 | out := gkebackupdata.RestoreEventData{} 141 | if err := protojson.Unmarshal(data, &out); err != nil { 142 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 143 | } 144 | }) 145 | 146 | }) 147 | } 148 | } 149 | 150 | // Validate the type can parse test data. 151 | // Goals: 152 | // - "Loose" parsing confirms the expected library experience 153 | // - "Strict" parsing confirms: 154 | // - no deleted or renamed fields in protos covered in test data 155 | // - test data does not carry unknown fields 156 | func TestParsingRestorePlanEventData(t *testing.T) { 157 | cases := testhelper.FindTestData(t, "RestorePlanEventData", "google/events/cloud/gkebackup/v1") 158 | 159 | for name, file := range cases { 160 | t.Run(name, func(t *testing.T) { 161 | data, err := os.ReadFile(file) 162 | if err != nil { 163 | t.Fatal("os.ReadFile:", err) 164 | } 165 | 166 | if ext := filepath.Ext(file); ext != ".json" { 167 | t.Fatalf("test support for %q data not implemented", ext) 168 | } 169 | 170 | t.Run("loose", func(t *testing.T) { 171 | out := gkebackupdata.RestorePlanEventData{} 172 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 173 | if err := pj.Unmarshal(data, &out); err != nil { 174 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 175 | } 176 | }) 177 | 178 | t.Run("strict", func(t *testing.T) { 179 | out := gkebackupdata.RestorePlanEventData{} 180 | if err := protojson.Unmarshal(data, &out); err != nil { 181 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 182 | } 183 | }) 184 | 185 | }) 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /cloud/gkebackupdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package gkebackupdata provides Backup for GKE type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.gkebackup.backupPlan.v1.created 6 | // - google.cloud.gkebackup.backupPlan.v1.updated 7 | // - google.cloud.gkebackup.backupPlan.v1.deleted 8 | // - google.cloud.gkebackup.backup.v1.created 9 | // - google.cloud.gkebackup.backup.v1.updated 10 | // - google.cloud.gkebackup.backup.v1.deleted 11 | // - google.cloud.gkebackup.restorePlan.v1.created 12 | // - google.cloud.gkebackup.restorePlan.v1.updated 13 | // - google.cloud.gkebackup.restorePlan.v1.deleted 14 | // - google.cloud.gkebackup.restore.v1.created 15 | // - google.cloud.gkebackup.restore.v1.updated 16 | // - google.cloud.gkebackup.restore.v1.deleted 17 | package gkebackupdata 18 | -------------------------------------------------------------------------------- /cloud/gkehubdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/gkehub/v1/events.proto 20 | 21 | package gkehubdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/gkehubdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingFeatureEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "FeatureEventData", "google/events/cloud/gkehub/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := gkehubdata.FeatureEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := gkehubdata.FeatureEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingMembershipBindingEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "MembershipBindingEventData", "google/events/cloud/gkehub/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := gkehubdata.MembershipBindingEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := gkehubdata.MembershipBindingEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | 111 | // Validate the type can parse test data. 112 | // Goals: 113 | // - "Loose" parsing confirms the expected library experience 114 | // - "Strict" parsing confirms: 115 | // - no deleted or renamed fields in protos covered in test data 116 | // - test data does not carry unknown fields 117 | func TestParsingMembershipEventData(t *testing.T) { 118 | cases := testhelper.FindTestData(t, "MembershipEventData", "google/events/cloud/gkehub/v1") 119 | 120 | for name, file := range cases { 121 | t.Run(name, func(t *testing.T) { 122 | data, err := os.ReadFile(file) 123 | if err != nil { 124 | t.Fatal("os.ReadFile:", err) 125 | } 126 | 127 | if ext := filepath.Ext(file); ext != ".json" { 128 | t.Fatalf("test support for %q data not implemented", ext) 129 | } 130 | 131 | t.Run("loose", func(t *testing.T) { 132 | out := gkehubdata.MembershipEventData{} 133 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 134 | if err := pj.Unmarshal(data, &out); err != nil { 135 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 136 | } 137 | }) 138 | 139 | t.Run("strict", func(t *testing.T) { 140 | out := gkehubdata.MembershipEventData{} 141 | if err := protojson.Unmarshal(data, &out); err != nil { 142 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 143 | } 144 | }) 145 | 146 | }) 147 | } 148 | } 149 | 150 | // Validate the type can parse test data. 151 | // Goals: 152 | // - "Loose" parsing confirms the expected library experience 153 | // - "Strict" parsing confirms: 154 | // - no deleted or renamed fields in protos covered in test data 155 | // - test data does not carry unknown fields 156 | func TestParsingScopeEventData(t *testing.T) { 157 | cases := testhelper.FindTestData(t, "ScopeEventData", "google/events/cloud/gkehub/v1") 158 | 159 | for name, file := range cases { 160 | t.Run(name, func(t *testing.T) { 161 | data, err := os.ReadFile(file) 162 | if err != nil { 163 | t.Fatal("os.ReadFile:", err) 164 | } 165 | 166 | if ext := filepath.Ext(file); ext != ".json" { 167 | t.Fatalf("test support for %q data not implemented", ext) 168 | } 169 | 170 | t.Run("loose", func(t *testing.T) { 171 | out := gkehubdata.ScopeEventData{} 172 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 173 | if err := pj.Unmarshal(data, &out); err != nil { 174 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 175 | } 176 | }) 177 | 178 | t.Run("strict", func(t *testing.T) { 179 | out := gkehubdata.ScopeEventData{} 180 | if err := protojson.Unmarshal(data, &out); err != nil { 181 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 182 | } 183 | }) 184 | 185 | }) 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /cloud/gkehubdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package gkehubdata provides GKE Hub type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.gkehub.membership.v1.created 6 | // - google.cloud.gkehub.feature.v1.created 7 | // - google.cloud.gkehub.membership.v1.deleted 8 | // - google.cloud.gkehub.feature.v1.deleted 9 | // - google.cloud.gkehub.membership.v1.updated 10 | // - google.cloud.gkehub.feature.v1.updated 11 | // - google.cloud.gkehub.scope.v1.created 12 | // - google.cloud.gkehub.scope.v1.deleted 13 | // - google.cloud.gkehub.membershipBinding.v1.created 14 | // - google.cloud.gkehub.membershipBinding.v1.updated 15 | // - google.cloud.gkehub.membershipBinding.v1.deleted 16 | package gkehubdata 17 | -------------------------------------------------------------------------------- /cloud/iotdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/iot/v1/events.proto 20 | 21 | package iotdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/iotdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingDeviceEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "DeviceEventData", "google/events/cloud/iot/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := iotdata.DeviceEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := iotdata.DeviceEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingRegistryEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "RegistryEventData", "google/events/cloud/iot/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := iotdata.RegistryEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := iotdata.RegistryEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /cloud/iotdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package iotdata provides Cloud IoT type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.iot.v1.DeviceManager.CreateDevice 6 | // - google.cloud.iot.v1.DeviceManager.UpdateDevice 7 | // - google.cloud.iot.v1.DeviceManager.DeleteDevice 8 | // - google.cloud.iot.v1.DeviceManager.CreateDeviceRegistry 9 | // - google.cloud.iot.v1.DeviceManager.UpdateDeviceRegistry 10 | // - google.cloud.iot.v1.DeviceManager.DeleteDeviceRegistry 11 | package iotdata 12 | -------------------------------------------------------------------------------- /cloud/memcachedata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/memcache/v1/events.proto 20 | 21 | package memcachedata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/memcachedata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingInstanceEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "InstanceEventData", "google/events/cloud/memcache/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := memcachedata.InstanceEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := memcachedata.InstanceEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/memcachedata/doc.go: -------------------------------------------------------------------------------- 1 | // Package memcachedata provides Cloud Memorystore for Memcached type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.memcache.instance.v1.created 6 | // - google.cloud.memcache.instance.v1.updated 7 | // - google.cloud.memcache.instance.v1.deleted 8 | package memcachedata 9 | -------------------------------------------------------------------------------- /cloud/metastoredata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/metastore/v1/events.proto 20 | 21 | package metastoredata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/metastoredata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingBackupEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "BackupEventData", "google/events/cloud/metastore/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := metastoredata.BackupEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := metastoredata.BackupEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingFederationEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "FederationEventData", "google/events/cloud/metastore/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := metastoredata.FederationEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := metastoredata.FederationEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | 111 | // Validate the type can parse test data. 112 | // Goals: 113 | // - "Loose" parsing confirms the expected library experience 114 | // - "Strict" parsing confirms: 115 | // - no deleted or renamed fields in protos covered in test data 116 | // - test data does not carry unknown fields 117 | func TestParsingMetadataImportEventData(t *testing.T) { 118 | cases := testhelper.FindTestData(t, "MetadataImportEventData", "google/events/cloud/metastore/v1") 119 | 120 | for name, file := range cases { 121 | t.Run(name, func(t *testing.T) { 122 | data, err := os.ReadFile(file) 123 | if err != nil { 124 | t.Fatal("os.ReadFile:", err) 125 | } 126 | 127 | if ext := filepath.Ext(file); ext != ".json" { 128 | t.Fatalf("test support for %q data not implemented", ext) 129 | } 130 | 131 | t.Run("loose", func(t *testing.T) { 132 | out := metastoredata.MetadataImportEventData{} 133 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 134 | if err := pj.Unmarshal(data, &out); err != nil { 135 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 136 | } 137 | }) 138 | 139 | t.Run("strict", func(t *testing.T) { 140 | out := metastoredata.MetadataImportEventData{} 141 | if err := protojson.Unmarshal(data, &out); err != nil { 142 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 143 | } 144 | }) 145 | 146 | }) 147 | } 148 | } 149 | 150 | // Validate the type can parse test data. 151 | // Goals: 152 | // - "Loose" parsing confirms the expected library experience 153 | // - "Strict" parsing confirms: 154 | // - no deleted or renamed fields in protos covered in test data 155 | // - test data does not carry unknown fields 156 | func TestParsingServiceEventData(t *testing.T) { 157 | cases := testhelper.FindTestData(t, "ServiceEventData", "google/events/cloud/metastore/v1") 158 | 159 | for name, file := range cases { 160 | t.Run(name, func(t *testing.T) { 161 | data, err := os.ReadFile(file) 162 | if err != nil { 163 | t.Fatal("os.ReadFile:", err) 164 | } 165 | 166 | if ext := filepath.Ext(file); ext != ".json" { 167 | t.Fatalf("test support for %q data not implemented", ext) 168 | } 169 | 170 | t.Run("loose", func(t *testing.T) { 171 | out := metastoredata.ServiceEventData{} 172 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 173 | if err := pj.Unmarshal(data, &out); err != nil { 174 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 175 | } 176 | }) 177 | 178 | t.Run("strict", func(t *testing.T) { 179 | out := metastoredata.ServiceEventData{} 180 | if err := protojson.Unmarshal(data, &out); err != nil { 181 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 182 | } 183 | }) 184 | 185 | }) 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /cloud/metastoredata/doc.go: -------------------------------------------------------------------------------- 1 | // Package metastoredata provides Dataproc Metastore type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.metastore.federation.v1.created 6 | // - google.cloud.metastore.federation.v1.updated 7 | // - google.cloud.metastore.federation.v1.deleted 8 | // - google.cloud.metastore.service.v1.created 9 | // - google.cloud.metastore.service.v1.updated 10 | // - google.cloud.metastore.service.v1.deleted 11 | // - google.cloud.metastore.metadataImport.v1.created 12 | // - google.cloud.metastore.metadataImport.v1.updated 13 | // - google.cloud.metastore.backup.v1.created 14 | // - google.cloud.metastore.backup.v1.deleted 15 | package metastoredata 16 | -------------------------------------------------------------------------------- /cloud/networkconnectivitydata/doc.go: -------------------------------------------------------------------------------- 1 | // Package networkconnectivitydata provides Network Connectivity type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.networkconnectivity.serviceConnectionMap.v1.created 6 | // - google.cloud.networkconnectivity.serviceConnectionMap.v1.updated 7 | // - google.cloud.networkconnectivity.serviceConnectionMap.v1.deleted 8 | // - google.cloud.networkconnectivity.serviceConnectionPolicy.v1.created 9 | // - google.cloud.networkconnectivity.serviceConnectionPolicy.v1.updated 10 | // - google.cloud.networkconnectivity.serviceConnectionPolicy.v1.deleted 11 | // - google.cloud.networkconnectivity.serviceClass.v1.updated 12 | // - google.cloud.networkconnectivity.serviceClass.v1.deleted 13 | // - google.cloud.networkconnectivity.serviceConnectionToken.v1.created 14 | // - google.cloud.networkconnectivity.serviceConnectionToken.v1.deleted 15 | // - google.cloud.networkconnectivity.hub.v1.created 16 | // - google.cloud.networkconnectivity.hub.v1.updated 17 | // - google.cloud.networkconnectivity.hub.v1.deleted 18 | // - google.cloud.networkconnectivity.spoke.v1.created 19 | // - google.cloud.networkconnectivity.spoke.v1.updated 20 | // - google.cloud.networkconnectivity.spoke.v1.deleted 21 | package networkconnectivitydata 22 | -------------------------------------------------------------------------------- /cloud/networkmanagementdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/networkmanagement/v1/events.proto 20 | 21 | package networkmanagementdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/networkmanagementdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingConnectivityTestEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "ConnectivityTestEventData", "google/events/cloud/networkmanagement/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := networkmanagementdata.ConnectivityTestEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := networkmanagementdata.ConnectivityTestEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/networkmanagementdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package networkmanagementdata provides Network Management type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.networkmanagement.connectivityTest.v1.created 6 | // - google.cloud.networkmanagement.connectivityTest.v1.updated 7 | // - google.cloud.networkmanagement.connectivityTest.v1.deleted 8 | package networkmanagementdata 9 | -------------------------------------------------------------------------------- /cloud/networkservicesdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package networkservicesdata provides Network Services type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.networkservices.endpointPolicy.v1.created 6 | // - google.cloud.networkservices.endpointPolicy.v1.updated 7 | // - google.cloud.networkservices.endpointPolicy.v1.deleted 8 | // - google.cloud.networkservices.gateway.v1.created 9 | // - google.cloud.networkservices.gateway.v1.updated 10 | // - google.cloud.networkservices.gateway.v1.deleted 11 | // - google.cloud.networkservices.grpcRoute.v1.created 12 | // - google.cloud.networkservices.grpcRoute.v1.updated 13 | // - google.cloud.networkservices.grpcRoute.v1.deleted 14 | // - google.cloud.networkservices.httpRoute.v1.created 15 | // - google.cloud.networkservices.httpRoute.v1.updated 16 | // - google.cloud.networkservices.httpRoute.v1.deleted 17 | // - google.cloud.networkservices.tcpRoute.v1.created 18 | // - google.cloud.networkservices.tcpRoute.v1.updated 19 | // - google.cloud.networkservices.tcpRoute.v1.deleted 20 | // - google.cloud.networkservices.tlsRoute.v1.created 21 | // - google.cloud.networkservices.tlsRoute.v1.updated 22 | // - google.cloud.networkservices.tlsRoute.v1.deleted 23 | // - google.cloud.networkservices.serviceBinding.v1.created 24 | // - google.cloud.networkservices.serviceBinding.v1.deleted 25 | // - google.cloud.networkservices.mesh.v1.created 26 | // - google.cloud.networkservices.mesh.v1.updated 27 | // - google.cloud.networkservices.mesh.v1.deleted 28 | package networkservicesdata 29 | -------------------------------------------------------------------------------- /cloud/notebooksdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/notebooks/v1/events.proto 20 | 21 | package notebooksdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/notebooksdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingEnvironmentEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "EnvironmentEventData", "google/events/cloud/notebooks/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := notebooksdata.EnvironmentEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := notebooksdata.EnvironmentEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingExecutionEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "ExecutionEventData", "google/events/cloud/notebooks/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := notebooksdata.ExecutionEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := notebooksdata.ExecutionEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | 111 | // Validate the type can parse test data. 112 | // Goals: 113 | // - "Loose" parsing confirms the expected library experience 114 | // - "Strict" parsing confirms: 115 | // - no deleted or renamed fields in protos covered in test data 116 | // - test data does not carry unknown fields 117 | func TestParsingInstanceEventData(t *testing.T) { 118 | cases := testhelper.FindTestData(t, "InstanceEventData", "google/events/cloud/notebooks/v1") 119 | 120 | for name, file := range cases { 121 | t.Run(name, func(t *testing.T) { 122 | data, err := os.ReadFile(file) 123 | if err != nil { 124 | t.Fatal("os.ReadFile:", err) 125 | } 126 | 127 | if ext := filepath.Ext(file); ext != ".json" { 128 | t.Fatalf("test support for %q data not implemented", ext) 129 | } 130 | 131 | t.Run("loose", func(t *testing.T) { 132 | out := notebooksdata.InstanceEventData{} 133 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 134 | if err := pj.Unmarshal(data, &out); err != nil { 135 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 136 | } 137 | }) 138 | 139 | t.Run("strict", func(t *testing.T) { 140 | out := notebooksdata.InstanceEventData{} 141 | if err := protojson.Unmarshal(data, &out); err != nil { 142 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 143 | } 144 | }) 145 | 146 | }) 147 | } 148 | } 149 | 150 | // Validate the type can parse test data. 151 | // Goals: 152 | // - "Loose" parsing confirms the expected library experience 153 | // - "Strict" parsing confirms: 154 | // - no deleted or renamed fields in protos covered in test data 155 | // - test data does not carry unknown fields 156 | func TestParsingRuntimeEventData(t *testing.T) { 157 | cases := testhelper.FindTestData(t, "RuntimeEventData", "google/events/cloud/notebooks/v1") 158 | 159 | for name, file := range cases { 160 | t.Run(name, func(t *testing.T) { 161 | data, err := os.ReadFile(file) 162 | if err != nil { 163 | t.Fatal("os.ReadFile:", err) 164 | } 165 | 166 | if ext := filepath.Ext(file); ext != ".json" { 167 | t.Fatalf("test support for %q data not implemented", ext) 168 | } 169 | 170 | t.Run("loose", func(t *testing.T) { 171 | out := notebooksdata.RuntimeEventData{} 172 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 173 | if err := pj.Unmarshal(data, &out); err != nil { 174 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 175 | } 176 | }) 177 | 178 | t.Run("strict", func(t *testing.T) { 179 | out := notebooksdata.RuntimeEventData{} 180 | if err := protojson.Unmarshal(data, &out); err != nil { 181 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 182 | } 183 | }) 184 | 185 | }) 186 | } 187 | } 188 | 189 | // Validate the type can parse test data. 190 | // Goals: 191 | // - "Loose" parsing confirms the expected library experience 192 | // - "Strict" parsing confirms: 193 | // - no deleted or renamed fields in protos covered in test data 194 | // - test data does not carry unknown fields 195 | func TestParsingScheduleEventData(t *testing.T) { 196 | cases := testhelper.FindTestData(t, "ScheduleEventData", "google/events/cloud/notebooks/v1") 197 | 198 | for name, file := range cases { 199 | t.Run(name, func(t *testing.T) { 200 | data, err := os.ReadFile(file) 201 | if err != nil { 202 | t.Fatal("os.ReadFile:", err) 203 | } 204 | 205 | if ext := filepath.Ext(file); ext != ".json" { 206 | t.Fatalf("test support for %q data not implemented", ext) 207 | } 208 | 209 | t.Run("loose", func(t *testing.T) { 210 | out := notebooksdata.ScheduleEventData{} 211 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 212 | if err := pj.Unmarshal(data, &out); err != nil { 213 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 214 | } 215 | }) 216 | 217 | t.Run("strict", func(t *testing.T) { 218 | out := notebooksdata.ScheduleEventData{} 219 | if err := protojson.Unmarshal(data, &out); err != nil { 220 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 221 | } 222 | }) 223 | 224 | }) 225 | } 226 | } 227 | -------------------------------------------------------------------------------- /cloud/notebooksdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package notebooksdata provides Notebooks type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.notebooks.runtime.v1.created 6 | // - google.cloud.notebooks.runtime.v1.updated 7 | // - google.cloud.notebooks.runtime.v1.deleted 8 | // - google.cloud.notebooks.instance.v1.created 9 | // - google.cloud.notebooks.instance.v1.deleted 10 | // - google.cloud.notebooks.environment.v1.created 11 | // - google.cloud.notebooks.environment.v1.deleted 12 | // - google.cloud.notebooks.schedule.v1.deleted 13 | // - google.cloud.notebooks.schedule.v1.created 14 | // - google.cloud.notebooks.execution.v1.deleted 15 | // - google.cloud.notebooks.execution.v1.created 16 | package notebooksdata 17 | -------------------------------------------------------------------------------- /cloud/redisdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/redis/v1/events.proto 20 | 21 | package redisdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/redisdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingInstanceEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "InstanceEventData", "google/events/cloud/redis/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := redisdata.InstanceEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := redisdata.InstanceEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/redisdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package redisdata provides Google Cloud Memorystore for Redis type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.redis.instance.v1.created 6 | // - google.cloud.redis.instance.v1.updated 7 | // - google.cloud.redis.instance.v1.deleted 8 | package redisdata 9 | -------------------------------------------------------------------------------- /cloud/schedulerdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/scheduler/v1/events.proto 20 | 21 | package schedulerdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/schedulerdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingJobEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "JobEventData", "google/events/cloud/scheduler/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := schedulerdata.JobEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := schedulerdata.JobEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingSchedulerJobData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "SchedulerJobData", "google/events/cloud/scheduler/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := schedulerdata.SchedulerJobData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := schedulerdata.SchedulerJobData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /cloud/schedulerdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package schedulerdata provides Cloud Scheduler type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.scheduler.job.v1.created 6 | // - google.cloud.scheduler.job.v1.updated 7 | // - google.cloud.scheduler.job.v1.deleted 8 | // - google.cloud.scheduler.job.v1.executed 9 | package schedulerdata 10 | -------------------------------------------------------------------------------- /cloud/speechdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/speech/v1/events.proto 20 | 21 | package speechdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/speechdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingCustomClassEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "CustomClassEventData", "google/events/cloud/speech/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := speechdata.CustomClassEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := speechdata.CustomClassEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingPhraseSetEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "PhraseSetEventData", "google/events/cloud/speech/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := speechdata.PhraseSetEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := speechdata.PhraseSetEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /cloud/speechdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package speechdata provides Cloud Speech-to-Text type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.speech.phraseSet.v1.created 6 | // - google.cloud.speech.phraseSet.v1.updated 7 | // - google.cloud.speech.phraseSet.v1.deleted 8 | // - google.cloud.speech.customClass.v1.created 9 | // - google.cloud.speech.customClass.v1.updated 10 | // - google.cloud.speech.customClass.v1.deleted 11 | package speechdata 12 | -------------------------------------------------------------------------------- /cloud/storagedata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/storage/v1/events.proto 20 | 21 | package storagedata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/storagedata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingStorageObjectData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "StorageObjectData", "google/events/cloud/storage/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := storagedata.StorageObjectData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := storagedata.StorageObjectData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/storagedata/doc.go: -------------------------------------------------------------------------------- 1 | // Package storagedata provides Cloud Storage type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.storage.object.v1.finalized 6 | // - google.cloud.storage.object.v1.archived 7 | // - google.cloud.storage.object.v1.deleted 8 | // - google.cloud.storage.object.v1.metadataUpdated 9 | package storagedata 10 | -------------------------------------------------------------------------------- /cloud/video/transcoderdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/video/transcoder/v1/events.proto 20 | 21 | package transcoderdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/video/transcoderdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingJobEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "JobEventData", "google/events/cloud/video/transcoder/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := transcoderdata.JobEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := transcoderdata.JobEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | 72 | // Validate the type can parse test data. 73 | // Goals: 74 | // - "Loose" parsing confirms the expected library experience 75 | // - "Strict" parsing confirms: 76 | // - no deleted or renamed fields in protos covered in test data 77 | // - test data does not carry unknown fields 78 | func TestParsingJobTemplateEventData(t *testing.T) { 79 | cases := testhelper.FindTestData(t, "JobTemplateEventData", "google/events/cloud/video/transcoder/v1") 80 | 81 | for name, file := range cases { 82 | t.Run(name, func(t *testing.T) { 83 | data, err := os.ReadFile(file) 84 | if err != nil { 85 | t.Fatal("os.ReadFile:", err) 86 | } 87 | 88 | if ext := filepath.Ext(file); ext != ".json" { 89 | t.Fatalf("test support for %q data not implemented", ext) 90 | } 91 | 92 | t.Run("loose", func(t *testing.T) { 93 | out := transcoderdata.JobTemplateEventData{} 94 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 95 | if err := pj.Unmarshal(data, &out); err != nil { 96 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 97 | } 98 | }) 99 | 100 | t.Run("strict", func(t *testing.T) { 101 | out := transcoderdata.JobTemplateEventData{} 102 | if err := protojson.Unmarshal(data, &out); err != nil { 103 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 104 | } 105 | }) 106 | 107 | }) 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /cloud/video/transcoderdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package transcoderdata provides Transcoder type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.video.transcoder.job.v1.created 6 | // - google.cloud.video.transcoder.job.v1.deleted 7 | // - google.cloud.video.transcoder.jobTemplate.v1.created 8 | // - google.cloud.video.transcoder.jobTemplate.v1.deleted 9 | package transcoderdata 10 | -------------------------------------------------------------------------------- /cloud/visionaidata/doc.go: -------------------------------------------------------------------------------- 1 | // Package visionaidata provides Vision AI type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.visionai.analysis.v1.created 6 | // - google.cloud.visionai.analysis.v1.updated 7 | // - google.cloud.visionai.analysis.v1.deleted 8 | // - google.cloud.visionai.process.v1.created 9 | // - google.cloud.visionai.process.v1.updated 10 | // - google.cloud.visionai.process.v1.deleted 11 | // - google.cloud.visionai.application.v1.created 12 | // - google.cloud.visionai.application.v1.updated 13 | // - google.cloud.visionai.application.v1.deleted 14 | // - google.cloud.visionai.draft.v1.created 15 | // - google.cloud.visionai.draft.v1.updated 16 | // - google.cloud.visionai.draft.v1.deleted 17 | // - google.cloud.visionai.processor.v1.created 18 | // - google.cloud.visionai.processor.v1.updated 19 | // - google.cloud.visionai.processor.v1.deleted 20 | // - google.cloud.visionai.cluster.v1.created 21 | // - google.cloud.visionai.cluster.v1.updated 22 | // - google.cloud.visionai.cluster.v1.deleted 23 | // - google.cloud.visionai.stream.v1.created 24 | // - google.cloud.visionai.stream.v1.updated 25 | // - google.cloud.visionai.stream.v1.deleted 26 | // - google.cloud.visionai.event.v1.created 27 | // - google.cloud.visionai.event.v1.updated 28 | // - google.cloud.visionai.event.v1.deleted 29 | // - google.cloud.visionai.series.v1.created 30 | // - google.cloud.visionai.series.v1.updated 31 | // - google.cloud.visionai.series.v1.deleted 32 | package visionaidata 33 | -------------------------------------------------------------------------------- /cloud/vmmigrationdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package vmmigrationdata provides VM Migration type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.vmmigration.source.v1.created 6 | // - google.cloud.vmmigration.source.v1.updated 7 | // - google.cloud.vmmigration.source.v1.deleted 8 | // - google.cloud.vmmigration.utilizationReport.v1.created 9 | // - google.cloud.vmmigration.utilizationReport.v1.deleted 10 | // - google.cloud.vmmigration.datacenterConnector.v1.created 11 | // - google.cloud.vmmigration.datacenterConnector.v1.deleted 12 | // - google.cloud.vmmigration.migratingVm.v1.created 13 | // - google.cloud.vmmigration.migratingVm.v1.updated 14 | // - google.cloud.vmmigration.migratingVm.v1.deleted 15 | // - google.cloud.vmmigration.cloneJob.v1.created 16 | // - google.cloud.vmmigration.cutoverJob.v1.created 17 | // - google.cloud.vmmigration.group.v1.created 18 | // - google.cloud.vmmigration.group.v1.updated 19 | // - google.cloud.vmmigration.group.v1.deleted 20 | // - google.cloud.vmmigration.targetProject.v1.created 21 | // - google.cloud.vmmigration.targetProject.v1.updated 22 | // - google.cloud.vmmigration.targetProject.v1.deleted 23 | package vmmigrationdata 24 | -------------------------------------------------------------------------------- /cloud/workflowsdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/cloud/workflows/v1/events.proto 20 | 21 | package workflowsdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/cloud/workflowsdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingWorkflowEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "WorkflowEventData", "google/events/cloud/workflows/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := workflowsdata.WorkflowEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := workflowsdata.WorkflowEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /cloud/workflowsdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package workflowsdata provides Workflows type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.cloud.workflows.workflow.v1.created 6 | // - google.cloud.workflows.workflow.v1.deleted 7 | // - google.cloud.workflows.workflow.v1.updated 8 | package workflowsdata 9 | -------------------------------------------------------------------------------- /examples/example_storage_test.go: -------------------------------------------------------------------------------- 1 | package examples 2 | 3 | import ( 4 | "fmt" 5 | "log" 6 | "time" 7 | 8 | "github.com/googleapis/google-cloudevents-go/cloud/storagedata" 9 | "google.golang.org/protobuf/encoding/protojson" 10 | ) 11 | 12 | // cloudEventPayload is initialized with the CloudEvent data payload. 13 | // Source: github.com/googleapis/google-cloudevents/tree/main/examples/binary/storage/StorageObjectData-simple.json 14 | var cloudEventPayload = []byte(` 15 | { 16 | "bucket": "sample-bucket", 17 | "contentType": "text/plain", 18 | "crc32c": "rTVTeQ==", 19 | "etag": "CNHZkbuF/ugCEAE=", 20 | "generation": "1587627537231057", 21 | "id": "sample-bucket/folder/Test.cs/1587627537231057", 22 | "kind": "storage#object", 23 | "md5Hash": "kF8MuJ5+CTJxvyhHS1xzRg==", 24 | "mediaLink": "https://www.googleapis.com/download/storage/v1/b/sample-bucket/o/folder%2FTest.cs?generation=1587627537231057\u0026alt=media", 25 | "metageneration": "1", 26 | "name": "folder/Test.cs", 27 | "selfLink": "https://www.googleapis.com/storage/v1/b/sample-bucket/o/folder/Test.cs", 28 | "size": "352", 29 | "storageClass": "MULTI_REGIONAL", 30 | "timeCreated": "2020-04-23T07:38:57.230Z", 31 | "timeStorageClassUpdated": "2020-04-23T07:38:57.230Z", 32 | "updated": "2020-04-23T07:38:57.230Z" 33 | }`) 34 | 35 | func Example() { 36 | data := storagedata.StorageObjectData{} 37 | 38 | // If you omit `DiscardUnknown`, protojson.Unmarshal returns an error 39 | // when encountering a new or unknown field. 40 | options := protojson.UnmarshalOptions{ 41 | DiscardUnknown: true, 42 | } 43 | if err := options.Unmarshal(cloudEventPayload, &data); err != nil { 44 | log.Fatal("protojson.Unmarshal: ", err) 45 | } 46 | 47 | updated := data.Updated.AsTime().Format(time.UnixDate) 48 | fmt.Printf("Bucket: %s, Object: %s, Updated: %s", data.Bucket, data.Name, updated) 49 | 50 | // Output: Bucket: sample-bucket, Object: folder/Test.cs, Updated: Thu Apr 23 07:38:57 UTC 2020 51 | } 52 | -------------------------------------------------------------------------------- /examples/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/googleapis/google-cloudevents-go/examples 2 | 3 | go 1.20 4 | 5 | replace github.com/googleapis/google-cloudevents-go v0.0.0 => ./.. 6 | 7 | require ( 8 | github.com/googleapis/google-cloudevents-go v0.0.0 9 | google.golang.org/protobuf v1.34.2 10 | ) 11 | -------------------------------------------------------------------------------- /examples/go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 2 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 3 | google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= 4 | google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= 5 | -------------------------------------------------------------------------------- /firebase/analyticsdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/firebase/analytics/v1/events.proto 20 | 21 | package analyticsdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/firebase/analyticsdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingAnalyticsLogData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "AnalyticsLogData", "google/events/firebase/analytics/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := analyticsdata.AnalyticsLogData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := analyticsdata.AnalyticsLogData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /firebase/analyticsdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package analyticsdata provides Google Analytics for Firebase type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.firebase.analytics.log.v1.written 6 | package analyticsdata 7 | -------------------------------------------------------------------------------- /firebase/authdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/firebase/auth/v1/events.proto 20 | 21 | package authdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/firebase/authdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingAuthEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "AuthEventData", "google/events/firebase/auth/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := authdata.AuthEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := authdata.AuthEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /firebase/authdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package authdata provides Firebase Authentication type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.firebase.auth.user.v1.created 6 | // - google.firebase.auth.user.v1.deleted 7 | package authdata 8 | -------------------------------------------------------------------------------- /firebase/databasedata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/firebase/database/v1/events.proto 20 | 21 | package databasedata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/firebase/databasedata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingReferenceEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "ReferenceEventData", "google/events/firebase/database/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := databasedata.ReferenceEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := databasedata.ReferenceEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /firebase/databasedata/doc.go: -------------------------------------------------------------------------------- 1 | // Package databasedata provides Firebase Realtime Database type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.firebase.database.ref.v1.created 6 | // - google.firebase.database.ref.v1.updated 7 | // - google.firebase.database.ref.v1.deleted 8 | // - google.firebase.database.ref.v1.written 9 | package databasedata 10 | -------------------------------------------------------------------------------- /firebase/firebasealertsdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/firebase/firebasealerts/v1/events.proto 20 | 21 | package firebasealertsdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/firebase/firebasealertsdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingAlertData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "AlertData", "google/events/firebase/firebasealerts/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := firebasealertsdata.AlertData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := firebasealertsdata.AlertData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /firebase/firebasealertsdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package firebasealertsdata provides Firebase Alerts type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.firebase.firebasealerts.alerts.v1.published 6 | package firebasealertsdata 7 | -------------------------------------------------------------------------------- /firebase/remoteconfigdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/firebase/remoteconfig/v1/events.proto 20 | 21 | package remoteconfigdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/firebase/remoteconfigdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingRemoteConfigEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "RemoteConfigEventData", "google/events/firebase/remoteconfig/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := remoteconfigdata.RemoteConfigEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := remoteconfigdata.RemoteConfigEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /firebase/remoteconfigdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package remoteconfigdata provides Firebase Remote Config type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.firebase.remoteconfig.remoteConfig.v1.updated 6 | package remoteconfigdata 7 | -------------------------------------------------------------------------------- /firebase/testlabdata/data_test.go: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc v3.21.6 18 | // protoc-gen-go v1.34.2 19 | // source: google/events/firebase/testlab/v1/events.proto 20 | 21 | package testlabdata_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/firebase/testlabdata" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | // Validate the type can parse test data. 34 | // Goals: 35 | // - "Loose" parsing confirms the expected library experience 36 | // - "Strict" parsing confirms: 37 | // - no deleted or renamed fields in protos covered in test data 38 | // - test data does not carry unknown fields 39 | func TestParsingTestMatrixEventData(t *testing.T) { 40 | cases := testhelper.FindTestData(t, "TestMatrixEventData", "google/events/firebase/testlab/v1") 41 | 42 | for name, file := range cases { 43 | t.Run(name, func(t *testing.T) { 44 | data, err := os.ReadFile(file) 45 | if err != nil { 46 | t.Fatal("os.ReadFile:", err) 47 | } 48 | 49 | if ext := filepath.Ext(file); ext != ".json" { 50 | t.Fatalf("test support for %q data not implemented", ext) 51 | } 52 | 53 | t.Run("loose", func(t *testing.T) { 54 | out := testlabdata.TestMatrixEventData{} 55 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 56 | if err := pj.Unmarshal(data, &out); err != nil { 57 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 58 | } 59 | }) 60 | 61 | t.Run("strict", func(t *testing.T) { 62 | out := testlabdata.TestMatrixEventData{} 63 | if err := protojson.Unmarshal(data, &out); err != nil { 64 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 65 | } 66 | }) 67 | 68 | }) 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /firebase/testlabdata/doc.go: -------------------------------------------------------------------------------- 1 | // Package testlabdata provides Firebase Test Lab type definitions for CloudEvent data payloads. 2 | // 3 | // # Supported CloudEvent Types 4 | // 5 | // - google.firebase.testlab.testMatrix.v1.completed 6 | package testlabdata 7 | -------------------------------------------------------------------------------- /generate-code.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2022, 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 | # https://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 | # Generates code from https://github.com/googleapis/google-cloudevents: 17 | # - Types from protobuf messages 18 | # 19 | # Configuration: 20 | # - GENERATE_DATA_SOURCE: Path to google-cloudevent repo. 21 | # - GENERATE_PROTOC_PATH: Path to protobuf tool. 22 | # - GENERATE_TEMPLATE_DIR: Location of gotemplate files for custom code generation. 23 | # 24 | # Usage: 25 | # - sh ./generate-code.sh 26 | # - GENERATE_DATA_SOURCE=tmp/google-cloudevents GENERATE_PROTOC_PATH=protoc sh ./generate-code.sh 27 | 28 | set -e 29 | 30 | # Output Utilities 31 | _heading() { 32 | if [ -t 1 ]; then 33 | echo 34 | echo "$(tput bold)${1}$(tput sgr0)" 35 | else 36 | echo "=> ${1}" 37 | fi 38 | } 39 | 40 | name=$(basename "${BASH_SOURCE[0]}") 41 | library_version=$(git rev-parse --short HEAD) 42 | library_date=$(git show -s --format=%ci "${library_version}") 43 | echo "google-cloudevents-go > ${name} (${library_version} on ${library_date})" 44 | echo "working-directory: ${PWD}" 45 | 46 | # Required configuration. 47 | if [[ -z "${GENERATE_DATA_SOURCE}" ]]; then 48 | echo 49 | echo "Environment variable 'GENERATE_DATE_SOURCE' not found." 50 | echo "Please run 'sh tools/setup-generator.sh' and follow the instructions." 51 | exit 1 52 | fi 53 | 54 | if [[ -z "${GENERATE_PROTOC_PATH}" ]]; then 55 | echo 56 | echo "Environment variable 'GENERATE_PROTOC_PATH' not found." 57 | echo "Please run 'sh tools/setup_generator.sh' and follow the instructions." 58 | exit 1 59 | fi 60 | 61 | if [[ -z "${GENERATE_TEMPLATE_DIR}" ]]; then 62 | export GENERATE_TEMPLATE_DIR=$(realpath ./generators/templates) 63 | fi 64 | 65 | GENERATE_DATA_SOURCE=$(realpath "${GENERATE_DATA_SOURCE}") 66 | 67 | # Derive proto repo metadata. 68 | data_version=$(git -C "${GENERATE_DATA_SOURCE}" rev-parse --short HEAD) 69 | data_date=$(git -C "${GENERATE_DATA_SOURCE}" show -s --format=%ci "${data_version}") 70 | # Derive proto lookup paths. 71 | src_dir="${GENERATE_DATA_SOURCE}/proto/google/events" 72 | googleapis_dir="${GENERATE_DATA_SOURCE}/third_party/googleapis" 73 | 74 | _heading "Preparing to generate library..." 75 | echo "- Schema Source Repository: \t${GENERATE_DATA_SOURCE} (${data_version} on ${data_date})" 76 | echo "- Proto Source Directory: \t${src_dir}" 77 | echo "- Shared googleapis Protos: \t${googleapis_dir}" 78 | echo "- Custom Code Generator Templates: \t${GENERATE_TEMPLATE_DIR}" 79 | 80 | # Manifest file with details about how code was most recently generated. 81 | # Useful when troubleshooting without build logs. 82 | cat > generated.txt < ${code_dest}data${version}" 130 | 131 | $GENERATE_PROTOC_PATH --go_out=. \ 132 | --go_opt="M${proto_src}"="${code_dest}data${version};${product}data${version}" \ 133 | --proto_path="${src_dir}" \ 134 | --proto_path="${googleapis_dir}" \ 135 | "${proto_src}" 136 | } 137 | 138 | _generateValidationTests() { 139 | # Source the schema protos. 140 | proto_dir="${GENERATE_DATA_SOURCE}/proto" 141 | proto_src=$(realpath --relative-to="${proto_dir}" "$1") 142 | # Derive path to data.proto from event.proto. 143 | # This is consistently available but not currently a standard. 144 | data_src=$(dirname "${proto_src}")/data.proto 145 | # Derive destination directory. 146 | code_dest=$(dirname "$(dirname "${proto_src}")" | cut -d'/' -f3-) 147 | # Product name & API version 148 | product=$(basename "$code_dest") 149 | version=$(basename "$(dirname "${proto_src}")") 150 | 151 | # Explicit type versioning after v1. 152 | if [[ "${version}" == "v1" ]]; then 153 | version="" 154 | fi 155 | 156 | # Skip unsupported products. 157 | if [[ "${product}" == "pubsub" ]]; then 158 | echo "- ${product}: skipping generation, not currently supported" 159 | return 160 | fi 161 | 162 | $GENERATE_PROTOC_PATH --go-googlecetypes_out=. \ 163 | --go-googlecetypes_opt="Mgoogle/events/cloudevent.proto"="github.com/googleapis/google-cloudevents-go/thirdparty/cloudevents;cloudevents" \ 164 | --go-googlecetypes_opt="M${proto_src}"="${code_dest}data${version}" \ 165 | --go-googlecetypes_opt="M${data_src}"="${code_dest}data${version};${product}data${version}" \ 166 | --proto_path="${proto_dir}" \ 167 | --proto_path="${googleapis_dir}" \ 168 | "${proto_src}" 169 | } 170 | 171 | _heading "Generating data type code in Go..." 172 | for i in $(find "${GENERATE_DATA_SOURCE}/proto" -type f -name data.proto); do 173 | _generateData "$i" 174 | done 175 | 176 | _heading "Generating validation tests and godoc..." 177 | for i in $(find "${GENERATE_DATA_SOURCE}/proto" -type f -name events.proto); do 178 | _generateValidationTests "$i" 179 | done 180 | 181 | _heading "Running validation tests..." 182 | # Run with GOFLAGS="-v" for verbose output. 183 | go test ./... 184 | -------------------------------------------------------------------------------- /generators/protoc-gen-go-googlecetypes/go.mod: -------------------------------------------------------------------------------- 1 | module github.com/googleapis/google-cloudevents-go/generators/protoc-gen-go-googlecetypes 2 | 3 | go 1.22 4 | 5 | toolchain go1.23.8 6 | 7 | require google.golang.org/protobuf v1.36.6 8 | -------------------------------------------------------------------------------- /generators/protoc-gen-go-googlecetypes/go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU= 2 | golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4= 3 | google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= 4 | google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= 5 | google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= 6 | google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= 7 | google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= 8 | google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= 9 | -------------------------------------------------------------------------------- /generators/templates/validationtest.gotpl: -------------------------------------------------------------------------------- 1 | // Copyright 2023 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 | // Code generated by protoc-gen-go-googlecetypes. DO NOT EDIT. 16 | // versions: 17 | // protoc {{ .ProtocVersion }} 18 | // protoc-gen-go {{ .ProtocGenGoVersion }} 19 | // source: {{ .SourceFile }} 20 | 21 | package {{ .Pkg }}_test 22 | 23 | import ( 24 | "os" 25 | "path/filepath" 26 | "testing" 27 | 28 | "github.com/googleapis/google-cloudevents-go/{{ .SrcPath }}" 29 | "github.com/googleapis/google-cloudevents-go/internal/testhelper" 30 | "google.golang.org/protobuf/encoding/protojson" 31 | ) 32 | 33 | {{ range .DataTypes }} 34 | // Validate the type can parse test data. 35 | // Goals: 36 | // - "Loose" parsing confirms the expected library experience 37 | // - "Strict" parsing confirms: 38 | // - no deleted or renamed fields in protos covered in test data 39 | // - test data does not carry unknown fields 40 | func TestParsing{{ . }}(t *testing.T) { 41 | cases := testhelper.FindTestData(t, "{{ . }}", "{{ $.TestDataPath }}") 42 | 43 | for name, file := range cases { 44 | t.Run(name, func(t *testing.T) { 45 | data, err := os.ReadFile(file) 46 | if err != nil { 47 | t.Fatal("os.ReadFile:", err) 48 | } 49 | 50 | if ext := filepath.Ext(file); ext != ".json" { 51 | t.Fatalf("test support for %q data not implemented", ext) 52 | } 53 | 54 | t.Run("loose", func(t *testing.T) { 55 | out := {{ $.Pkg }}.{{ . }}{} 56 | pj := protojson.UnmarshalOptions{DiscardUnknown: true} 57 | if err := pj.Unmarshal(data, &out); err != nil { 58 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 59 | } 60 | }) 61 | 62 | t.Run("strict", func(t *testing.T) { 63 | {{ if (index $.PrepareFunction . ) -}} 64 | t.Skip("Data is not compatible with strict processing.") 65 | {{ else -}} 66 | out := {{ $.Pkg }}.{{ . }}{} 67 | if err := protojson.Unmarshal(data, &out); err != nil { 68 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 69 | } 70 | {{ end -}} 71 | }) 72 | 73 | {{ if (index $.PrepareFunction . ) }} 74 | t.Run("compatibility", func(t *testing.T) { 75 | cleanData, err := {{ index $.PrepareFunction . }}(data) 76 | if err != nil { 77 | t.Errorf("could not prepare data for strict validation: %v", err) 78 | } 79 | 80 | out := {{ $.Pkg }}.{{ . }}{} 81 | if err := protojson.Unmarshal(cleanData, &out); err != nil { 82 | t.Fatalf("protojson.Unmarshal: could not parse %q\n----%s\n----", file, data) 83 | } 84 | }) 85 | {{ end -}} 86 | }) 87 | } 88 | } 89 | {{ end }} 90 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/googleapis/google-cloudevents-go 2 | 3 | go 1.23.0 4 | 5 | require ( 6 | google.golang.org/genproto v0.0.0-20250324211829-b45e905df463 7 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 8 | google.golang.org/protobuf v1.36.6 9 | ) 10 | -------------------------------------------------------------------------------- /go.sum: -------------------------------------------------------------------------------- 1 | github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= 2 | github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= 3 | google.golang.org/genproto v0.0.0-20250324211829-b45e905df463 h1:qEFnJI6AnfZk0NNe8YTyXQh5i//Zxi4gBHwRgp76qpw= 4 | google.golang.org/genproto v0.0.0-20250324211829-b45e905df463/go.mod h1:SqIx1NV9hcvqdLHo7uNZDS5lrUJybQ3evo3+z/WBfA0= 5 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463 h1:e0AIkUUhxyBKh6ssZNrAMeqhA7RKUj42346d1y02i2g= 6 | google.golang.org/genproto/googleapis/rpc v0.0.0-20250324211829-b45e905df463/go.mod h1:qQ0YXyHHx3XkvlzUtpXDkS29lDSafHMZBAZDc03LQ3A= 7 | google.golang.org/protobuf v1.36.6 h1:z1NpPI8ku2WgiWnf+t9wTPsn6eP1L7ksHUlkfLvd9xY= 8 | google.golang.org/protobuf v1.36.6/go.mod h1:jduwjTPXsFjZGTmRluh+L6NjiWu7pchiJ2/5YcXBHnY= 9 | -------------------------------------------------------------------------------- /internal/testhelper/prepare.go: -------------------------------------------------------------------------------- 1 | package testhelper 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | ) 7 | 8 | // PreparePubSubMessagePublishedData modifies data for protojson parsing. 9 | // - Remove fields protojson considers duplicate field names 10 | // - Remove @type properties 11 | func PreparePubSubMessagePublishedData(b []byte) ([]byte, error) { 12 | var j map[string]interface{} 13 | if err := json.Unmarshal(b, &j); err != nil { 14 | return nil, fmt.Errorf("json.Unmarshal: %w", err) 15 | } 16 | m := j["message"].(map[string]interface{}) 17 | 18 | // Remove reserved @type field. 19 | delete(m, "@type") 20 | // Remove message_id field name conflict with messageId. 21 | delete(m, "message_id") 22 | // Remove publish_time field name conflict with publishTime. 23 | delete(m, "publish_time") 24 | 25 | j["message"] = m 26 | return json.Marshal(j) 27 | } 28 | 29 | // PrepareAuditLogEntryData modifies data for protojson parsing. 30 | // - Remove @type properties 31 | func PrepareAuditLogEntryData(b []byte) ([]byte, error) { 32 | var j map[string]interface{} 33 | if err := json.Unmarshal(b, &j); err != nil { 34 | return nil, fmt.Errorf("json.Unmarshal: %w", err) 35 | } 36 | m := j["protoPayload"].(map[string]interface{}) 37 | 38 | // Remove reserved @type field. 39 | delete(m, "@type") 40 | 41 | j["protoPayload"] = m 42 | return json.Marshal(j) 43 | } 44 | -------------------------------------------------------------------------------- /internal/testhelper/testhelper.go: -------------------------------------------------------------------------------- 1 | package testhelper 2 | 3 | import ( 4 | "os" 5 | "path/filepath" 6 | "strings" 7 | "testing" 8 | ) 9 | 10 | type dataTestCase struct { 11 | // Ext is the test data file extension, used to inform data format. 12 | Ext string 13 | // Type is the CloudEvent data type inferred from the testdata filename. 14 | Type string 15 | // Case is the testing use case inferred from the testdata filename. 16 | Case string 17 | } 18 | 19 | // FindTestData identifies and loads relevant test cases for a given data type. 20 | func FindTestData(t *testing.T, dataType string, dataPath string) map[string]string { 21 | t.Helper() 22 | root := os.Getenv("GENERATE_DATA_SOURCE") 23 | if root == "" { 24 | t.Fatal("test data: GENERATE_DATA_SOURCE environment variable not set") 25 | } 26 | 27 | _, err := os.Stat(root) 28 | if err != nil { 29 | t.Fatal("test data: GENERATE_DATA_SOURCE environment variable not set to an existing base path.\nSet this variable to the local path of the google-cloudevents repository.") 30 | } 31 | 32 | if !filepath.IsAbs(root) { 33 | t.Fatal("test data: GENERATE_DATA_SOURCE environment variable not an absolute path") 34 | } 35 | 36 | testData := filepath.Join(root, "testdata", dataPath) 37 | files, err := os.ReadDir(testData) 38 | if err != nil { 39 | t.Skip("No test cases found: os.ReadDir:", err) 40 | } 41 | 42 | cases := make(map[string]string, len(files)) 43 | for _, file := range files { 44 | c := dataTestCase{ 45 | Ext: filepath.Ext(file.Name()), 46 | } 47 | if c.Ext != ".json" && c.Ext != ".proto" { 48 | continue 49 | } 50 | 51 | var ok bool 52 | c.Type, c.Case, ok = strings.Cut(strings.TrimSuffix(file.Name(), c.Ext), "-") 53 | if !ok { 54 | c.Case = "default" 55 | } 56 | 57 | if c.Type == dataType { 58 | cases[c.Case] = filepath.Join(testData, file.Name()) 59 | } 60 | } 61 | 62 | if len(cases) == 0 { 63 | t.Skip("No test cases found for", dataType) 64 | } 65 | 66 | return cases 67 | } 68 | -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "config:base" 4 | ], 5 | "schedule": ["on the first day of the month"], 6 | "constraints": { 7 | "go": "1.23" 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /tools/setup-generator.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # Copyright 2022, 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 | # https://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 | # Setup environment for code generation: 17 | # - install protobuf tools in a local temp directory 18 | # - clone google-cloudevents repo if needed 19 | set -e 20 | 21 | name=$(basename ${BASH_SOURCE:-$0}) 22 | library_version=$(git rev-parse --short HEAD) 23 | library_date=$(git show -s --format=%ci "${library_version}") 24 | echo "google-cloudevents-go > ${name} (${library_version} on ${library_date})" 25 | echo "working-directory: ${PWD}" 26 | echo 27 | 28 | if [ "${GENERATE_DATA_SOURCE:0:3}" = "tmp" ] || [ "${GENERATE_DATA_SOURCE:0:5}" = "./tmp" ]; then 29 | if [ -d "${GENERATE_DATA_SOURCE}" ]; then 30 | echo "setup-generator.sh will delete all contents of ./tmp. Currently GENERATE_DATA_SOURCE='${GENERATE_DATA_SOURCE}'." 31 | exit 2 32 | fi 33 | fi 34 | 35 | # Create a location for local tool installation. 36 | echo "- Removing existing tmp/ directory" 37 | rm -rf tmp 38 | mkdir tmp 39 | 40 | # Protobuf Setup 41 | PROTOBUF_VERSION=21.6 42 | # protoc is a native application, so we need to download different zip files 43 | # and use different binaries depending on the OS. 44 | echo "- Determining OS type" 45 | case "$OSTYPE" in 46 | linux*) 47 | PROTOBUF_PLATFORM=linux-x86_64 48 | PROTOC=tmp/protobuf/bin/protoc 49 | ;; 50 | win* | msys* | cygwin*) 51 | PROTOBUF_PLATFORM=win64 52 | PROTOC=tmp/protobuf/bin/protoc.exe 53 | ;; 54 | darwin*) 55 | PROTOBUF_PLATFORM=osx-x86_64 56 | PROTOC=tmp/protobuf/bin/protoc 57 | ;; 58 | *) 59 | echo "Unknown OSTYPE: $OSTYPE" 60 | exit 1 61 | esac 62 | 63 | # We download a specific version rather than using package managers 64 | # for portability and being able to rely on the version being available 65 | # as soon as it's released on GitHub. 66 | echo "- Downloading protobuf tools..." 67 | pushd tmp 1>/dev/null 68 | curl -sSL \ 69 | https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOBUF_VERSION/protoc-$PROTOBUF_VERSION-$PROTOBUF_PLATFORM.zip \ 70 | --output protobuf.zip 71 | (mkdir protobuf && cd protobuf && unzip -q ../protobuf.zip) 72 | popd 1>/dev/null 73 | chmod +x $PROTOC 74 | 75 | echo "- Downloaded protobuf ${PROTOBUF_VERSION} for ${PROTOBUF_PLATFORM}" 76 | 77 | echo "- Downloading & installing the Go protocol buffers plugin..." 78 | go install google.golang.org/protobuf/cmd/protoc-gen-go@latest 79 | echo "- Protobuf tooling installation complete" 80 | 81 | echo "- Installing custom generators" 82 | pushd generators/protoc-gen-go-googlecetypes 1>/dev/null 83 | go install . 84 | popd 1>/dev/null 85 | 86 | if [[ -z "${GENERATE_DATA_SOURCE}" ]]; then 87 | echo "- Cloning github.com/googleapis/google-cloudevents into tmp" 88 | # For the moment, just clone google-cloudevents. Later we might make 89 | # it a submodule. We clone quietly, and only with a depth of 1 90 | # as we don't need history. 91 | dest='tmp/google-cloudevents' 92 | git clone https://github.com/googleapis/google-cloudevents "${dest}" -q --depth 1 93 | else 94 | echo "- Skipping new clone of github.com/googleapis/google-cloudevents, GENERATE_DATA_SOURCE variable already set" 95 | fi 96 | 97 | echo 98 | echo "Configure environment for generate_code.sh:" 99 | echo "- Usage: Configure the path to protobuf tools ('export GENERATE_PROTOC_PATH=$PROTOC')" 100 | if [[ -z "${GENERATE_DATA_SOURCE}" ]]; then 101 | echo "- Usage: Configure the path to proto definitions ('export GENERATE_DATA_SOURCE=\"\$PWD/${dest}\")" 102 | fi 103 | 104 | echo 105 | echo "You are ready to run 'sh generate-code.sh'" 106 | --------------------------------------------------------------------------------