├── .commitlintrc ├── .editorconfig ├── .github ├── CODEOWNERS ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── dependabot.yaml └── workflows │ ├── auto-merge.yaml │ ├── policy.yaml │ └── test.yaml ├── .gitignore ├── .markdownlint.jsonc ├── .yamlfmt ├── .yamllint ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── api_contact_groups.go ├── api_heartbeat.go ├── api_locations.go ├── api_maintenance_windows_.go ├── api_pagespeed.go ├── api_ssl.go ├── api_uptime.go ├── backoff ├── backoff_test.go ├── constant.go ├── exponential.go ├── jitter.go └── linear.go ├── client.go ├── credentials ├── basic.go ├── bearer.go └── credentials_test.go ├── error.go ├── error_test.go ├── examples ├── contact-groups │ └── main.go ├── heartbeat │ └── main.go ├── locations │ └── main.go ├── maintenance-windows │ └── main.go ├── pagespeed │ └── main.go ├── ssl │ └── main.go └── uptime │ └── main.go ├── go.mod ├── model_api_response.go ├── model_api_response_data.go ├── model_contact_group.go ├── model_contact_group_response.go ├── model_contact_groups.go ├── model_heartbeat_test_.go ├── model_heartbeat_test_overview.go ├── model_heartbeat_test_response.go ├── model_heartbeat_test_status.go ├── model_heartbeat_tests.go ├── model_links.go ├── model_maintenance_window.go ├── model_maintenance_window_repeat_interval.go ├── model_maintenance_window_response.go ├── model_maintenance_window_state.go ├── model_maintenance_windows_.go ├── model_monitoring_location.go ├── model_monitoring_location_status.go ├── model_monitoring_locations.go ├── model_pagespeed_test_.go ├── model_pagespeed_test_check_rate.go ├── model_pagespeed_test_history.go ├── model_pagespeed_test_history_result.go ├── model_pagespeed_test_region.go ├── model_pagespeed_test_response.go ├── model_pagespeed_test_stats.go ├── model_pagespeed_test_throttling.go ├── model_pagespeed_tests.go ├── model_pagination.go ├── model_ssl_test_.go ├── model_ssl_test_check_rate.go ├── model_ssl_test_flags.go ├── model_ssl_test_mixed_content.go ├── model_ssl_test_response.go ├── model_ssl_tests.go ├── model_uptime_test_.go ├── model_uptime_test_alert.go ├── model_uptime_test_alerts.go ├── model_uptime_test_check_rate.go ├── model_uptime_test_history.go ├── model_uptime_test_history_result.go ├── model_uptime_test_overview.go ├── model_uptime_test_period.go ├── model_uptime_test_periods.go ├── model_uptime_test_processing_state.go ├── model_uptime_test_response.go ├── model_uptime_test_status.go ├── model_uptime_test_type.go ├── model_uptime_tests.go ├── options.go ├── throttle ├── group.go ├── throttle_test.go └── transport.go └── utils.go /.commitlintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": [ 3 | "@commitlint/config-conventional", 4 | ], 5 | "rules": { 6 | "body-max-line-length": [2, "always", 72], 7 | "header-max-length": [2, "always", 50], 8 | }, 9 | } 10 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig helps developers define and maintain consistent 2 | # coding styles between different editors and IDEs 3 | # editorconfig.org 4 | 5 | root = true 6 | 7 | [*] 8 | end_of_line = lf 9 | charset = utf-8 10 | trim_trailing_whitespace = true 11 | insert_final_newline = true 12 | indent_style = space 13 | indent_size = 2 14 | 15 | [*.{go,mod}] 16 | indent_style = tab 17 | 18 | [*.{diff,md}] 19 | trim_trailing_whitespace = false 20 | 21 | [{GNU,}Makefile] 22 | indent_style = tab 23 | -------------------------------------------------------------------------------- /.github/CODEOWNERS: -------------------------------------------------------------------------------- 1 | # These owners will be the default owners for everything in the repo. Unless a 2 | # later match takes precedence, these owner(s) will be requested for review 3 | # when someone opens a pull request. 4 | * @StatusCakeDev/developers 5 | 6 | # Order is important; the last matching pattern takes the most precedence. When 7 | # someone opens a pull request that only modifies the following paths, only 8 | # these owner(s) and not the global owner(s) will be requested for a review. 9 | .github/ @StatusCakeDev/operations 10 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: 'bug' 6 | assignees: '' 7 | --- 8 | 9 | **Describe the bug** 10 | A clear and concise description of what the bug is. 11 | 12 | **To Reproduce** 13 | Steps to reproduce the behaviour: 14 | 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behaviour** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | 28 | - OS: [e.g. iOS] 29 | - Browser [e.g. chrome, safari] 30 | - Version [e.g. 22] 31 | 32 | **Smartphone (please complete the following information):** 33 | 34 | - Device: [e.g. iPhone6] 35 | - OS: [e.g. iOS8.1] 36 | - Browser [e.g. stock browser, safari] 37 | - Version [e.g. 22] 38 | 39 | **Additional context** 40 | Add any other context about the problem here. 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | A clear and concise description of what the problem is. Ex. I'm always 11 | frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've 18 | considered. 19 | 20 | **Additional context** 21 | Add any other context or screenshots about the feature request here. 22 | -------------------------------------------------------------------------------- /.github/dependabot.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | version: 2 3 | updates: 4 | - package-ecosystem: github-actions 5 | directory: / 6 | schedule: 7 | interval: weekly 8 | commit-message: 9 | prefix: ci(deps) 10 | -------------------------------------------------------------------------------- /.github/workflows/auto-merge.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: auto-merge 3 | on: 4 | pull_request: 5 | permissions: 6 | contents: write 7 | pull-requests: write 8 | jobs: 9 | check-can-auto-merge: 10 | if: github.triggering_actor == 'dependabot[bot]' 11 | name: Check if PR can be auto-merged 12 | runs-on: ubuntu-latest 13 | outputs: 14 | can-auto-merge: ${{ steps.can-auto-merge.outputs.approve }} 15 | steps: 16 | - uses: dependabot/fetch-metadata@v2.4.0 17 | id: dependabot-metadata 18 | with: 19 | github-token: ${{ secrets.GITHUB_TOKEN }} 20 | - if: | 21 | steps.dependabot-metadata.outputs.update-type == 'version-update:semver-patch' || 22 | steps.dependabot-metadata.outputs.package-ecosystem == 'github_actions' 23 | id: can-auto-merge 24 | run: echo "approve=true" >> $GITHUB_OUTPUT 25 | auto-merge: 26 | needs: check-can-auto-merge 27 | if: needs.check-can-auto-merge.outputs.can-auto-merge == 'true' 28 | name: Auto merge pull requests 29 | runs-on: ubuntu-latest 30 | steps: 31 | - uses: dependabot/fetch-metadata@v2.4.0 32 | id: dependabot-metadata 33 | with: 34 | github-token: ${{ secrets.GITHUB_TOKEN }} 35 | - name: Approve Dependabot PR 36 | run: gh pr review --approve "${PR_URL}" 37 | env: 38 | PR_URL: ${{ github.event.pull_request.html_url }} 39 | # Because we enforce PRs be approved by a code owner, a token from the 40 | # operations team must be used to approve the PR. This token is from the 41 | # StatusCake machine account which has been given membership to the 42 | # operations team. 43 | GITHUB_TOKEN: ${{ secrets.MACHINE_TOKEN }} 44 | - name: Enable auto-merge for Dependabot PR 45 | run: gh pr merge --auto --merge "${PR_URL}" 46 | env: 47 | PR_URL: ${{ github.event.pull_request.html_url }} 48 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 49 | -------------------------------------------------------------------------------- /.github/workflows/policy.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: policy 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | # This is run on merge queue branches as there are jobs listed in this 8 | # action that are often required in branch protection rules. Due to guards 9 | # below certain jobs may not run in merge queue branches but will still 10 | # return a status indicating a pass. 11 | - gh-readonly-queue/** 12 | - master 13 | jobs: 14 | check-merge-commits: 15 | if: github.event_name == 'pull_request' 16 | name: Check merge commits 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v4 20 | with: 21 | fetch-depth: 0 22 | - run: | 23 | git config --global --add safe.directory /github/workspace 24 | merge_commits=$(git rev-list --merges "origin/$GITHUB_BASE_REF".."origin/$GITHUB_HEAD_REF") 25 | if [ -n "$merge_commits" ]; then 26 | echo "Error: merge commits found in $GITHUB_BASE_REF..$GITHUB_HEAD_REF" 27 | for merge_commit in $merge_commits; do 28 | echo "$merge_commit" 29 | done 30 | exit 1 31 | fi 32 | commit-message-style: 33 | if: github.event_name == 'pull_request' && github.triggering_actor != 'dependabot[bot]' 34 | name: Check commit message style 35 | runs-on: ubuntu-latest 36 | steps: 37 | - uses: actions/checkout@v4 38 | with: 39 | fetch-depth: 0 40 | - uses: actions/setup-node@v4 41 | with: 42 | node-version: 19.x 43 | - name: Install base config 44 | run: npm install @commitlint/config-conventional 45 | - name: Validate commit messages 46 | run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to HEAD --verbose 47 | markdown-style: 48 | name: Check markdown style 49 | runs-on: ubuntu-latest 50 | steps: 51 | - uses: actions/checkout@v4 52 | with: 53 | fetch-depth: 0 54 | - uses: actions/setup-node@v4 55 | with: 56 | node-version: 19.x 57 | - name: Validate markdown 58 | run: npx markdownlint-cli2 **/*.md 59 | yaml-style: 60 | name: Check YAML style 61 | runs-on: ubuntu-latest 62 | steps: 63 | - uses: actions/checkout@v4 64 | - uses: actions/setup-python@v5 65 | with: 66 | python-version: "3.10" 67 | - name: Install yamllint 68 | run: pip install --user yamllint 69 | - name: Validate YAML 70 | run: yamllint . 71 | -------------------------------------------------------------------------------- /.github/workflows/test.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | name: test 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - gh-readonly-queue/** 8 | - master 9 | jobs: 10 | test: 11 | name: Run tests 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | go: 16 | - "1.22" 17 | - "1.21" 18 | - "1.20" 19 | steps: 20 | - uses: actions/checkout@v4 21 | - uses: actions/setup-go@v5 22 | with: 23 | go-version: ${{ matrix.go }} 24 | - run: go test -v ./... 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Binaries for programs and plugins 2 | *.exe 3 | *.exe~ 4 | *.dll 5 | *.so 6 | *.dylib 7 | 8 | # Test binary, built with `go test -c` 9 | *.test 10 | 11 | # Output of the go coverage tool, specifically when used with LiteIDE 12 | *.out 13 | -------------------------------------------------------------------------------- /.markdownlint.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | "default": true, 3 | "line-length": { 4 | "tables": false 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /.yamlfmt: -------------------------------------------------------------------------------- 1 | # vi: ft=yaml 2 | --- 3 | formatter: 4 | type: basic 5 | # There is a "bug" with the behaviour of this option that will move file head 6 | # comments below the initial document start. For example front matter is 7 | # rearraged and therefore misplaced in the file. This behaviour prevents 8 | # `ymalfmt` from being run in CI or automatically in code editors. 9 | include_document_start: true 10 | indentless_arrays: true 11 | pad_line_comments: 2 12 | # There is missing functionality in `yamlfmt` to remove redundantly quoted 13 | # strings from YAML documents, and prefer the use of double quotes (or 14 | # whatever is configured). This means further manual effort is required to 15 | # correct files. 16 | -------------------------------------------------------------------------------- /.yamllint: -------------------------------------------------------------------------------- 1 | # vi: ft=yaml 2 | --- 3 | extends: default 4 | rules: 5 | document-start: 6 | level: error 7 | indentation: 8 | indent-sequences: false 9 | spaces: 2 10 | line-length: false 11 | quoted-strings: 12 | quote-type: double 13 | required: only-when-needed 14 | truthy: disable 15 | -------------------------------------------------------------------------------- /CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Covenant Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as 6 | contributors and maintainers pledge to making participation in our project and 7 | our community a harassment-free experience for everyone, regardless of age, body 8 | size, disability, ethnicity, gender identity and expression, level of 9 | experience, nationality, personal appearance, race, religion, or sexual identity 10 | and orientation. 11 | 12 | ## Our Standards 13 | 14 | Examples of behaviour that contributes to creating a positive environment 15 | include: 16 | 17 | - Using welcoming and inclusive language 18 | - Being respectful of differing viewpoints and experiences 19 | - Gracefully accepting constructive criticism 20 | - Focusing on what is best for the community 21 | - Showing empathy towards other community members 22 | 23 | Examples of unacceptable behaviour by participants include: 24 | 25 | - The use of sexualized language or imagery and unwelcome sexual attention or 26 | advances 27 | - Trolling, insulting/derogatory comments, and personal or political attacks 28 | - Public or private harassment 29 | - Publishing others' private information, such as a physical or electronic 30 | address, without explicit permission 31 | - Other conduct which could reasonably be considered inappropriate in a 32 | professional setting 33 | 34 | ## Our Responsibilities 35 | 36 | Project maintainers are responsible for clarifying the standards of acceptable 37 | behaviour and are expected to take appropriate and fair corrective action in 38 | response to any instances of unacceptable behaviour. 39 | 40 | Project maintainers have the right and responsibility to remove, edit, or reject 41 | comments, commits, code, wiki edits, issues, and other contributions that are 42 | not aligned to this Code of Conduct, or to ban temporarily or permanently any 43 | contributor for other behaviours that they deem inappropriate, threatening, 44 | offensive, or harmful. 45 | 46 | ## Scope 47 | 48 | This Code of Conduct applies both within project spaces and in public spaces 49 | when an individual is representing the project or its community. Examples of 50 | representing a project or community include using an official project e-mail 51 | address, posting via an official social media account, or acting as an appointed 52 | representative at an online or offline event. Representation of a project may be 53 | further defined and clarified by project maintainers. 54 | 55 | ## Enforcement 56 | 57 | Instances of abusive, harassing, or otherwise unacceptable behaviour may be 58 | reported by contacting the [project team](mailto:support@statuscake.com). All 59 | complaints will be reviewed and investigated and will result in a response that 60 | is deemed necessary and appropriate to the circumstances. The project team is 61 | obligated to maintain confidentiality with regard to the reporter of an 62 | incident. Further details of specific enforcement policies may be posted 63 | separately. 64 | 65 | Project maintainers who do not follow or enforce the Code of Conduct in good 66 | faith may face temporary or permanent repercussions as determined by other 67 | members of the project's leadership. 68 | 69 | ## Attribution 70 | 71 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], 72 | version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 73 | 74 | [homepage]: http://contributor-covenant.org 75 | [version]: http://contributor-covenant.org/version/1/4/ 76 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How To Contribute 2 | 3 | Contributions are welcome as we strive to make this module as useful as possible 4 | for everyone. However time is not always on our side, and changes may not be 5 | reviewed or merged in a timely manner. 6 | 7 | If this module is found to be missing in functionality, please open an issue 8 | describing the proposed change - discussing changes ahead of time reduces 9 | friction within pull requests. 10 | 11 | ## Prerequisites 12 | 13 | You will need the following things properly installed on your computer: 14 | 15 | - [Git](https://git-scm.com/) 16 | - [Go](https://go.dev/) (1.13+) 17 | 18 | ## Installation 19 | 20 | - `git clone ` this repository 21 | - `cd statuscake-go` 22 | 23 | ## Running tests 24 | 25 | - `go test ./...` 26 | 27 | ## Making Changes 28 | 29 | See the contributing guide at 30 | [devhandbook.org](https://devhandbook.org/contributing) 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2021 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # statuscake-go ![test](https://github.com/StatusCakeDev/statuscake-go/workflows/test/badge.svg) 2 | 3 | The [Go](https://golang.org/) implementation of the [StatusCake 4 | API](https://www.statuscake.com/api/v1) client. Documentation for this library 5 | can be found [here](https://www.statuscake.com/api/v1). 6 | 7 | ## Prerequisites 8 | 9 | You will need the following things properly installed on your computer: 10 | 11 | - [Go](https://golang.org/): any one of the **three latest major** 12 | [releases](https://golang.org/doc/devel/release.html) 13 | 14 | ## Installation 15 | 16 | With [Go module](https://github.com/golang/go/wiki/Modules) support (Go 1.11+), 17 | add the following import 18 | 19 | ```go 20 | import "github.com/StatusCakeDev/statuscake-go" 21 | ``` 22 | 23 | to your code, and then `go [build|run|test]` will automatically fetch the 24 | necessary dependencies. 25 | 26 | Otherwise, to install the `statuscake-go` package, run the following command: 27 | 28 | ```bash 29 | go get -u github.com/StatusCakeDev/statuscake-go 30 | ``` 31 | 32 | ## Usage 33 | 34 | Within any Go file instantiate an API client and execute a request: 35 | 36 | ```go 37 | package main 38 | 39 | import ( 40 | "context" 41 | "fmt" 42 | 43 | "github.com/StatusCakeDev/statuscake-go" 44 | "github.com/StatusCakeDev/statuscake-go/credentials" 45 | ) 46 | 47 | func main() { 48 | bearer := credentials.NewBearerWithStaticToken(apiToken) 49 | client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer)) 50 | 51 | tests, err := client.ListUptimeTests(context.Background()).Execute() 52 | if err != nil { 53 | panic(err) 54 | } 55 | 56 | fmt.Printf("%+v\n", tests.Data) 57 | } 58 | ``` 59 | 60 | ## License 61 | 62 | This project is licensed under the [MIT License](LICENSE). 63 | -------------------------------------------------------------------------------- /backoff/backoff_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package backoff_test 31 | 32 | import ( 33 | "testing" 34 | "time" 35 | 36 | "github.com/StatusCakeDev/statuscake-go/backoff" 37 | ) 38 | 39 | func TestConstant(t *testing.T) { 40 | t.Run("returns a constant duration", func(t *testing.T) { 41 | b := backoff.Constant{ 42 | BaseDelay: 6.0 * time.Second, 43 | } 44 | 45 | retries := 5 46 | 47 | expected := b.BaseDelay 48 | got := b.Backoff(retries) 49 | 50 | if expected != got { 51 | t.Errorf("expected: %s, got: %s", expected, got) 52 | } 53 | }) 54 | } 55 | 56 | func TestExponential(t *testing.T) { 57 | b := backoff.Exponential{ 58 | BaseDelay: 1.0 * time.Second, 59 | Multiplier: 2.0, // Exponential factor. 60 | Jitter: 0, // To make test predictible. 61 | MaxDelay: 120 * time.Second, 62 | } 63 | 64 | tests := []struct { 65 | name string 66 | idx int 67 | expected time.Duration 68 | }{ 69 | { 70 | name: "returns the base delay for the initial index", 71 | idx: 0, 72 | expected: b.BaseDelay, 73 | }, 74 | { 75 | name: "returns the next duration in an exponential sequence", 76 | idx: 5, 77 | expected: time.Duration(32 * time.Second), 78 | }, 79 | { 80 | name: "returns the maximum delay when the calculated backoff exceeds the maximum", 81 | idx: 7, 82 | expected: b.MaxDelay, 83 | }, 84 | } 85 | for _, tt := range tests { 86 | t.Run(tt.name, func(t *testing.T) { 87 | got := b.Backoff(tt.idx) 88 | if tt.expected != got { 89 | t.Errorf("expected: %s, got: %s", tt.expected, got) 90 | } 91 | }) 92 | } 93 | } 94 | 95 | func TestLinear(t *testing.T) { 96 | b := backoff.Linear{ 97 | BaseDelay: 1.0 * time.Second, 98 | Jitter: 0, // To make test predictible. 99 | MaxDelay: 120 * time.Second, 100 | } 101 | 102 | tests := []struct { 103 | name string 104 | idx int 105 | expected time.Duration 106 | }{ 107 | { 108 | name: "returns the base delay for the initial index", 109 | idx: 0, 110 | expected: b.BaseDelay, 111 | }, 112 | { 113 | name: "returns the next duration in a linear sequence", 114 | idx: 5, 115 | expected: time.Duration(6 * time.Second), 116 | }, 117 | { 118 | name: "returns the maximum delay when the calculated backoff exceeds the maximum", 119 | idx: 120, 120 | expected: b.MaxDelay, 121 | }, 122 | } 123 | for _, tt := range tests { 124 | t.Run(tt.name, func(t *testing.T) { 125 | got := b.Backoff(tt.idx) 126 | if tt.expected != got { 127 | t.Errorf("expected: %s, got: %s", tt.expected, got) 128 | } 129 | }) 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /backoff/constant.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package backoff 31 | 32 | import "time" 33 | 34 | // Constant is a default implementation for a backoff strategy with constant 35 | // backoff. 36 | type Constant struct { 37 | BaseDelay time.Duration 38 | } 39 | 40 | // Backoff returns the duration to wait. 41 | func (b Constant) Backoff(idx int) time.Duration { 42 | return b.BaseDelay 43 | } 44 | -------------------------------------------------------------------------------- /backoff/exponential.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package backoff 31 | 32 | import "time" 33 | 34 | // Exponential is an implementation of a backoff strategy applying an 35 | // exponential function. 36 | type Exponential struct { 37 | BaseDelay time.Duration 38 | Multiplier float64 39 | Jitter float64 40 | MaxDelay time.Duration 41 | } 42 | 43 | // Backoff returns the duration to wait. 44 | func (b Exponential) Backoff(idx int) time.Duration { 45 | if idx == 0 { 46 | return b.BaseDelay 47 | } 48 | 49 | backoff, max := float64(b.BaseDelay), float64(b.MaxDelay) 50 | for backoff < max && idx > 0 { 51 | backoff *= b.Multiplier 52 | idx-- 53 | } 54 | 55 | if backoff > max { 56 | backoff = max 57 | } 58 | 59 | backoff = addJitter(backoff, b.Jitter) 60 | return time.Duration(backoff) 61 | } 62 | -------------------------------------------------------------------------------- /backoff/jitter.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package backoff 31 | 32 | import "math/rand" 33 | 34 | func addJitter(backoff, jitter float64) float64 { 35 | backoff *= 1 + jitter*(rand.Float64()*2-1) 36 | if backoff < 0 { 37 | return 0 38 | } 39 | return backoff 40 | } 41 | -------------------------------------------------------------------------------- /backoff/linear.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package backoff 31 | 32 | import "time" 33 | 34 | // Linear is an implementation of a backoff strategy applying a linear 35 | // function. 36 | type Linear struct { 37 | BaseDelay time.Duration 38 | Jitter float64 39 | MaxDelay time.Duration 40 | } 41 | 42 | // Backoff returns the duration to wait. 43 | func (b Linear) Backoff(idx int) time.Duration { 44 | backoff, max := float64(b.BaseDelay), float64(b.MaxDelay) 45 | backoff *= float64(idx) + 1 46 | 47 | if backoff > max { 48 | backoff = max 49 | } 50 | 51 | backoff = addJitter(backoff, b.Jitter) 52 | return time.Duration(backoff) 53 | } 54 | -------------------------------------------------------------------------------- /credentials/basic.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package credentials 31 | 32 | import "net/http" 33 | 34 | // Basic defines a basic authentication mechanism that attaches a username and 35 | // password to each request. 36 | type Basic struct { 37 | username string 38 | password string 39 | } 40 | 41 | // NewBasicAuthentication returns a value describing authentication credentials 42 | // for a HTTP request. 43 | func NewBasicAuthentication(username, password string) *Basic { 44 | return &Basic{ 45 | username: username, 46 | password: password, 47 | } 48 | } 49 | 50 | // AddCredentials includes the basic authentication credentials within a HTTP 51 | // request. 52 | func (c *Basic) AddCredentials(r *http.Request) *http.Request { 53 | r.SetBasicAuth(c.username, c.password) 54 | return r 55 | } 56 | -------------------------------------------------------------------------------- /credentials/bearer.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package credentials 31 | 32 | import "net/http" 33 | 34 | const authorisationHeaderName = "Authorization" 35 | 36 | type tokenFunc func(r *http.Request) string 37 | 38 | // Bearer defines an authentication mechanism that attaches bearer token 39 | // security credentials to each request. 40 | type Bearer struct { 41 | header string 42 | token tokenFunc 43 | } 44 | 45 | // NewBearer returns a value describing authentication credentials for a HTTP 46 | // request. 47 | func NewBearer(token tokenFunc) *Bearer { 48 | return &Bearer{ 49 | header: authorisationHeaderName, 50 | token: token, 51 | } 52 | } 53 | 54 | // NewBearerWithStaticToken returns a value describing authentication 55 | // credentials for a HTTP request. 56 | func NewBearerWithStaticToken(token string) *Bearer { 57 | return &Bearer{ 58 | header: authorisationHeaderName, 59 | token: func(r *http.Request) string { 60 | return token 61 | }, 62 | } 63 | } 64 | 65 | // SetHeader allows for the bearer authentication scheme to be used with 66 | // a non-default header. 67 | func (c *Bearer) SetHeader(header string) { 68 | c.header = header 69 | } 70 | 71 | // AddCredentials includes the bearer authentication credentials within a HTTP 72 | // request. 73 | func (c *Bearer) AddCredentials(r *http.Request) *http.Request { 74 | r.Header.Set(c.header, "Bearer "+c.token(r)) 75 | return r 76 | } 77 | -------------------------------------------------------------------------------- /credentials/credentials_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package credentials_test 31 | 32 | import ( 33 | "encoding/base64" 34 | "net/http" 35 | "testing" 36 | 37 | "github.com/StatusCakeDev/statuscake-go/credentials" 38 | ) 39 | 40 | func TestBasicAuthentication(t *testing.T) { 41 | t.Run("sets basic authenticaton credentials on a HTTP request", func(t *testing.T) { 42 | r, err := http.NewRequest(http.MethodGet, "", nil) 43 | if err != nil { 44 | t.Fatalf("failed to create request: %+v", err) 45 | } 46 | 47 | c := credentials.NewBasicAuthentication("jean-luc", "enterprise") 48 | c.AddCredentials(r) 49 | 50 | authorisationHeader := r.Header.Get("Authorization") 51 | expected := "Basic " + base64.StdEncoding.EncodeToString([]byte("jean-luc:enterprise")) 52 | 53 | if authorisationHeader != expected { 54 | t.Errorf("expected: %s, got: %s", expected, authorisationHeader) 55 | } 56 | }) 57 | } 58 | 59 | func TestBearerToken(t *testing.T) { 60 | t.Run("sets bearer authenticaton credentials on a HTTP request", func(t *testing.T) { 61 | r, err := http.NewRequest(http.MethodGet, "", nil) 62 | if err != nil { 63 | t.Fatalf("failed to create request: %+v", err) 64 | } 65 | 66 | c := credentials.NewBearerWithStaticToken("this-is-a-token") 67 | c.AddCredentials(r) 68 | 69 | authorisationHeader := r.Header.Get("Authorization") 70 | expected := "Bearer this-is-a-token" 71 | 72 | if authorisationHeader != expected { 73 | t.Errorf("expected: %s, got: %s", expected, authorisationHeader) 74 | } 75 | }) 76 | 77 | t.Run("when a custom function is given, sets bearer authenticaton credentials on a HTTP request", func(t *testing.T) { 78 | r, err := http.NewRequest(http.MethodGet, "", nil) 79 | if err != nil { 80 | t.Fatalf("failed to create request: %+v", err) 81 | } 82 | 83 | c := credentials.NewBearer(func(r *http.Request) string { 84 | return "this-is-a-token" 85 | }) 86 | c.AddCredentials(r) 87 | 88 | authorisationHeader := r.Header.Get("Authorization") 89 | expected := "Bearer this-is-a-token" 90 | 91 | if authorisationHeader != expected { 92 | t.Errorf("expected: %s, got: %s", expected, authorisationHeader) 93 | } 94 | }) 95 | } 96 | -------------------------------------------------------------------------------- /error.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | // APIError represents an error returned from the API. This type abstracts the 33 | // different payloads that can be returned from the API in response to an error 34 | // which would otherwise add unnecessary compexity to the interface of this 35 | // package. 36 | type APIError struct { 37 | Status int 38 | Message string `json:"message,omitempty"` 39 | Errors map[string][]string `json:"errors,omitempty"` 40 | 41 | // Wrap the parent error in case it is of any use. 42 | parent error 43 | } 44 | 45 | // NewAPIError returns a structured error type from an API response. 46 | func NewAPIError(message string, parent error) APIError { 47 | return APIError{ 48 | Message: message, 49 | parent: parent, 50 | } 51 | } 52 | 53 | func (e APIError) Error() string { 54 | if e.parent != nil { 55 | return e.parent.Error() + ": " + e.Message 56 | } 57 | 58 | return e.Message 59 | } 60 | 61 | func (e APIError) Unwrap() error { 62 | return e.parent 63 | } 64 | 65 | // Errors returns the map of error messages contained in an APIError. If the 66 | // error passed into the function cannot be asserted to be of type APIError 67 | // then an empty map is returned. 68 | func Errors(err error) map[string][]string { 69 | if e, ok := err.(APIError); ok { 70 | return e.Errors 71 | } 72 | 73 | return map[string][]string{} 74 | } 75 | -------------------------------------------------------------------------------- /error_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake_test 31 | 32 | import ( 33 | "errors" 34 | "reflect" 35 | "testing" 36 | 37 | "github.com/StatusCakeDev/statuscake-go" 38 | ) 39 | 40 | func TestAPIError(t *testing.T) { 41 | t.Run("it conforms to the error interface", func(t *testing.T) { 42 | err := statuscake.NewAPIError( 43 | "error message", 44 | errors.New("parent error message"), 45 | ) 46 | 47 | expected := "parent error message: error message" 48 | got := err.Error() 49 | 50 | if expected != got { 51 | t.Errorf("expected: %s, got: %s", expected, got) 52 | } 53 | }) 54 | } 55 | 56 | func TestUnwrap(t *testing.T) { 57 | t.Run("it returns the wrapped error if exists", func(t *testing.T) { 58 | parent := errors.New("parent error message") 59 | 60 | err := statuscake.NewAPIError( 61 | "error message", 62 | parent, 63 | ) 64 | 65 | got := err.Unwrap() 66 | if got != parent { 67 | t.Errorf("expected: %+v, got: %+v", parent, got) 68 | } 69 | }) 70 | 71 | t.Run("it returns nil if no wrapped error exists", func(t *testing.T) { 72 | err := statuscake.NewAPIError( 73 | "error message", 74 | nil, 75 | ) 76 | 77 | got := err.Unwrap() 78 | if got != nil { 79 | t.Errorf("expected: , got: %+v", got) 80 | } 81 | }) 82 | } 83 | 84 | func TestErrors(t *testing.T) { 85 | t.Run("returns error messages contained within the error", func(t *testing.T) { 86 | errors := map[string][]string{ 87 | "field": []string{ 88 | "is required", 89 | "should be numeric", 90 | }, 91 | } 92 | 93 | err := statuscake.APIError{ 94 | Errors: errors, 95 | } 96 | 97 | expected := errors 98 | got := statuscake.Errors(err) 99 | 100 | if !reflect.DeepEqual(expected, got) { 101 | t.Errorf("expected: %+v, got: %+v", expected, got) 102 | } 103 | }) 104 | 105 | t.Run("returns an empty map if the error is of an unexpected type", func(t *testing.T) { 106 | got := statuscake.Errors(errors.New("unexpected error")) 107 | expected := map[string][]string{} 108 | 109 | if !reflect.DeepEqual(expected, got) { 110 | t.Errorf("expected: %+v, got: %+v", expected, got) 111 | } 112 | }) 113 | } 114 | -------------------------------------------------------------------------------- /examples/contact-groups/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/StatusCakeDev/statuscake-go" 9 | "github.com/StatusCakeDev/statuscake-go/credentials" 10 | ) 11 | 12 | func main() { 13 | var apiToken string 14 | 15 | if apiToken = os.Getenv("STATUSCAKE_API_TOKEN"); apiToken == "" { 16 | panic("STATUSCAKE_API_TOKEN not set in environment") 17 | } 18 | 19 | bearer := credentials.NewBearerWithStaticToken(apiToken) 20 | client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer)) 21 | 22 | res, err := client.CreateContactGroup(context.Background()). 23 | Name("Operations Team"). 24 | EmailAddresses([]string{ 25 | "johnsmith@example.com", 26 | "janesmith@example.com", 27 | }). 28 | Integrations([]string{ 29 | "1", 30 | "2", 31 | "3", 32 | }). 33 | MobileNumbers([]string{ 34 | "447712345678", 35 | "447987462344", 36 | }). 37 | PingURL("https://ping.example.com"). 38 | Execute() 39 | if err != nil { 40 | printError(err) 41 | return 42 | } 43 | 44 | groupID := res.Data.NewID 45 | fmt.Printf("CONTACT GROUP ID: %s\n", groupID) 46 | 47 | group, err := client.GetContactGroup(context.Background(), groupID).Execute() 48 | if err != nil { 49 | printError(err) 50 | } 51 | 52 | fmt.Printf("CONTACT GROUP: %+v\n", group.Data) 53 | 54 | err = client.UpdateContactGroup(context.Background(), groupID). 55 | Name("Development Team"). 56 | EmailAddresses([]string{}). // Remove all email addresses. 57 | Integrations([]string{ 58 | "4", 59 | "5", 60 | "6", 61 | }). 62 | MobileNumbers([]string{ 63 | "447891998195", 64 | }). 65 | PingURL("https://ping.example.com/groups"). 66 | Execute() 67 | if err != nil { 68 | printError(err) 69 | } 70 | 71 | group, err = client.GetContactGroup(context.Background(), groupID).Execute() 72 | if err != nil { 73 | printError(err) 74 | } 75 | 76 | fmt.Printf("UPDATED CONTACT GROUP: %+v\n", group.Data) 77 | 78 | groups, err := client.ListContactGroups(context.Background()).Execute() 79 | if err != nil { 80 | printError(err) 81 | } 82 | 83 | fmt.Printf("CONTACT GROUPS: %+v\n", groups.Data) 84 | 85 | err = client.DeleteContactGroup(context.Background(), groupID).Execute() 86 | if err != nil { 87 | printError(err) 88 | } 89 | } 90 | 91 | func printError(err error) { 92 | fmt.Println(err) 93 | fmt.Printf("%+v\n", statuscake.Errors(err)) 94 | } 95 | -------------------------------------------------------------------------------- /examples/heartbeat/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/StatusCakeDev/statuscake-go" 9 | "github.com/StatusCakeDev/statuscake-go/credentials" 10 | ) 11 | 12 | func main() { 13 | var apiToken string 14 | 15 | if apiToken = os.Getenv("STATUSCAKE_API_TOKEN"); apiToken == "" { 16 | panic("STATUSCAKE_API_TOKEN not set in environment") 17 | } 18 | 19 | bearer := credentials.NewBearerWithStaticToken(apiToken) 20 | client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer)) 21 | 22 | res, _ := client.CreateContactGroup(context.Background()). 23 | Name("Development Team"). 24 | Execute() 25 | 26 | groupID := res.Data.NewID 27 | defer client.DeleteContactGroup(context.Background(), groupID).Execute() 28 | 29 | res, err := client.CreateHeartbeatTest(context.Background()). 30 | Name("statuscake.com"). 31 | Period(1800). 32 | ContactGroups([]string{ 33 | groupID, 34 | }). 35 | Paused(true). 36 | Tags([]string{ 37 | "testing", 38 | }). 39 | Execute() 40 | if err != nil { 41 | printError(err) 42 | return 43 | } 44 | 45 | testID := res.Data.NewID 46 | fmt.Printf("HEARTBEAT CHECK ID: %s\n", testID) 47 | 48 | test, err := client.GetHeartbeatTest(context.Background(), testID).Execute() 49 | if err != nil { 50 | printError(err) 51 | } 52 | 53 | fmt.Printf("HEARTBEAT CHECK: %+v\n", test.Data) 54 | 55 | err = client.UpdateHeartbeatTest(context.Background(), testID). 56 | Period(3600). 57 | Paused(false). 58 | Execute() 59 | if err != nil { 60 | printError(err) 61 | } 62 | 63 | test, err = client.GetHeartbeatTest(context.Background(), testID).Execute() 64 | if err != nil { 65 | printError(err) 66 | } 67 | 68 | fmt.Printf("UPDATED HEARTBEAT CHECK: %+v\n", test.Data) 69 | 70 | tests, err := client.ListHeartbeatTests(context.Background()).Execute() 71 | if err != nil { 72 | printError(err) 73 | } 74 | 75 | fmt.Printf("HEARTBEAT CHECKS: %+v\n", tests.Data) 76 | 77 | err = client.DeleteHeartbeatTest(context.Background(), testID).Execute() 78 | if err != nil { 79 | printError(err) 80 | } 81 | } 82 | 83 | func printError(err error) { 84 | fmt.Println(err) 85 | fmt.Printf("%+v\n", statuscake.Errors(err)) 86 | } 87 | -------------------------------------------------------------------------------- /examples/locations/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/StatusCakeDev/statuscake-go" 9 | "github.com/StatusCakeDev/statuscake-go/credentials" 10 | ) 11 | 12 | func main() { 13 | var apiToken string 14 | 15 | if apiToken = os.Getenv("STATUSCAKE_API_TOKEN"); apiToken == "" { 16 | panic("STATUSCAKE_API_TOKEN not set in environment") 17 | } 18 | 19 | bearer := credentials.NewBearerWithStaticToken(apiToken) 20 | client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer)) 21 | 22 | locations, err := client.ListPagespeedMonitoringLocations(context.Background()).Execute() 23 | if err != nil { 24 | printError(err) 25 | } 26 | 27 | fmt.Printf("PAGESPEED LOCATIONS: %+v\n", locations.Data) 28 | 29 | locations, err = client.ListUptimeMonitoringLocations(context.Background()).Execute() 30 | if err != nil { 31 | printError(err) 32 | } 33 | 34 | fmt.Printf("UPTIME LOCATIONS: %+v\n", locations.Data) 35 | } 36 | 37 | func printError(err error) { 38 | fmt.Println(err) 39 | fmt.Printf("%+v\n", statuscake.Errors(err)) 40 | } 41 | -------------------------------------------------------------------------------- /examples/maintenance-windows/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | "time" 8 | 9 | "github.com/StatusCakeDev/statuscake-go" 10 | "github.com/StatusCakeDev/statuscake-go/credentials" 11 | ) 12 | 13 | func main() { 14 | var apiToken string 15 | 16 | if apiToken = os.Getenv("STATUSCAKE_API_TOKEN"); apiToken == "" { 17 | panic("STATUSCAKE_API_TOKEN not set in environment") 18 | } 19 | 20 | bearer := credentials.NewBearerWithStaticToken(apiToken) 21 | client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer)) 22 | 23 | t := time.Now() 24 | res, err := client.CreateMaintenanceWindow(context.Background()). 25 | Name("Weekly maintenance"). 26 | End(t.Add(time.Hour * 3)). 27 | RepeatInterval(statuscake.MaintenanceWindowRepeatIntervalWeekly). 28 | Start(t). 29 | Tags([]string{"testing"}). 30 | Timezone("UTC"). 31 | Execute() 32 | if err != nil { 33 | printError(err) 34 | return 35 | } 36 | 37 | windowID := res.Data.NewID 38 | fmt.Printf("MAINTENANCE WINDOW ID: %s\n", windowID) 39 | 40 | window, err := client.GetMaintenanceWindow(context.Background(), windowID).Execute() 41 | if err != nil { 42 | printError(err) 43 | } 44 | 45 | fmt.Printf("MAINTENANCE WINDOW: %+v\n", window.Data) 46 | 47 | err = client.UpdateMaintenanceWindow(context.Background(), windowID). 48 | Name("Monthly maintenance"). 49 | End(t.Add(time.Hour * 48)). 50 | RepeatInterval(statuscake.MaintenanceWindowRepeatIntervalMonthly). 51 | Start(t). 52 | Execute() 53 | if err != nil { 54 | printError(err) 55 | } 56 | 57 | window, err = client.GetMaintenanceWindow(context.Background(), windowID).Execute() 58 | if err != nil { 59 | printError(err) 60 | } 61 | 62 | fmt.Printf("UPDATED MAINTENANCE WINDOW: %+v\n", window.Data) 63 | 64 | windows, err := client.ListMaintenanceWindows(context.Background()).Execute() 65 | if err != nil { 66 | printError(err) 67 | } 68 | 69 | fmt.Printf("MAINTENANCE WINDOWS: %+v\n", windows.Data) 70 | 71 | err = client.DeleteMaintenanceWindow(context.Background(), windowID).Execute() 72 | if err != nil { 73 | printError(err) 74 | } 75 | } 76 | 77 | func printError(err error) { 78 | fmt.Println(err) 79 | fmt.Printf("%+v\n", statuscake.Errors(err)) 80 | } 81 | -------------------------------------------------------------------------------- /examples/pagespeed/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/StatusCakeDev/statuscake-go" 9 | "github.com/StatusCakeDev/statuscake-go/credentials" 10 | ) 11 | 12 | func main() { 13 | var apiToken string 14 | 15 | if apiToken = os.Getenv("STATUSCAKE_API_TOKEN"); apiToken == "" { 16 | panic("STATUSCAKE_API_TOKEN not set in environment") 17 | } 18 | 19 | bearer := credentials.NewBearerWithStaticToken(apiToken) 20 | client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer)) 21 | 22 | res, _ := client.CreateContactGroup(context.Background()). 23 | Name("Development Team"). 24 | Execute() 25 | 26 | groupID := res.Data.NewID 27 | defer client.DeleteContactGroup(context.Background(), groupID).Execute() 28 | 29 | res, err := client.CreatePagespeedTest(context.Background()). 30 | Name("statuscake.com"). 31 | WebsiteURL("https://www.statuscake.com"). 32 | CheckRate(statuscake.PagespeedTestCheckRateOneDay). 33 | AlertSmaller(10). 34 | AlertBigger(100). 35 | AlertSlower(1000). 36 | ContactGroups([]string{ 37 | groupID, 38 | }). 39 | Paused(true). 40 | Region(statuscake.PagespeedTestRegionUnitedKingdom). 41 | Execute() 42 | if err != nil { 43 | printError(err) 44 | return 45 | } 46 | 47 | testID := res.Data.NewID 48 | fmt.Printf("PAGESPEED CHECK ID: %s\n", testID) 49 | 50 | test, err := client.GetPagespeedTest(context.Background(), testID).Execute() 51 | if err != nil { 52 | printError(err) 53 | } 54 | 55 | fmt.Printf("PAGESPEED CHECK: %+v\n", test.Data) 56 | 57 | err = client.UpdatePagespeedTest(context.Background(), testID). 58 | CheckRate(statuscake.PagespeedTestCheckRateOneHour). 59 | ContactGroups([]string{}). // Remove all contact groups. 60 | Paused(false). 61 | Execute() 62 | if err != nil { 63 | printError(err) 64 | } 65 | 66 | test, err = client.GetPagespeedTest(context.Background(), testID).Execute() 67 | if err != nil { 68 | printError(err) 69 | } 70 | 71 | fmt.Printf("UPDATED PAGESPEED CHECK: %+v\n", test.Data) 72 | 73 | tests, err := client.ListPagespeedTests(context.Background()).Execute() 74 | if err != nil { 75 | printError(err) 76 | } 77 | 78 | fmt.Printf("PAGESPEED CHECKS: %+v\n", tests.Data) 79 | 80 | results, err := client.ListPagespeedTestHistory(context.Background(), testID).Execute() 81 | if err != nil { 82 | printError(err) 83 | } 84 | 85 | fmt.Printf("PAGESPEED CHECK HISTORY: %+v\n", results.Data) 86 | 87 | err = client.DeletePagespeedTest(context.Background(), testID).Execute() 88 | if err != nil { 89 | printError(err) 90 | } 91 | } 92 | 93 | func printError(err error) { 94 | fmt.Println(err) 95 | fmt.Printf("%+v\n", statuscake.Errors(err)) 96 | } 97 | -------------------------------------------------------------------------------- /examples/ssl/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | 8 | "github.com/StatusCakeDev/statuscake-go" 9 | "github.com/StatusCakeDev/statuscake-go/credentials" 10 | ) 11 | 12 | func main() { 13 | var apiToken string 14 | 15 | if apiToken = os.Getenv("STATUSCAKE_API_TOKEN"); apiToken == "" { 16 | panic("STATUSCAKE_API_TOKEN not set in environment") 17 | } 18 | 19 | bearer := credentials.NewBearerWithStaticToken(apiToken) 20 | client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer)) 21 | 22 | res, _ := client.CreateContactGroup(context.Background()). 23 | Name("Development Team"). 24 | Execute() 25 | 26 | groupID := res.Data.NewID 27 | defer client.DeleteContactGroup(context.Background(), groupID).Execute() 28 | 29 | res, err := client.CreateSslTest(context.Background()). 30 | WebsiteURL("https://www.statuscake.com"). 31 | CheckRate(statuscake.SSLTestCheckRateFiveMinutes). 32 | AlertAt([]int32{1, 7, 30}). 33 | AlertBroken(true). 34 | AlertExpiry(true). 35 | AlertMixed(true). 36 | AlertReminder(true). 37 | ContactGroups([]string{ 38 | groupID, 39 | }). 40 | FollowRedirects(true). 41 | Paused(true). 42 | Execute() 43 | if err != nil { 44 | printError(err) 45 | return 46 | } 47 | 48 | testID := res.Data.NewID 49 | fmt.Printf("SSL CHECK ID: %s\n", testID) 50 | 51 | test, err := client.GetSslTest(context.Background(), testID).Execute() 52 | if err != nil { 53 | printError(err) 54 | } 55 | 56 | fmt.Printf("SSL CHECK: %+v\n", test.Data) 57 | 58 | err = client.UpdateSslTest(context.Background(), testID). 59 | CheckRate(statuscake.SSLTestCheckRateOneHour). 60 | ContactGroups([]string{}). // Remove all contact groups. 61 | Paused(false). 62 | Execute() 63 | if err != nil { 64 | printError(err) 65 | } 66 | 67 | test, err = client.GetSslTest(context.Background(), testID).Execute() 68 | if err != nil { 69 | printError(err) 70 | } 71 | 72 | fmt.Printf("UPDATED SSL CHECK: %+v\n", test.Data) 73 | 74 | tests, err := client.ListSslTests(context.Background()).Execute() 75 | if err != nil { 76 | printError(err) 77 | } 78 | 79 | fmt.Printf("SSL CHECKS: %+v\n", tests.Data) 80 | 81 | err = client.DeleteSslTest(context.Background(), testID).Execute() 82 | if err != nil { 83 | printError(err) 84 | } 85 | } 86 | 87 | func printError(err error) { 88 | fmt.Println(err) 89 | fmt.Printf("%+v\n", statuscake.Errors(err)) 90 | } 91 | -------------------------------------------------------------------------------- /examples/uptime/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import ( 4 | "context" 5 | "fmt" 6 | "os" 7 | "time" 8 | 9 | "github.com/StatusCakeDev/statuscake-go" 10 | "github.com/StatusCakeDev/statuscake-go/credentials" 11 | ) 12 | 13 | func main() { 14 | var apiToken string 15 | 16 | if apiToken = os.Getenv("STATUSCAKE_API_TOKEN"); apiToken == "" { 17 | panic("STATUSCAKE_API_TOKEN not set in environment") 18 | } 19 | 20 | bearer := credentials.NewBearerWithStaticToken(apiToken) 21 | client := statuscake.NewClient(statuscake.WithRequestCredentials(bearer)) 22 | 23 | res, _ := client.CreateContactGroup(context.Background()). 24 | Name("Development Team"). 25 | Execute() 26 | 27 | groupID := res.Data.NewID 28 | defer client.DeleteContactGroup(context.Background(), groupID).Execute() 29 | 30 | t := time.Now() 31 | res, _ = client.CreateMaintenanceWindow(context.Background()). 32 | Name("Saturday maintenance"). 33 | End(t.Add(time.Hour * 3)). 34 | RepeatInterval(statuscake.MaintenanceWindowRepeatIntervalWeekly). 35 | Start(t). 36 | Tags([]string{"testing"}). 37 | Timezone("UTC"). 38 | Execute() 39 | 40 | windowID := res.Data.NewID 41 | defer client.DeleteMaintenanceWindow(context.Background(), windowID).Execute() 42 | 43 | res, err := client.CreateUptimeTest(context.Background()). 44 | Name("statuscake.com"). 45 | TestType(statuscake.UptimeTestTypeHTTP). 46 | WebsiteURL("https://www.statuscake.com"). 47 | CheckRate(statuscake.UptimeTestCheckRateFifteenMinutes). 48 | ContactGroups([]string{ 49 | groupID, 50 | }). 51 | EnableSSLAlert(true). 52 | FollowRedirects(true). 53 | Paused(true). 54 | Regions([]string{ 55 | "london", 56 | }). 57 | Tags([]string{ 58 | "testing", 59 | }). 60 | Execute() 61 | if err != nil { 62 | printError(err) 63 | return 64 | } 65 | 66 | testID := res.Data.NewID 67 | fmt.Printf("UPTIME CHECK ID: %s\n", testID) 68 | 69 | test, err := client.GetUptimeTest(context.Background(), testID).Execute() 70 | if err != nil { 71 | printError(err) 72 | } 73 | 74 | fmt.Printf("UPTIME CHECK: %+v\n", test.Data) 75 | 76 | err = client.UpdateUptimeTest(context.Background(), testID). 77 | CheckRate(statuscake.UptimeTestCheckRateThirtyMinutes). 78 | Paused(false). 79 | Regions([]string{ 80 | "london", 81 | "paris", 82 | }). 83 | Execute() 84 | if err != nil { 85 | printError(err) 86 | } 87 | 88 | test, err = client.GetUptimeTest(context.Background(), testID).Execute() 89 | if err != nil { 90 | printError(err) 91 | } 92 | 93 | fmt.Printf("UPDATED UPTIME CHECK: %+v\n", test.Data) 94 | 95 | tests, err := client.ListUptimeTests(context.Background()).Execute() 96 | if err != nil { 97 | printError(err) 98 | } 99 | 100 | fmt.Printf("UPTIME CHECKS: %+v\n", tests.Data) 101 | 102 | results, err := client.ListUptimeTestHistory(context.Background(), testID).Execute() 103 | if err != nil { 104 | printError(err) 105 | } 106 | 107 | fmt.Printf("UPTIME CHECK HISTORY: %+v\n", results.Data) 108 | 109 | periods, err := client.ListUptimeTestPeriods(context.Background(), testID).Execute() 110 | if err != nil { 111 | printError(err) 112 | } 113 | 114 | fmt.Printf("UPTIME CHECK PERIODS: %+v\n", periods.Data) 115 | 116 | alerts, err := client.ListUptimeTestAlerts(context.Background(), testID).Execute() 117 | if err != nil { 118 | printError(err) 119 | } 120 | 121 | fmt.Printf("SENT ALERTS: %+v\n", alerts.Data) 122 | 123 | err = client.DeleteUptimeTest(context.Background(), testID).Execute() 124 | if err != nil { 125 | printError(err) 126 | } 127 | } 128 | 129 | func printError(err error) { 130 | fmt.Println(err) 131 | fmt.Printf("%+v\n", statuscake.Errors(err)) 132 | } 133 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/StatusCakeDev/statuscake-go 2 | 3 | go 1.13 4 | -------------------------------------------------------------------------------- /model_api_response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // APIResponse struct for APIResponse 37 | type APIResponse struct { 38 | Data APIResponseData `json:"data"` 39 | } 40 | 41 | // NewAPIResponse instantiates a new APIResponse object. 42 | // This constructor will assign default values to properties that have it 43 | // defined, and makes sure properties required by API are set, but the set of 44 | // arguments will change when the set of required properties is changed. 45 | func NewAPIResponse(data APIResponseData) *APIResponse { 46 | return &APIResponse{ 47 | Data: data, 48 | } 49 | } 50 | 51 | // MarshalJSON serialises data in the struct to JSON. 52 | func (o APIResponse) MarshalJSON() ([]byte, error) { 53 | toSerialize := map[string]interface{}{} 54 | if true { 55 | toSerialize["data"] = o.Data 56 | } 57 | return json.Marshal(toSerialize) 58 | } 59 | -------------------------------------------------------------------------------- /model_api_response_data.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // APIResponseData Response body 37 | type APIResponseData struct { 38 | // ID of newly created resource. 39 | NewID string `json:"new_id"` 40 | } 41 | 42 | // NewAPIResponseData instantiates a new APIResponseData object. 43 | // This constructor will assign default values to properties that have it 44 | // defined, and makes sure properties required by API are set, but the set of 45 | // arguments will change when the set of required properties is changed. 46 | func NewAPIResponseData(newId string) *APIResponseData { 47 | return &APIResponseData{ 48 | NewID: newId, 49 | } 50 | } 51 | 52 | // MarshalJSON serialises data in the struct to JSON. 53 | func (o APIResponseData) MarshalJSON() ([]byte, error) { 54 | toSerialize := map[string]interface{}{} 55 | if true { 56 | toSerialize["new_id"] = o.NewID 57 | } 58 | return json.Marshal(toSerialize) 59 | } 60 | -------------------------------------------------------------------------------- /model_contact_group.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // ContactGroup struct for ContactGroup 37 | type ContactGroup struct { 38 | // Contact group ID 39 | ID string `json:"id"` 40 | // Name of the contact group 41 | Name string `json:"name"` 42 | // List of email addresses 43 | EmailAddresses []string `json:"email_addresses"` 44 | // List of configured integration IDs 45 | Integrations []string `json:"integrations"` 46 | // List of international format mobile phone numbers 47 | MobileNumbers []string `json:"mobile_numbers"` 48 | // URL or IP address of an endpoint to push uptime events. Currently this only supports HTTP GET endpoints 49 | PingURL *string `json:"ping_url,omitempty"` 50 | } 51 | 52 | // NewContactGroup instantiates a new ContactGroup object. 53 | // This constructor will assign default values to properties that have it 54 | // defined, and makes sure properties required by API are set, but the set of 55 | // arguments will change when the set of required properties is changed. 56 | func NewContactGroup(id string, name string, emailAddresses []string, integrations []string, mobileNumbers []string) *ContactGroup { 57 | return &ContactGroup{ 58 | ID: id, 59 | Name: name, 60 | EmailAddresses: emailAddresses, 61 | Integrations: integrations, 62 | MobileNumbers: mobileNumbers, 63 | } 64 | } 65 | 66 | // MarshalJSON serialises data in the struct to JSON. 67 | func (o ContactGroup) MarshalJSON() ([]byte, error) { 68 | toSerialize := map[string]interface{}{} 69 | if true { 70 | toSerialize["id"] = o.ID 71 | } 72 | if true { 73 | toSerialize["name"] = o.Name 74 | } 75 | if true { 76 | toSerialize["email_addresses"] = o.EmailAddresses 77 | } 78 | if true { 79 | toSerialize["integrations"] = o.Integrations 80 | } 81 | if true { 82 | toSerialize["mobile_numbers"] = o.MobileNumbers 83 | } 84 | if o.PingURL != nil { 85 | toSerialize["ping_url"] = o.PingURL 86 | } 87 | return json.Marshal(toSerialize) 88 | } 89 | -------------------------------------------------------------------------------- /model_contact_group_response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // ContactGroupResponse struct for ContactGroupResponse 37 | type ContactGroupResponse struct { 38 | Data ContactGroup `json:"data"` 39 | } 40 | 41 | // NewContactGroupResponse instantiates a new ContactGroupResponse object. 42 | // This constructor will assign default values to properties that have it 43 | // defined, and makes sure properties required by API are set, but the set of 44 | // arguments will change when the set of required properties is changed. 45 | func NewContactGroupResponse(data ContactGroup) *ContactGroupResponse { 46 | return &ContactGroupResponse{ 47 | Data: data, 48 | } 49 | } 50 | 51 | // MarshalJSON serialises data in the struct to JSON. 52 | func (o ContactGroupResponse) MarshalJSON() ([]byte, error) { 53 | toSerialize := map[string]interface{}{} 54 | if true { 55 | toSerialize["data"] = o.Data 56 | } 57 | return json.Marshal(toSerialize) 58 | } 59 | -------------------------------------------------------------------------------- /model_contact_groups.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // ContactGroups struct for ContactGroups 37 | type ContactGroups struct { 38 | // List of contact groups 39 | Data []ContactGroup `json:"data"` 40 | Metadata Pagination `json:"metadata"` 41 | } 42 | 43 | // NewContactGroups instantiates a new ContactGroups object. 44 | // This constructor will assign default values to properties that have it 45 | // defined, and makes sure properties required by API are set, but the set of 46 | // arguments will change when the set of required properties is changed. 47 | func NewContactGroups(data []ContactGroup, metadata Pagination) *ContactGroups { 48 | return &ContactGroups{ 49 | Data: data, 50 | Metadata: metadata, 51 | } 52 | } 53 | 54 | // MarshalJSON serialises data in the struct to JSON. 55 | func (o ContactGroups) MarshalJSON() ([]byte, error) { 56 | toSerialize := map[string]interface{}{} 57 | if true { 58 | toSerialize["data"] = o.Data 59 | } 60 | if true { 61 | toSerialize["metadata"] = o.Metadata 62 | } 63 | return json.Marshal(toSerialize) 64 | } 65 | -------------------------------------------------------------------------------- /model_heartbeat_test_.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "time" 35 | ) 36 | 37 | // HeartbeatTest struct for HeartbeatTest 38 | type HeartbeatTest struct { 39 | // Heartbeat check ID 40 | ID string `json:"id"` 41 | // Name of the check 42 | Name string `json:"name"` 43 | // URL of the check 44 | WebsiteURL string `json:"url"` 45 | // Number of seconds since the last ping before the check is considered down 46 | Period int32 `json:"period"` 47 | // List of contact group IDs 48 | ContactGroups []string `json:"contact_groups"` 49 | // Name of the hosting provider 50 | Host *string `json:"host,omitempty"` 51 | // When the check was last run (RFC3339 format) 52 | LastTested *time.Time `json:"last_tested_at,omitempty"` 53 | // Whether the check should be run 54 | Paused bool `json:"paused"` 55 | Status HeartbeatTestStatus `json:"status"` 56 | // List of tags 57 | Tags []string `json:"tags"` 58 | // Uptime percentage for a check 59 | Uptime float32 `json:"uptime"` 60 | } 61 | 62 | // NewHeartbeatTest instantiates a new HeartbeatTest object. 63 | // This constructor will assign default values to properties that have it 64 | // defined, and makes sure properties required by API are set, but the set of 65 | // arguments will change when the set of required properties is changed. 66 | func NewHeartbeatTest(id string, name string, url string, period int32, contactGroups []string, paused bool, status HeartbeatTestStatus, tags []string, uptime float32) *HeartbeatTest { 67 | return &HeartbeatTest{ 68 | ID: id, 69 | Name: name, 70 | WebsiteURL: url, 71 | Period: period, 72 | ContactGroups: contactGroups, 73 | Paused: paused, 74 | Status: status, 75 | Tags: tags, 76 | Uptime: uptime, 77 | } 78 | } 79 | 80 | // MarshalJSON serialises data in the struct to JSON. 81 | func (o HeartbeatTest) MarshalJSON() ([]byte, error) { 82 | toSerialize := map[string]interface{}{} 83 | if true { 84 | toSerialize["id"] = o.ID 85 | } 86 | if true { 87 | toSerialize["name"] = o.Name 88 | } 89 | if true { 90 | toSerialize["url"] = o.WebsiteURL 91 | } 92 | if true { 93 | toSerialize["period"] = o.Period 94 | } 95 | if true { 96 | toSerialize["contact_groups"] = o.ContactGroups 97 | } 98 | if o.Host != nil { 99 | toSerialize["host"] = o.Host 100 | } 101 | if o.LastTested != nil { 102 | toSerialize["last_tested_at"] = o.LastTested 103 | } 104 | if true { 105 | toSerialize["paused"] = o.Paused 106 | } 107 | if true { 108 | toSerialize["status"] = o.Status 109 | } 110 | if true { 111 | toSerialize["tags"] = o.Tags 112 | } 113 | if true { 114 | toSerialize["uptime"] = o.Uptime 115 | } 116 | return json.Marshal(toSerialize) 117 | } 118 | -------------------------------------------------------------------------------- /model_heartbeat_test_overview.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // HeartbeatTestOverview struct for HeartbeatTestOverview 37 | type HeartbeatTestOverview struct { 38 | // Heartbeat check ID 39 | ID string `json:"id"` 40 | // Name of the check 41 | Name string `json:"name"` 42 | // URL of the check 43 | WebsiteURL string `json:"url"` 44 | // Number of seconds since the last ping before the check is considered down 45 | Period int32 `json:"period"` 46 | // List of contact group IDs 47 | ContactGroups []string `json:"contact_groups"` 48 | // Whether the check should be run 49 | Paused bool `json:"paused"` 50 | Status HeartbeatTestStatus `json:"status"` 51 | // List of tags 52 | Tags []string `json:"tags"` 53 | // Uptime percentage for a check 54 | Uptime *float32 `json:"uptime,omitempty"` 55 | } 56 | 57 | // NewHeartbeatTestOverview instantiates a new HeartbeatTestOverview object. 58 | // This constructor will assign default values to properties that have it 59 | // defined, and makes sure properties required by API are set, but the set of 60 | // arguments will change when the set of required properties is changed. 61 | func NewHeartbeatTestOverview(id string, name string, url string, period int32, contactGroups []string, paused bool, status HeartbeatTestStatus, tags []string) *HeartbeatTestOverview { 62 | return &HeartbeatTestOverview{ 63 | ID: id, 64 | Name: name, 65 | WebsiteURL: url, 66 | Period: period, 67 | ContactGroups: contactGroups, 68 | Paused: paused, 69 | Status: status, 70 | Tags: tags, 71 | } 72 | } 73 | 74 | // MarshalJSON serialises data in the struct to JSON. 75 | func (o HeartbeatTestOverview) MarshalJSON() ([]byte, error) { 76 | toSerialize := map[string]interface{}{} 77 | if true { 78 | toSerialize["id"] = o.ID 79 | } 80 | if true { 81 | toSerialize["name"] = o.Name 82 | } 83 | if true { 84 | toSerialize["url"] = o.WebsiteURL 85 | } 86 | if true { 87 | toSerialize["period"] = o.Period 88 | } 89 | if true { 90 | toSerialize["contact_groups"] = o.ContactGroups 91 | } 92 | if true { 93 | toSerialize["paused"] = o.Paused 94 | } 95 | if true { 96 | toSerialize["status"] = o.Status 97 | } 98 | if true { 99 | toSerialize["tags"] = o.Tags 100 | } 101 | if o.Uptime != nil { 102 | toSerialize["uptime"] = o.Uptime 103 | } 104 | return json.Marshal(toSerialize) 105 | } 106 | -------------------------------------------------------------------------------- /model_heartbeat_test_response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // HeartbeatTestResponse struct for HeartbeatTestResponse 37 | type HeartbeatTestResponse struct { 38 | Data HeartbeatTest `json:"data"` 39 | } 40 | 41 | // NewHeartbeatTestResponse instantiates a new HeartbeatTestResponse object. 42 | // This constructor will assign default values to properties that have it 43 | // defined, and makes sure properties required by API are set, but the set of 44 | // arguments will change when the set of required properties is changed. 45 | func NewHeartbeatTestResponse(data HeartbeatTest) *HeartbeatTestResponse { 46 | return &HeartbeatTestResponse{ 47 | Data: data, 48 | } 49 | } 50 | 51 | // MarshalJSON serialises data in the struct to JSON. 52 | func (o HeartbeatTestResponse) MarshalJSON() ([]byte, error) { 53 | toSerialize := map[string]interface{}{} 54 | if true { 55 | toSerialize["data"] = o.Data 56 | } 57 | return json.Marshal(toSerialize) 58 | } 59 | -------------------------------------------------------------------------------- /model_heartbeat_test_status.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // HeartbeatTestStatus The returned status of a heartbeat check 38 | type HeartbeatTestStatus string 39 | 40 | const ( 41 | // HeartbeatTestStatusDown a heartbeat check with a down status. 42 | HeartbeatTestStatusDown HeartbeatTestStatus = "down" 43 | // HeartbeatTestStatusUp a heartbeat check with an up status. 44 | HeartbeatTestStatusUp HeartbeatTestStatus = "up" 45 | ) 46 | 47 | // Unmarshal JSON data into any of the pointers in the type. 48 | func (v *HeartbeatTestStatus) UnmarshalJSON(src []byte) error { 49 | var value string 50 | if err := json.Unmarshal(src, &value); err != nil { 51 | return err 52 | } 53 | 54 | ev := HeartbeatTestStatus(value) 55 | if !ev.Valid() { 56 | return fmt.Errorf("%+v is not a valid HeartbeatTestStatus", value) 57 | } 58 | 59 | *v = ev 60 | return nil 61 | } 62 | 63 | // Valid determines if the value is valid. 64 | func (v HeartbeatTestStatus) Valid() bool { 65 | return v == HeartbeatTestStatusDown || v == HeartbeatTestStatusUp 66 | } 67 | 68 | // HeartbeatTestStatusValues returns the values of HeartbeatTestStatus. 69 | func HeartbeatTestStatusValues() []string { 70 | return []string{ 71 | "down", 72 | "up", 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /model_heartbeat_tests.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // HeartbeatTests struct for HeartbeatTests 37 | type HeartbeatTests struct { 38 | // List of heartbeat checks 39 | Data []HeartbeatTestOverview `json:"data"` 40 | Metadata Pagination `json:"metadata"` 41 | } 42 | 43 | // NewHeartbeatTests instantiates a new HeartbeatTests object. 44 | // This constructor will assign default values to properties that have it 45 | // defined, and makes sure properties required by API are set, but the set of 46 | // arguments will change when the set of required properties is changed. 47 | func NewHeartbeatTests(data []HeartbeatTestOverview, metadata Pagination) *HeartbeatTests { 48 | return &HeartbeatTests{ 49 | Data: data, 50 | Metadata: metadata, 51 | } 52 | } 53 | 54 | // MarshalJSON serialises data in the struct to JSON. 55 | func (o HeartbeatTests) MarshalJSON() ([]byte, error) { 56 | toSerialize := map[string]interface{}{} 57 | if true { 58 | toSerialize["data"] = o.Data 59 | } 60 | if true { 61 | toSerialize["metadata"] = o.Metadata 62 | } 63 | return json.Marshal(toSerialize) 64 | } 65 | -------------------------------------------------------------------------------- /model_links.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // Links struct for Links 37 | type Links struct { 38 | // The URL that created the current response document 39 | Self string `json:"self"` 40 | // Additional links. The nature of these fields is described in the endpoint description 41 | AdditionalProperties map[string]interface{} 42 | } 43 | 44 | type _Links Links 45 | 46 | // NewLinks instantiates a new Links object. 47 | // This constructor will assign default values to properties that have it 48 | // defined, and makes sure properties required by API are set, but the set of 49 | // arguments will change when the set of required properties is changed. 50 | func NewLinks(self string) *Links { 51 | return &Links{ 52 | Self: self, 53 | } 54 | } 55 | 56 | // MarshalJSON serialises data in the struct to JSON. 57 | func (o Links) MarshalJSON() ([]byte, error) { 58 | toSerialize := map[string]interface{}{} 59 | if true { 60 | toSerialize["self"] = o.Self 61 | } 62 | for key, value := range o.AdditionalProperties { 63 | toSerialize[key] = value 64 | } 65 | return json.Marshal(toSerialize) 66 | } 67 | 68 | // UnmarshalJSON deserialises JSON into a struct. 69 | func (o *Links) UnmarshalJSON(bytes []byte) error { 70 | varLinks := _Links{} 71 | if err := json.Unmarshal(bytes, &varLinks); err != nil { 72 | return err 73 | } 74 | 75 | *o = Links(varLinks) 76 | 77 | additionalProperties := make(map[string]interface{}) 78 | if err := json.Unmarshal(bytes, &additionalProperties); err != nil { 79 | return err 80 | } 81 | 82 | // This is a hack to ensure the `self` key is removed from additional 83 | // properies. This is adequate since we only expect this single key to be 84 | // present. But this is not scalable. 85 | delete(additionalProperties, "self") 86 | o.AdditionalProperties = additionalProperties 87 | 88 | return nil 89 | } 90 | -------------------------------------------------------------------------------- /model_maintenance_window.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "time" 35 | ) 36 | 37 | // MaintenanceWindow struct for MaintenanceWindow 38 | type MaintenanceWindow struct { 39 | // Maintenance window ID 40 | ID string `json:"id"` 41 | // Name of the maintenance window 42 | Name string `json:"name"` 43 | // End of the maintenance window (RFC3339 format) 44 | End time.Time `json:"end_at"` 45 | RepeatInterval MaintenanceWindowRepeatInterval `json:"repeat_interval"` 46 | // Start of the maintenance window (RFC3339 format) 47 | Start time.Time `json:"start_at"` 48 | State MaintenanceWindowState `json:"state"` 49 | // List of tags used to include matching uptime checks in this maintenance window 50 | Tags []string `json:"tags"` 51 | // List of uptime check IDs explicitly included in this maintenance window 52 | Tests []string `json:"tests"` 53 | // Standard [timezone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List) associated with this maintenance window 54 | Timezone string `json:"timezone"` 55 | } 56 | 57 | // NewMaintenanceWindow instantiates a new MaintenanceWindow object. 58 | // This constructor will assign default values to properties that have it 59 | // defined, and makes sure properties required by API are set, but the set of 60 | // arguments will change when the set of required properties is changed. 61 | func NewMaintenanceWindow(id string, name string, endAt time.Time, repeatInterval MaintenanceWindowRepeatInterval, startAt time.Time, state MaintenanceWindowState, tags []string, tests []string, timezone string) *MaintenanceWindow { 62 | return &MaintenanceWindow{ 63 | ID: id, 64 | Name: name, 65 | End: endAt, 66 | RepeatInterval: repeatInterval, 67 | Start: startAt, 68 | State: state, 69 | Tags: tags, 70 | Tests: tests, 71 | Timezone: timezone, 72 | } 73 | } 74 | 75 | // MarshalJSON serialises data in the struct to JSON. 76 | func (o MaintenanceWindow) MarshalJSON() ([]byte, error) { 77 | toSerialize := map[string]interface{}{} 78 | if true { 79 | toSerialize["id"] = o.ID 80 | } 81 | if true { 82 | toSerialize["name"] = o.Name 83 | } 84 | if true { 85 | toSerialize["end_at"] = o.End 86 | } 87 | if true { 88 | toSerialize["repeat_interval"] = o.RepeatInterval 89 | } 90 | if true { 91 | toSerialize["start_at"] = o.Start 92 | } 93 | if true { 94 | toSerialize["state"] = o.State 95 | } 96 | if true { 97 | toSerialize["tags"] = o.Tags 98 | } 99 | if true { 100 | toSerialize["tests"] = o.Tests 101 | } 102 | if true { 103 | toSerialize["timezone"] = o.Timezone 104 | } 105 | return json.Marshal(toSerialize) 106 | } 107 | -------------------------------------------------------------------------------- /model_maintenance_window_repeat_interval.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // MaintenanceWindowRepeatInterval How often the maintenance window should occur 38 | type MaintenanceWindowRepeatInterval string 39 | 40 | const ( 41 | // MaintenanceWindowRepeatIntervalNever a maintenance window that never reoccurs. 42 | MaintenanceWindowRepeatIntervalNever MaintenanceWindowRepeatInterval = "never" 43 | // MaintenanceWindowRepeatIntervalDaily a maintenance window occuring daily. 44 | MaintenanceWindowRepeatIntervalDaily MaintenanceWindowRepeatInterval = "1d" 45 | // MaintenanceWindowRepeatIntervalWeekly a maintenance window occuring weekly. 46 | MaintenanceWindowRepeatIntervalWeekly MaintenanceWindowRepeatInterval = "1w" 47 | // MaintenanceWindowRepeatIntervalBiweekly a maintenance window occuring biweekly. 48 | MaintenanceWindowRepeatIntervalBiweekly MaintenanceWindowRepeatInterval = "2w" 49 | // MaintenanceWindowRepeatIntervalMonthly a maintenance window occuring monthly. 50 | MaintenanceWindowRepeatIntervalMonthly MaintenanceWindowRepeatInterval = "1m" 51 | ) 52 | 53 | // Unmarshal JSON data into any of the pointers in the type. 54 | func (v *MaintenanceWindowRepeatInterval) UnmarshalJSON(src []byte) error { 55 | var value string 56 | if err := json.Unmarshal(src, &value); err != nil { 57 | return err 58 | } 59 | 60 | ev := MaintenanceWindowRepeatInterval(value) 61 | if !ev.Valid() { 62 | return fmt.Errorf("%+v is not a valid MaintenanceWindowRepeatInterval", value) 63 | } 64 | 65 | *v = ev 66 | return nil 67 | } 68 | 69 | // Valid determines if the value is valid. 70 | func (v MaintenanceWindowRepeatInterval) Valid() bool { 71 | return v == MaintenanceWindowRepeatIntervalNever || v == MaintenanceWindowRepeatIntervalDaily || v == MaintenanceWindowRepeatIntervalWeekly || v == MaintenanceWindowRepeatIntervalBiweekly || v == MaintenanceWindowRepeatIntervalMonthly 72 | } 73 | 74 | // MaintenanceWindowRepeatIntervalValues returns the values of MaintenanceWindowRepeatInterval. 75 | func MaintenanceWindowRepeatIntervalValues() []string { 76 | return []string{ 77 | "never", 78 | "1d", 79 | "1w", 80 | "2w", 81 | "1m", 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /model_maintenance_window_response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // MaintenanceWindowResponse struct for MaintenanceWindowResponse 37 | type MaintenanceWindowResponse struct { 38 | Data MaintenanceWindow `json:"data"` 39 | } 40 | 41 | // NewMaintenanceWindowResponse instantiates a new MaintenanceWindowResponse object. 42 | // This constructor will assign default values to properties that have it 43 | // defined, and makes sure properties required by API are set, but the set of 44 | // arguments will change when the set of required properties is changed. 45 | func NewMaintenanceWindowResponse(data MaintenanceWindow) *MaintenanceWindowResponse { 46 | return &MaintenanceWindowResponse{ 47 | Data: data, 48 | } 49 | } 50 | 51 | // MarshalJSON serialises data in the struct to JSON. 52 | func (o MaintenanceWindowResponse) MarshalJSON() ([]byte, error) { 53 | toSerialize := map[string]interface{}{} 54 | if true { 55 | toSerialize["data"] = o.Data 56 | } 57 | return json.Marshal(toSerialize) 58 | } 59 | -------------------------------------------------------------------------------- /model_maintenance_window_state.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // MaintenanceWindowState Maintenance window state 38 | type MaintenanceWindowState string 39 | 40 | const ( 41 | // MaintenanceWindowStateActive a maintenance window in an active state. 42 | MaintenanceWindowStateActive MaintenanceWindowState = "active" 43 | // MaintenanceWindowStatePaused a maintenance window in a paused state. 44 | MaintenanceWindowStatePaused MaintenanceWindowState = "paused" 45 | // MaintenanceWindowStatePending a maintenance window in a pending state. 46 | MaintenanceWindowStatePending MaintenanceWindowState = "pending" 47 | ) 48 | 49 | // Unmarshal JSON data into any of the pointers in the type. 50 | func (v *MaintenanceWindowState) UnmarshalJSON(src []byte) error { 51 | var value string 52 | if err := json.Unmarshal(src, &value); err != nil { 53 | return err 54 | } 55 | 56 | ev := MaintenanceWindowState(value) 57 | if !ev.Valid() { 58 | return fmt.Errorf("%+v is not a valid MaintenanceWindowState", value) 59 | } 60 | 61 | *v = ev 62 | return nil 63 | } 64 | 65 | // Valid determines if the value is valid. 66 | func (v MaintenanceWindowState) Valid() bool { 67 | return v == MaintenanceWindowStateActive || v == MaintenanceWindowStatePaused || v == MaintenanceWindowStatePending 68 | } 69 | 70 | // MaintenanceWindowStateValues returns the values of MaintenanceWindowState. 71 | func MaintenanceWindowStateValues() []string { 72 | return []string{ 73 | "active", 74 | "paused", 75 | "pending", 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /model_maintenance_windows_.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // MaintenanceWindows struct for MaintenanceWindows 37 | type MaintenanceWindows struct { 38 | // List of maintenance windows 39 | Data []MaintenanceWindow `json:"data"` 40 | Metadata Pagination `json:"metadata"` 41 | } 42 | 43 | // NewMaintenanceWindows instantiates a new MaintenanceWindows object. 44 | // This constructor will assign default values to properties that have it 45 | // defined, and makes sure properties required by API are set, but the set of 46 | // arguments will change when the set of required properties is changed. 47 | func NewMaintenanceWindows(data []MaintenanceWindow, metadata Pagination) *MaintenanceWindows { 48 | return &MaintenanceWindows{ 49 | Data: data, 50 | Metadata: metadata, 51 | } 52 | } 53 | 54 | // MarshalJSON serialises data in the struct to JSON. 55 | func (o MaintenanceWindows) MarshalJSON() ([]byte, error) { 56 | toSerialize := map[string]interface{}{} 57 | if true { 58 | toSerialize["data"] = o.Data 59 | } 60 | if true { 61 | toSerialize["metadata"] = o.Metadata 62 | } 63 | return json.Marshal(toSerialize) 64 | } 65 | -------------------------------------------------------------------------------- /model_monitoring_location.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // MonitoringLocation struct for MonitoringLocation 37 | type MonitoringLocation struct { 38 | // Server description 39 | Description string `json:"description"` 40 | // Server IPv4 address 41 | IPv4 *string `json:"ipv4,omitempty"` 42 | // Server IPv6 address 43 | IPv6 *string `json:"ipv6,omitempty"` 44 | // Server region 45 | Region string `json:"region"` 46 | // Server region code 47 | RegionCode string `json:"region_code"` 48 | Status MonitoringLocationStatus `json:"status"` 49 | } 50 | 51 | // NewMonitoringLocation instantiates a new MonitoringLocation object. 52 | // This constructor will assign default values to properties that have it 53 | // defined, and makes sure properties required by API are set, but the set of 54 | // arguments will change when the set of required properties is changed. 55 | func NewMonitoringLocation(description string, region string, regionCode string, status MonitoringLocationStatus) *MonitoringLocation { 56 | return &MonitoringLocation{ 57 | Description: description, 58 | Region: region, 59 | RegionCode: regionCode, 60 | Status: status, 61 | } 62 | } 63 | 64 | // MarshalJSON serialises data in the struct to JSON. 65 | func (o MonitoringLocation) MarshalJSON() ([]byte, error) { 66 | toSerialize := map[string]interface{}{} 67 | if true { 68 | toSerialize["description"] = o.Description 69 | } 70 | if o.IPv4 != nil { 71 | toSerialize["ipv4"] = o.IPv4 72 | } 73 | if o.IPv6 != nil { 74 | toSerialize["ipv6"] = o.IPv6 75 | } 76 | if true { 77 | toSerialize["region"] = o.Region 78 | } 79 | if true { 80 | toSerialize["region_code"] = o.RegionCode 81 | } 82 | if true { 83 | toSerialize["status"] = o.Status 84 | } 85 | return json.Marshal(toSerialize) 86 | } 87 | -------------------------------------------------------------------------------- /model_monitoring_location_status.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // MonitoringLocationStatus Server status 38 | type MonitoringLocationStatus string 39 | 40 | const ( 41 | // MonitoringLocationStatusDown a monitoring location with a down status. 42 | MonitoringLocationStatusDown MonitoringLocationStatus = "down" 43 | // MonitoringLocationStatusUp a monitoring location with an up status. 44 | MonitoringLocationStatusUp MonitoringLocationStatus = "up" 45 | ) 46 | 47 | // Unmarshal JSON data into any of the pointers in the type. 48 | func (v *MonitoringLocationStatus) UnmarshalJSON(src []byte) error { 49 | var value string 50 | if err := json.Unmarshal(src, &value); err != nil { 51 | return err 52 | } 53 | 54 | ev := MonitoringLocationStatus(value) 55 | if !ev.Valid() { 56 | return fmt.Errorf("%+v is not a valid MonitoringLocationStatus", value) 57 | } 58 | 59 | *v = ev 60 | return nil 61 | } 62 | 63 | // Valid determines if the value is valid. 64 | func (v MonitoringLocationStatus) Valid() bool { 65 | return v == MonitoringLocationStatusDown || v == MonitoringLocationStatusUp 66 | } 67 | 68 | // MonitoringLocationStatusValues returns the values of MonitoringLocationStatus. 69 | func MonitoringLocationStatusValues() []string { 70 | return []string{ 71 | "down", 72 | "up", 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /model_monitoring_locations.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // MonitoringLocations struct for MonitoringLocations 37 | type MonitoringLocations struct { 38 | // List of monitoring locations 39 | Data []MonitoringLocation `json:"data"` 40 | } 41 | 42 | // NewMonitoringLocations instantiates a new MonitoringLocations object. 43 | // This constructor will assign default values to properties that have it 44 | // defined, and makes sure properties required by API are set, but the set of 45 | // arguments will change when the set of required properties is changed. 46 | func NewMonitoringLocations(data []MonitoringLocation) *MonitoringLocations { 47 | return &MonitoringLocations{ 48 | Data: data, 49 | } 50 | } 51 | 52 | // MarshalJSON serialises data in the struct to JSON. 53 | func (o MonitoringLocations) MarshalJSON() ([]byte, error) { 54 | toSerialize := map[string]interface{}{} 55 | if true { 56 | toSerialize["data"] = o.Data 57 | } 58 | return json.Marshal(toSerialize) 59 | } 60 | -------------------------------------------------------------------------------- /model_pagespeed_test_.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // PagespeedTest struct for PagespeedTest 37 | type PagespeedTest struct { 38 | // Pagespeed check ID 39 | ID string `json:"id"` 40 | // Name of the check 41 | Name string `json:"name"` 42 | // URL, FQDN, or IP address of the website under test 43 | WebsiteURL string `json:"website_url"` 44 | CheckRate PagespeedTestCheckRate `json:"check_rate"` 45 | // An alert will be sent if the size of the page is larger than this value (kb). A value of 0 prevents alerts being sent. 46 | AlertBigger int32 `json:"alert_bigger"` 47 | // An alert will be sent if the load time of the page exceeds this value (ms). A value of 0 prevents alerts being sent 48 | AlertSlower int64 `json:"alert_slower"` 49 | // An alert will be sent if the size of the page is smaller than this value (kb). A value of 0 prevents alerts being sent 50 | AlertSmaller int32 `json:"alert_smaller"` 51 | // List of contact group IDs 52 | ContactGroups []string `json:"contact_groups"` 53 | LatestStats *PagespeedTestStats `json:"latest_stats,omitempty"` 54 | // Assigned monitoring location on which checks will be run 55 | Location string `json:"location"` 56 | // Whether the check should be run 57 | Paused bool `json:"paused"` 58 | } 59 | 60 | // NewPagespeedTest instantiates a new PagespeedTest object. 61 | // This constructor will assign default values to properties that have it 62 | // defined, and makes sure properties required by API are set, but the set of 63 | // arguments will change when the set of required properties is changed. 64 | func NewPagespeedTest(id string, name string, websiteUrl string, checkRate PagespeedTestCheckRate, alertBigger int32, alertSlower int64, alertSmaller int32, contactGroups []string, location string, paused bool) *PagespeedTest { 65 | return &PagespeedTest{ 66 | ID: id, 67 | Name: name, 68 | WebsiteURL: websiteUrl, 69 | CheckRate: checkRate, 70 | AlertBigger: alertBigger, 71 | AlertSlower: alertSlower, 72 | AlertSmaller: alertSmaller, 73 | ContactGroups: contactGroups, 74 | Location: location, 75 | Paused: paused, 76 | } 77 | } 78 | 79 | // MarshalJSON serialises data in the struct to JSON. 80 | func (o PagespeedTest) MarshalJSON() ([]byte, error) { 81 | toSerialize := map[string]interface{}{} 82 | if true { 83 | toSerialize["id"] = o.ID 84 | } 85 | if true { 86 | toSerialize["name"] = o.Name 87 | } 88 | if true { 89 | toSerialize["website_url"] = o.WebsiteURL 90 | } 91 | if true { 92 | toSerialize["check_rate"] = o.CheckRate 93 | } 94 | if true { 95 | toSerialize["alert_bigger"] = o.AlertBigger 96 | } 97 | if true { 98 | toSerialize["alert_slower"] = o.AlertSlower 99 | } 100 | if true { 101 | toSerialize["alert_smaller"] = o.AlertSmaller 102 | } 103 | if true { 104 | toSerialize["contact_groups"] = o.ContactGroups 105 | } 106 | if o.LatestStats != nil { 107 | toSerialize["latest_stats"] = o.LatestStats 108 | } 109 | if true { 110 | toSerialize["location"] = o.Location 111 | } 112 | if true { 113 | toSerialize["paused"] = o.Paused 114 | } 115 | return json.Marshal(toSerialize) 116 | } 117 | -------------------------------------------------------------------------------- /model_pagespeed_test_check_rate.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // PagespeedTestCheckRate Number of seconds between checks 38 | type PagespeedTestCheckRate int32 39 | 40 | const ( 41 | // PagespeedTestCheckRateOneMinute a check rate of 1 minute. 42 | PagespeedTestCheckRateOneMinute PagespeedTestCheckRate = 60 43 | // PagespeedTestCheckRateFiveMinutes a check rate of 5 minutes. 44 | PagespeedTestCheckRateFiveMinutes PagespeedTestCheckRate = 300 45 | // PagespeedTestCheckRateTenMinutes a check rate of 10 minutes. 46 | PagespeedTestCheckRateTenMinutes PagespeedTestCheckRate = 600 47 | // PagespeedTestCheckRateFifteenMinutes a check rate of 15 minutes. 48 | PagespeedTestCheckRateFifteenMinutes PagespeedTestCheckRate = 900 49 | // PagespeedTestCheckRateThirtyMinutes a check rate of 30 minutes. 50 | PagespeedTestCheckRateThirtyMinutes PagespeedTestCheckRate = 1800 51 | // PagespeedTestCheckRateOneHour a check rate of 1 hour. 52 | PagespeedTestCheckRateOneHour PagespeedTestCheckRate = 3600 53 | // PagespeedTestCheckRateOneDay a check rate of 1 day. 54 | PagespeedTestCheckRateOneDay PagespeedTestCheckRate = 86400 55 | ) 56 | 57 | // Unmarshal JSON data into any of the pointers in the type. 58 | func (v *PagespeedTestCheckRate) UnmarshalJSON(src []byte) error { 59 | var value int32 60 | if err := json.Unmarshal(src, &value); err != nil { 61 | return err 62 | } 63 | 64 | ev := PagespeedTestCheckRate(value) 65 | if !ev.Valid() { 66 | return fmt.Errorf("%+v is not a valid PagespeedTestCheckRate", value) 67 | } 68 | 69 | *v = ev 70 | return nil 71 | } 72 | 73 | // Valid determines if the value is valid. 74 | func (v PagespeedTestCheckRate) Valid() bool { 75 | return v == PagespeedTestCheckRateOneMinute || v == PagespeedTestCheckRateFiveMinutes || v == PagespeedTestCheckRateTenMinutes || v == PagespeedTestCheckRateFifteenMinutes || v == PagespeedTestCheckRateThirtyMinutes || v == PagespeedTestCheckRateOneHour || v == PagespeedTestCheckRateOneDay 76 | } 77 | 78 | // PagespeedTestCheckRateValues returns the values of PagespeedTestCheckRate. 79 | func PagespeedTestCheckRateValues() []int32 { 80 | return []int32{ 81 | 60, 82 | 300, 83 | 600, 84 | 900, 85 | 1800, 86 | 3600, 87 | 86400, 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /model_pagespeed_test_history.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // PagespeedTestHistory struct for PagespeedTestHistory 37 | type PagespeedTestHistory struct { 38 | // List of pagespeed check history results 39 | Data []PagespeedTestHistoryResult `json:"data"` 40 | Links Links `json:"links"` 41 | Metadata map[string]interface{} `json:"metadata,omitempty"` 42 | } 43 | 44 | // NewPagespeedTestHistory instantiates a new PagespeedTestHistory object. 45 | // This constructor will assign default values to properties that have it 46 | // defined, and makes sure properties required by API are set, but the set of 47 | // arguments will change when the set of required properties is changed. 48 | func NewPagespeedTestHistory(data []PagespeedTestHistoryResult, links Links) *PagespeedTestHistory { 49 | return &PagespeedTestHistory{ 50 | Data: data, 51 | Links: links, 52 | } 53 | } 54 | 55 | // MarshalJSON serialises data in the struct to JSON. 56 | func (o PagespeedTestHistory) MarshalJSON() ([]byte, error) { 57 | toSerialize := map[string]interface{}{} 58 | if true { 59 | toSerialize["data"] = o.Data 60 | } 61 | if true { 62 | toSerialize["links"] = o.Links 63 | } 64 | if o.Metadata != nil { 65 | toSerialize["metadata"] = o.Metadata 66 | } 67 | return json.Marshal(toSerialize) 68 | } 69 | -------------------------------------------------------------------------------- /model_pagespeed_test_history_result.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "time" 35 | ) 36 | 37 | // PagespeedTestHistoryResult struct for PagespeedTestHistoryResult 38 | type PagespeedTestHistoryResult struct { 39 | // Creation time of the result (RFC3339 format) 40 | Created time.Time `json:"created_at"` 41 | // Recorded filesize (kb) 42 | Filesize float32 `json:"filesize"` 43 | // Location of the saved HAR file 44 | HARLocation string `json:"har_location"` 45 | // Recorded loadtime (ms) 46 | Loadtime int64 `json:"loadtime"` 47 | // Recorded request count 48 | Requests int32 `json:"requests"` 49 | Throttling PagespeedTestThrottling `json:"throttling"` 50 | } 51 | 52 | // NewPagespeedTestHistoryResult instantiates a new PagespeedTestHistoryResult object. 53 | // This constructor will assign default values to properties that have it 54 | // defined, and makes sure properties required by API are set, but the set of 55 | // arguments will change when the set of required properties is changed. 56 | func NewPagespeedTestHistoryResult(createdAt time.Time, filesize float32, harLocation string, loadtime int64, requests int32, throttling PagespeedTestThrottling) *PagespeedTestHistoryResult { 57 | return &PagespeedTestHistoryResult{ 58 | Created: createdAt, 59 | Filesize: filesize, 60 | HARLocation: harLocation, 61 | Loadtime: loadtime, 62 | Requests: requests, 63 | Throttling: throttling, 64 | } 65 | } 66 | 67 | // MarshalJSON serialises data in the struct to JSON. 68 | func (o PagespeedTestHistoryResult) MarshalJSON() ([]byte, error) { 69 | toSerialize := map[string]interface{}{} 70 | if true { 71 | toSerialize["created_at"] = o.Created 72 | } 73 | if true { 74 | toSerialize["filesize"] = o.Filesize 75 | } 76 | if true { 77 | toSerialize["har_location"] = o.HARLocation 78 | } 79 | if true { 80 | toSerialize["loadtime"] = o.Loadtime 81 | } 82 | if true { 83 | toSerialize["requests"] = o.Requests 84 | } 85 | if true { 86 | toSerialize["throttling"] = o.Throttling 87 | } 88 | return json.Marshal(toSerialize) 89 | } 90 | -------------------------------------------------------------------------------- /model_pagespeed_test_region.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // PagespeedTestRegion Testing regions 38 | type PagespeedTestRegion string 39 | 40 | const ( 41 | // PagespeedTestRegionAustralia a testing region based in Australia. 42 | PagespeedTestRegionAustralia PagespeedTestRegion = "AU" 43 | // PagespeedTestRegionCanada a testing region based in Canada. 44 | PagespeedTestRegionCanada PagespeedTestRegion = "CA" 45 | // PagespeedTestRegionGermany a testing region based in Germany. 46 | PagespeedTestRegionGermany PagespeedTestRegion = "DE" 47 | // PagespeedTestRegionFrance a testing region based in France. 48 | PagespeedTestRegionFrance PagespeedTestRegion = "FR" 49 | // PagespeedTestRegionIndia a testing region based in India. 50 | PagespeedTestRegionIndia PagespeedTestRegion = "IN" 51 | // PagespeedTestRegionJapan a testing region based in Japan. 52 | PagespeedTestRegionJapan PagespeedTestRegion = "JP" 53 | // PagespeedTestRegionNetherlands a testing region based in the Netherlands. 54 | PagespeedTestRegionNetherlands PagespeedTestRegion = "NL" 55 | // PagespeedTestRegionSingapore a testing region based in Singapore. 56 | PagespeedTestRegionSingapore PagespeedTestRegion = "SG" 57 | // PagespeedTestRegionUnitedKingdom a testing region based in the United Kingdom. 58 | PagespeedTestRegionUnitedKingdom PagespeedTestRegion = "UK" 59 | // PagespeedTestRegionAmericaEast a testing region based in the United States of America (East). 60 | PagespeedTestRegionAmericaEast PagespeedTestRegion = "US" 61 | // PagespeedTestRegionAmericaWest a testing region based in the United States of America (West). 62 | PagespeedTestRegionAmericaWest PagespeedTestRegion = "USW" 63 | ) 64 | 65 | // Unmarshal JSON data into any of the pointers in the type. 66 | func (v *PagespeedTestRegion) UnmarshalJSON(src []byte) error { 67 | var value string 68 | if err := json.Unmarshal(src, &value); err != nil { 69 | return err 70 | } 71 | 72 | ev := PagespeedTestRegion(value) 73 | if !ev.Valid() { 74 | return fmt.Errorf("%+v is not a valid PagespeedTestRegion", value) 75 | } 76 | 77 | *v = ev 78 | return nil 79 | } 80 | 81 | // Valid determines if the value is valid. 82 | func (v PagespeedTestRegion) Valid() bool { 83 | return v == PagespeedTestRegionAustralia || v == PagespeedTestRegionCanada || v == PagespeedTestRegionGermany || v == PagespeedTestRegionFrance || v == PagespeedTestRegionIndia || v == PagespeedTestRegionJapan || v == PagespeedTestRegionNetherlands || v == PagespeedTestRegionSingapore || v == PagespeedTestRegionUnitedKingdom || v == PagespeedTestRegionAmericaEast || v == PagespeedTestRegionAmericaWest 84 | } 85 | 86 | // PagespeedTestRegionValues returns the values of PagespeedTestRegion. 87 | func PagespeedTestRegionValues() []string { 88 | return []string{ 89 | "AU", 90 | "CA", 91 | "DE", 92 | "FR", 93 | "IN", 94 | "JP", 95 | "NL", 96 | "SG", 97 | "UK", 98 | "US", 99 | "USW", 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /model_pagespeed_test_response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // PagespeedTestResponse struct for PagespeedTestResponse 37 | type PagespeedTestResponse struct { 38 | Data PagespeedTest `json:"data"` 39 | } 40 | 41 | // NewPagespeedTestResponse instantiates a new PagespeedTestResponse object. 42 | // This constructor will assign default values to properties that have it 43 | // defined, and makes sure properties required by API are set, but the set of 44 | // arguments will change when the set of required properties is changed. 45 | func NewPagespeedTestResponse(data PagespeedTest) *PagespeedTestResponse { 46 | return &PagespeedTestResponse{ 47 | Data: data, 48 | } 49 | } 50 | 51 | // MarshalJSON serialises data in the struct to JSON. 52 | func (o PagespeedTestResponse) MarshalJSON() ([]byte, error) { 53 | toSerialize := map[string]interface{}{} 54 | if true { 55 | toSerialize["data"] = o.Data 56 | } 57 | return json.Marshal(toSerialize) 58 | } 59 | -------------------------------------------------------------------------------- /model_pagespeed_test_stats.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // PagespeedTestStats struct for PagespeedTestStats 37 | type PagespeedTestStats struct { 38 | // Latest recorded filesize (kb) 39 | Filesize float32 `json:"filesize"` 40 | // Whether the latest check has an issue 41 | HasIssue bool `json:"has_issue"` 42 | // Latest recorded loadtime (ms) 43 | Loadtime int32 `json:"loadtime"` 44 | // Latest recorded request count 45 | Requests int32 `json:"requests"` 46 | // Latest recorded issue 47 | LatestIssue *string `json:"latest_issue,omitempty"` 48 | } 49 | 50 | // NewPagespeedTestStats instantiates a new PagespeedTestStats object. 51 | // This constructor will assign default values to properties that have it 52 | // defined, and makes sure properties required by API are set, but the set of 53 | // arguments will change when the set of required properties is changed. 54 | func NewPagespeedTestStats(filesize float32, hasIssue bool, loadtime int32, requests int32) *PagespeedTestStats { 55 | return &PagespeedTestStats{ 56 | Filesize: filesize, 57 | HasIssue: hasIssue, 58 | Loadtime: loadtime, 59 | Requests: requests, 60 | } 61 | } 62 | 63 | // MarshalJSON serialises data in the struct to JSON. 64 | func (o PagespeedTestStats) MarshalJSON() ([]byte, error) { 65 | toSerialize := map[string]interface{}{} 66 | if true { 67 | toSerialize["filesize"] = o.Filesize 68 | } 69 | if true { 70 | toSerialize["has_issue"] = o.HasIssue 71 | } 72 | if true { 73 | toSerialize["loadtime"] = o.Loadtime 74 | } 75 | if true { 76 | toSerialize["requests"] = o.Requests 77 | } 78 | if o.LatestIssue != nil { 79 | toSerialize["latest_issue"] = o.LatestIssue 80 | } 81 | return json.Marshal(toSerialize) 82 | } 83 | -------------------------------------------------------------------------------- /model_pagespeed_test_throttling.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // PagespeedTestThrottling Simulated throttling speed 38 | type PagespeedTestThrottling string 39 | 40 | const ( 41 | // PagespeedTestThrottlingNone no throttling. 42 | PagespeedTestThrottlingNone PagespeedTestThrottling = "NONE" 43 | // PagespeedTestThrottlingFast3G fast 3G. 44 | PagespeedTestThrottlingFast3G PagespeedTestThrottling = "3G_FAST" 45 | // PagespeedTestThrottlingSlow3G slow 3G. 46 | PagespeedTestThrottlingSlow3G PagespeedTestThrottling = "3G_SLOW" 47 | // PagespeedTestThrottling4G 4G. 48 | PagespeedTestThrottling4G PagespeedTestThrottling = "4G" 49 | // PagespeedTestThrottlingEDGE EDGE. 50 | PagespeedTestThrottlingEDGE PagespeedTestThrottling = "EDGE" 51 | // PagespeedTestThrottlingGPRS GPRS. 52 | PagespeedTestThrottlingGPRS PagespeedTestThrottling = "GPRS" 53 | ) 54 | 55 | // Unmarshal JSON data into any of the pointers in the type. 56 | func (v *PagespeedTestThrottling) UnmarshalJSON(src []byte) error { 57 | var value string 58 | if err := json.Unmarshal(src, &value); err != nil { 59 | return err 60 | } 61 | 62 | ev := PagespeedTestThrottling(value) 63 | if !ev.Valid() { 64 | return fmt.Errorf("%+v is not a valid PagespeedTestThrottling", value) 65 | } 66 | 67 | *v = ev 68 | return nil 69 | } 70 | 71 | // Valid determines if the value is valid. 72 | func (v PagespeedTestThrottling) Valid() bool { 73 | return v == PagespeedTestThrottlingNone || v == PagespeedTestThrottlingFast3G || v == PagespeedTestThrottlingSlow3G || v == PagespeedTestThrottling4G || v == PagespeedTestThrottlingEDGE || v == PagespeedTestThrottlingGPRS 74 | } 75 | 76 | // PagespeedTestThrottlingValues returns the values of PagespeedTestThrottling. 77 | func PagespeedTestThrottlingValues() []string { 78 | return []string{ 79 | "NONE", 80 | "3G_FAST", 81 | "3G_SLOW", 82 | "4G", 83 | "EDGE", 84 | "GPRS", 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /model_pagespeed_tests.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // PagespeedTests struct for PagespeedTests 37 | type PagespeedTests struct { 38 | // List of pagespeed checks 39 | Data []PagespeedTest `json:"data"` 40 | Metadata Pagination `json:"metadata"` 41 | } 42 | 43 | // NewPagespeedTests instantiates a new PagespeedTests object. 44 | // This constructor will assign default values to properties that have it 45 | // defined, and makes sure properties required by API are set, but the set of 46 | // arguments will change when the set of required properties is changed. 47 | func NewPagespeedTests(data []PagespeedTest, metadata Pagination) *PagespeedTests { 48 | return &PagespeedTests{ 49 | Data: data, 50 | Metadata: metadata, 51 | } 52 | } 53 | 54 | // MarshalJSON serialises data in the struct to JSON. 55 | func (o PagespeedTests) MarshalJSON() ([]byte, error) { 56 | toSerialize := map[string]interface{}{} 57 | if true { 58 | toSerialize["data"] = o.Data 59 | } 60 | if true { 61 | toSerialize["metadata"] = o.Metadata 62 | } 63 | return json.Marshal(toSerialize) 64 | } 65 | -------------------------------------------------------------------------------- /model_pagination.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // Pagination struct for Pagination 37 | type Pagination struct { 38 | // The current page of results 39 | Page int32 `json:"page"` 40 | // The number of results per page 41 | PerPage int32 `json:"per_page"` 42 | // The total number of pages 43 | PageCount int32 `json:"page_count"` 44 | // The total number of results 45 | TotalCount int32 `json:"total_count"` 46 | } 47 | 48 | // NewPagination instantiates a new Pagination object. 49 | // This constructor will assign default values to properties that have it 50 | // defined, and makes sure properties required by API are set, but the set of 51 | // arguments will change when the set of required properties is changed. 52 | func NewPagination(page int32, perPage int32, pageCount int32, totalCount int32) *Pagination { 53 | return &Pagination{ 54 | Page: page, 55 | PerPage: perPage, 56 | PageCount: pageCount, 57 | TotalCount: totalCount, 58 | } 59 | } 60 | 61 | // MarshalJSON serialises data in the struct to JSON. 62 | func (o Pagination) MarshalJSON() ([]byte, error) { 63 | toSerialize := map[string]interface{}{} 64 | if true { 65 | toSerialize["page"] = o.Page 66 | } 67 | if true { 68 | toSerialize["per_page"] = o.PerPage 69 | } 70 | if true { 71 | toSerialize["page_count"] = o.PageCount 72 | } 73 | if true { 74 | toSerialize["total_count"] = o.TotalCount 75 | } 76 | return json.Marshal(toSerialize) 77 | } 78 | -------------------------------------------------------------------------------- /model_ssl_test_.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "time" 35 | ) 36 | 37 | // SSLTest struct for SSLTest 38 | type SSLTest struct { 39 | // SSL check ID 40 | ID string `json:"id"` 41 | // URL of the server under test 42 | WebsiteURL string `json:"website_url"` 43 | CheckRate SSLTestCheckRate `json:"check_rate"` 44 | // List representing when alerts should be sent (days). 45 | AlertAt []int32 `json:"alert_at"` 46 | // Whether to enable alerts when SSL certificate issues are found 47 | AlertBroken bool `json:"alert_broken"` 48 | // Whether to enable alerts when the SSL certificate is to expire 49 | AlertExpiry bool `json:"alert_expiry"` 50 | // Whether to enable alerts when mixed content is found 51 | AlertMixed bool `json:"alert_mixed"` 52 | // Whether to enable alert reminders 53 | AlertReminder bool `json:"alert_reminder"` 54 | // SSL certificate score (%) 55 | CertificateScore *int32 `json:"certificate_score,omitempty"` 56 | // SSL certificate status 57 | CertificateStatus *string `json:"certificate_status,omitempty"` 58 | // SSL/TLS cipher suite belonging to the SSL certificate 59 | Cipher *string `json:"cipher,omitempty"` 60 | // SSL certificate cipher strength (%) 61 | CipherScore *int32 `json:"cipher_score,omitempty"` 62 | // List of contact group IDs 63 | ContactGroups []string `json:"contact_groups"` 64 | // Issuer of the SSL certificate 65 | IssuerCommonName *string `json:"issuer_common_name,omitempty"` 66 | Flags *SSLTestFlags `json:"flags,omitempty"` 67 | // Whether to follow redirects when testing. Disabled by default 68 | FollowRedirects bool `json:"follow_redirects"` 69 | // Hostname of the server under test 70 | Hostname *string `json:"hostname,omitempty"` 71 | // The last reminder to have been sent (days) 72 | LastReminder *int32 `json:"last_reminder,omitempty"` 73 | // List of mixed content resources 74 | MixedContent []SSLTestMixedContent `json:"mixed_content"` 75 | // Whether the check should be run 76 | Paused bool `json:"paused"` 77 | // When the SSL certificate was last updated (RFC3339 format) 78 | Updated *time.Time `json:"updated_at,omitempty"` 79 | // Custom user agent string set when testing 80 | UserAgent *string `json:"user_agent,omitempty"` 81 | // SSL certificate validity start (RFC3339 format) 82 | ValidFrom *time.Time `json:"valid_from,omitempty"` 83 | // SSL certificate validity end (RFC3339 format) 84 | ValidUntil *time.Time `json:"valid_until,omitempty"` 85 | } 86 | 87 | // NewSSLTest instantiates a new SSLTest object. 88 | // This constructor will assign default values to properties that have it 89 | // defined, and makes sure properties required by API are set, but the set of 90 | // arguments will change when the set of required properties is changed. 91 | func NewSSLTest(id string, websiteUrl string, checkRate SSLTestCheckRate, alertAt []int32, alertBroken bool, alertExpiry bool, alertMixed bool, alertReminder bool, contactGroups []string, followRedirects bool, mixedContent []SSLTestMixedContent, paused bool) *SSLTest { 92 | return &SSLTest{ 93 | ID: id, 94 | WebsiteURL: websiteUrl, 95 | CheckRate: checkRate, 96 | AlertAt: alertAt, 97 | AlertBroken: alertBroken, 98 | AlertExpiry: alertExpiry, 99 | AlertMixed: alertMixed, 100 | AlertReminder: alertReminder, 101 | ContactGroups: contactGroups, 102 | FollowRedirects: followRedirects, 103 | MixedContent: mixedContent, 104 | Paused: paused, 105 | } 106 | } 107 | 108 | // MarshalJSON serialises data in the struct to JSON. 109 | func (o SSLTest) MarshalJSON() ([]byte, error) { 110 | toSerialize := map[string]interface{}{} 111 | if true { 112 | toSerialize["id"] = o.ID 113 | } 114 | if true { 115 | toSerialize["website_url"] = o.WebsiteURL 116 | } 117 | if true { 118 | toSerialize["check_rate"] = o.CheckRate 119 | } 120 | if true { 121 | toSerialize["alert_at"] = o.AlertAt 122 | } 123 | if true { 124 | toSerialize["alert_broken"] = o.AlertBroken 125 | } 126 | if true { 127 | toSerialize["alert_expiry"] = o.AlertExpiry 128 | } 129 | if true { 130 | toSerialize["alert_mixed"] = o.AlertMixed 131 | } 132 | if true { 133 | toSerialize["alert_reminder"] = o.AlertReminder 134 | } 135 | if o.CertificateScore != nil { 136 | toSerialize["certificate_score"] = o.CertificateScore 137 | } 138 | if o.CertificateStatus != nil { 139 | toSerialize["certificate_status"] = o.CertificateStatus 140 | } 141 | if o.Cipher != nil { 142 | toSerialize["cipher"] = o.Cipher 143 | } 144 | if o.CipherScore != nil { 145 | toSerialize["cipher_score"] = o.CipherScore 146 | } 147 | if true { 148 | toSerialize["contact_groups"] = o.ContactGroups 149 | } 150 | if o.IssuerCommonName != nil { 151 | toSerialize["issuer_common_name"] = o.IssuerCommonName 152 | } 153 | if o.Flags != nil { 154 | toSerialize["flags"] = o.Flags 155 | } 156 | if true { 157 | toSerialize["follow_redirects"] = o.FollowRedirects 158 | } 159 | if o.Hostname != nil { 160 | toSerialize["hostname"] = o.Hostname 161 | } 162 | if o.LastReminder != nil { 163 | toSerialize["last_reminder"] = o.LastReminder 164 | } 165 | if true { 166 | toSerialize["mixed_content"] = o.MixedContent 167 | } 168 | if true { 169 | toSerialize["paused"] = o.Paused 170 | } 171 | if o.Updated != nil { 172 | toSerialize["updated_at"] = o.Updated 173 | } 174 | if o.UserAgent != nil { 175 | toSerialize["user_agent"] = o.UserAgent 176 | } 177 | if o.ValidFrom != nil { 178 | toSerialize["valid_from"] = o.ValidFrom 179 | } 180 | if o.ValidUntil != nil { 181 | toSerialize["valid_until"] = o.ValidUntil 182 | } 183 | return json.Marshal(toSerialize) 184 | } 185 | -------------------------------------------------------------------------------- /model_ssl_test_check_rate.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // SSLTestCheckRate Number of seconds between checks 38 | type SSLTestCheckRate int32 39 | 40 | const ( 41 | // SSLTestCheckRateFiveMinutes a check rate of 5 minutes. 42 | SSLTestCheckRateFiveMinutes SSLTestCheckRate = 300 43 | // SSLTestCheckRateTenMinutes a check rate of 10 minutes. 44 | SSLTestCheckRateTenMinutes SSLTestCheckRate = 600 45 | // SSLTestCheckRateThirtyMinutes a check rate of 30 minutes. 46 | SSLTestCheckRateThirtyMinutes SSLTestCheckRate = 1800 47 | // SSLTestCheckRateOneHour a check rate of 1 hour. 48 | SSLTestCheckRateOneHour SSLTestCheckRate = 3600 49 | // SSLTestCheckRateOneDay a check rate of 1 day. 50 | SSLTestCheckRateOneDay SSLTestCheckRate = 86400 51 | // SSLTestCheckRateOneWeek a check rate of 1 week. 52 | SSLTestCheckRateOneWeek SSLTestCheckRate = 2073600 53 | ) 54 | 55 | // Unmarshal JSON data into any of the pointers in the type. 56 | func (v *SSLTestCheckRate) UnmarshalJSON(src []byte) error { 57 | var value int32 58 | if err := json.Unmarshal(src, &value); err != nil { 59 | return err 60 | } 61 | 62 | ev := SSLTestCheckRate(value) 63 | if !ev.Valid() { 64 | return fmt.Errorf("%+v is not a valid SSLTestCheckRate", value) 65 | } 66 | 67 | *v = ev 68 | return nil 69 | } 70 | 71 | // Valid determines if the value is valid. 72 | func (v SSLTestCheckRate) Valid() bool { 73 | return v == SSLTestCheckRateFiveMinutes || v == SSLTestCheckRateTenMinutes || v == SSLTestCheckRateThirtyMinutes || v == SSLTestCheckRateOneHour || v == SSLTestCheckRateOneDay || v == SSLTestCheckRateOneWeek 74 | } 75 | 76 | // SSLTestCheckRateValues returns the values of SSLTestCheckRate. 77 | func SSLTestCheckRateValues() []int32 { 78 | return []int32{ 79 | 300, 80 | 600, 81 | 1800, 82 | 3600, 83 | 86400, 84 | 2073600, 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /model_ssl_test_flags.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // SSLTestFlags struct for SSLTestFlags 37 | type SSLTestFlags struct { 38 | // Wherher follow redirects has been enabled for the SSL check 39 | FollowRedirects bool `json:"follow_redirects"` 40 | // Whether the requested page has mixed content 41 | HasMixed bool `json:"has_mixed"` 42 | // Whether the SSL certificate has Perfect Forward Security enabled 43 | HasPFS bool `json:"has_pfs"` 44 | // Whether the SSL certificate has errors 45 | IsBroken bool `json:"is_broken"` 46 | // Whether the SSL certificate has expired 47 | IsExpired bool `json:"is_expired"` 48 | // Whether the SSL certificate has Extended Validation (EV) 49 | IsExtended bool `json:"is_extended"` 50 | // Whether the SSL certificate is missing 51 | IsMissing bool `json:"is_missing"` 52 | // Whether the SSL certificate has been revoked by the certificate authority 53 | IsRevoked bool `json:"is_revoked"` 54 | } 55 | 56 | // NewSSLTestFlags instantiates a new SSLTestFlags object. 57 | // This constructor will assign default values to properties that have it 58 | // defined, and makes sure properties required by API are set, but the set of 59 | // arguments will change when the set of required properties is changed. 60 | func NewSSLTestFlags(followRedirects bool, hasMixed bool, hasPfs bool, isBroken bool, isExpired bool, isExtended bool, isMissing bool, isRevoked bool) *SSLTestFlags { 61 | return &SSLTestFlags{ 62 | FollowRedirects: followRedirects, 63 | HasMixed: hasMixed, 64 | HasPFS: hasPfs, 65 | IsBroken: isBroken, 66 | IsExpired: isExpired, 67 | IsExtended: isExtended, 68 | IsMissing: isMissing, 69 | IsRevoked: isRevoked, 70 | } 71 | } 72 | 73 | // MarshalJSON serialises data in the struct to JSON. 74 | func (o SSLTestFlags) MarshalJSON() ([]byte, error) { 75 | toSerialize := map[string]interface{}{} 76 | if true { 77 | toSerialize["follow_redirects"] = o.FollowRedirects 78 | } 79 | if true { 80 | toSerialize["has_mixed"] = o.HasMixed 81 | } 82 | if true { 83 | toSerialize["has_pfs"] = o.HasPFS 84 | } 85 | if true { 86 | toSerialize["is_broken"] = o.IsBroken 87 | } 88 | if true { 89 | toSerialize["is_expired"] = o.IsExpired 90 | } 91 | if true { 92 | toSerialize["is_extended"] = o.IsExtended 93 | } 94 | if true { 95 | toSerialize["is_missing"] = o.IsMissing 96 | } 97 | if true { 98 | toSerialize["is_revoked"] = o.IsRevoked 99 | } 100 | return json.Marshal(toSerialize) 101 | } 102 | -------------------------------------------------------------------------------- /model_ssl_test_mixed_content.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // SSLTestMixedContent struct for SSLTestMixedContent 37 | type SSLTestMixedContent struct { 38 | // Full path to the content resource 39 | URL string `json:"src"` 40 | // Type of the content 41 | Type string `json:"type"` 42 | } 43 | 44 | // NewSSLTestMixedContent instantiates a new SSLTestMixedContent object. 45 | // This constructor will assign default values to properties that have it 46 | // defined, and makes sure properties required by API are set, but the set of 47 | // arguments will change when the set of required properties is changed. 48 | func NewSSLTestMixedContent(src string, type_ string) *SSLTestMixedContent { 49 | return &SSLTestMixedContent{ 50 | URL: src, 51 | Type: type_, 52 | } 53 | } 54 | 55 | // MarshalJSON serialises data in the struct to JSON. 56 | func (o SSLTestMixedContent) MarshalJSON() ([]byte, error) { 57 | toSerialize := map[string]interface{}{} 58 | if true { 59 | toSerialize["src"] = o.URL 60 | } 61 | if true { 62 | toSerialize["type"] = o.Type 63 | } 64 | return json.Marshal(toSerialize) 65 | } 66 | -------------------------------------------------------------------------------- /model_ssl_test_response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // SSLTestResponse struct for SSLTestResponse 37 | type SSLTestResponse struct { 38 | Data SSLTest `json:"data"` 39 | } 40 | 41 | // NewSSLTestResponse instantiates a new SSLTestResponse object. 42 | // This constructor will assign default values to properties that have it 43 | // defined, and makes sure properties required by API are set, but the set of 44 | // arguments will change when the set of required properties is changed. 45 | func NewSSLTestResponse(data SSLTest) *SSLTestResponse { 46 | return &SSLTestResponse{ 47 | Data: data, 48 | } 49 | } 50 | 51 | // MarshalJSON serialises data in the struct to JSON. 52 | func (o SSLTestResponse) MarshalJSON() ([]byte, error) { 53 | toSerialize := map[string]interface{}{} 54 | if true { 55 | toSerialize["data"] = o.Data 56 | } 57 | return json.Marshal(toSerialize) 58 | } 59 | -------------------------------------------------------------------------------- /model_ssl_tests.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // SSLTests struct for SSLTests 37 | type SSLTests struct { 38 | // List of SSL checks 39 | Data []SSLTest `json:"data"` 40 | Metadata Pagination `json:"metadata"` 41 | } 42 | 43 | // NewSSLTests instantiates a new SSLTests object. 44 | // This constructor will assign default values to properties that have it 45 | // defined, and makes sure properties required by API are set, but the set of 46 | // arguments will change when the set of required properties is changed. 47 | func NewSSLTests(data []SSLTest, metadata Pagination) *SSLTests { 48 | return &SSLTests{ 49 | Data: data, 50 | Metadata: metadata, 51 | } 52 | } 53 | 54 | // MarshalJSON serialises data in the struct to JSON. 55 | func (o SSLTests) MarshalJSON() ([]byte, error) { 56 | toSerialize := map[string]interface{}{} 57 | if true { 58 | toSerialize["data"] = o.Data 59 | } 60 | if true { 61 | toSerialize["metadata"] = o.Metadata 62 | } 63 | return json.Marshal(toSerialize) 64 | } 65 | -------------------------------------------------------------------------------- /model_uptime_test_alert.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "time" 35 | ) 36 | 37 | // UptimeTestAlert struct for UptimeTestAlert 38 | type UptimeTestAlert struct { 39 | // Uptime check ID 40 | ID string `json:"id"` 41 | Status UptimeTestStatus `json:"status"` 42 | // Uptime check status code 43 | StatusCode int32 `json:"status_code"` 44 | // When the alert was triggered (RFC3339 format) 45 | Triggered *time.Time `json:"triggered_at,omitempty"` 46 | } 47 | 48 | // NewUptimeTestAlert instantiates a new UptimeTestAlert object. 49 | // This constructor will assign default values to properties that have it 50 | // defined, and makes sure properties required by API are set, but the set of 51 | // arguments will change when the set of required properties is changed. 52 | func NewUptimeTestAlert(id string, status UptimeTestStatus, statusCode int32) *UptimeTestAlert { 53 | return &UptimeTestAlert{ 54 | ID: id, 55 | Status: status, 56 | StatusCode: statusCode, 57 | } 58 | } 59 | 60 | // MarshalJSON serialises data in the struct to JSON. 61 | func (o UptimeTestAlert) MarshalJSON() ([]byte, error) { 62 | toSerialize := map[string]interface{}{} 63 | if true { 64 | toSerialize["id"] = o.ID 65 | } 66 | if true { 67 | toSerialize["status"] = o.Status 68 | } 69 | if true { 70 | toSerialize["status_code"] = o.StatusCode 71 | } 72 | if o.Triggered != nil { 73 | toSerialize["triggered_at"] = o.Triggered 74 | } 75 | return json.Marshal(toSerialize) 76 | } 77 | -------------------------------------------------------------------------------- /model_uptime_test_alerts.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // UptimeTestAlerts struct for UptimeTestAlerts 37 | type UptimeTestAlerts struct { 38 | // List of uptime check alerts 39 | Data []UptimeTestAlert `json:"data"` 40 | Links Links `json:"links"` 41 | Metadata map[string]interface{} `json:"metadata,omitempty"` 42 | } 43 | 44 | // NewUptimeTestAlerts instantiates a new UptimeTestAlerts object. 45 | // This constructor will assign default values to properties that have it 46 | // defined, and makes sure properties required by API are set, but the set of 47 | // arguments will change when the set of required properties is changed. 48 | func NewUptimeTestAlerts(data []UptimeTestAlert, links Links) *UptimeTestAlerts { 49 | return &UptimeTestAlerts{ 50 | Data: data, 51 | Links: links, 52 | } 53 | } 54 | 55 | // MarshalJSON serialises data in the struct to JSON. 56 | func (o UptimeTestAlerts) MarshalJSON() ([]byte, error) { 57 | toSerialize := map[string]interface{}{} 58 | if true { 59 | toSerialize["data"] = o.Data 60 | } 61 | if true { 62 | toSerialize["links"] = o.Links 63 | } 64 | if o.Metadata != nil { 65 | toSerialize["metadata"] = o.Metadata 66 | } 67 | return json.Marshal(toSerialize) 68 | } 69 | -------------------------------------------------------------------------------- /model_uptime_test_check_rate.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // UptimeTestCheckRate Number of seconds between checks 38 | type UptimeTestCheckRate int32 39 | 40 | const ( 41 | // UptimeTestCheckRateConstant a constant check rate. 42 | UptimeTestCheckRateConstant UptimeTestCheckRate = 0 43 | // UptimeTestCheckRateThirtySeconds a check rate of 30 seconds. 44 | UptimeTestCheckRateThirtySeconds UptimeTestCheckRate = 30 45 | // UptimeTestCheckRateOneMinute a check rate of 1 minute. 46 | UptimeTestCheckRateOneMinute UptimeTestCheckRate = 60 47 | // UptimeTestCheckRateFiveMinutes a check rate of 5 minutes. 48 | UptimeTestCheckRateFiveMinutes UptimeTestCheckRate = 300 49 | // UptimeTestCheckRateFifteenMinutes a check rate of 15 minutes. 50 | UptimeTestCheckRateFifteenMinutes UptimeTestCheckRate = 900 51 | // UptimeTestCheckRateThirtyMinutes a check rate of 30 minutes. 52 | UptimeTestCheckRateThirtyMinutes UptimeTestCheckRate = 1800 53 | // UptimeTestCheckRateOneHour a check rate of 1 hour. 54 | UptimeTestCheckRateOneHour UptimeTestCheckRate = 3600 55 | // UptimeTestCheckRateOneDay a check rate of 1 day. 56 | UptimeTestCheckRateOneDay UptimeTestCheckRate = 86400 57 | ) 58 | 59 | // Unmarshal JSON data into any of the pointers in the type. 60 | func (v *UptimeTestCheckRate) UnmarshalJSON(src []byte) error { 61 | var value int32 62 | if err := json.Unmarshal(src, &value); err != nil { 63 | return err 64 | } 65 | 66 | ev := UptimeTestCheckRate(value) 67 | if !ev.Valid() { 68 | return fmt.Errorf("%+v is not a valid UptimeTestCheckRate", value) 69 | } 70 | 71 | *v = ev 72 | return nil 73 | } 74 | 75 | // Valid determines if the value is valid. 76 | func (v UptimeTestCheckRate) Valid() bool { 77 | return v == UptimeTestCheckRateConstant || v == UptimeTestCheckRateThirtySeconds || v == UptimeTestCheckRateOneMinute || v == UptimeTestCheckRateFiveMinutes || v == UptimeTestCheckRateFifteenMinutes || v == UptimeTestCheckRateThirtyMinutes || v == UptimeTestCheckRateOneHour || v == UptimeTestCheckRateOneDay 78 | } 79 | 80 | // UptimeTestCheckRateValues returns the values of UptimeTestCheckRate. 81 | func UptimeTestCheckRateValues() []int32 { 82 | return []int32{ 83 | 0, 84 | 30, 85 | 60, 86 | 300, 87 | 900, 88 | 1800, 89 | 3600, 90 | 86400, 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /model_uptime_test_history.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // UptimeTestHistory struct for UptimeTestHistory 37 | type UptimeTestHistory struct { 38 | // List of uptime check history results 39 | Data []UptimeTestHistoryResult `json:"data"` 40 | Links Links `json:"links"` 41 | Metadata map[string]interface{} `json:"metadata,omitempty"` 42 | } 43 | 44 | // NewUptimeTestHistory instantiates a new UptimeTestHistory object. 45 | // This constructor will assign default values to properties that have it 46 | // defined, and makes sure properties required by API are set, but the set of 47 | // arguments will change when the set of required properties is changed. 48 | func NewUptimeTestHistory(data []UptimeTestHistoryResult, links Links) *UptimeTestHistory { 49 | return &UptimeTestHistory{ 50 | Data: data, 51 | Links: links, 52 | } 53 | } 54 | 55 | // MarshalJSON serialises data in the struct to JSON. 56 | func (o UptimeTestHistory) MarshalJSON() ([]byte, error) { 57 | toSerialize := map[string]interface{}{} 58 | if true { 59 | toSerialize["data"] = o.Data 60 | } 61 | if true { 62 | toSerialize["links"] = o.Links 63 | } 64 | if o.Metadata != nil { 65 | toSerialize["metadata"] = o.Metadata 66 | } 67 | return json.Marshal(toSerialize) 68 | } 69 | -------------------------------------------------------------------------------- /model_uptime_test_history_result.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "time" 35 | ) 36 | 37 | // UptimeTestHistoryResult struct for UptimeTestHistoryResult 38 | type UptimeTestHistoryResult struct { 39 | // Creation time of the result (RFC3339 format) 40 | Created time.Time `json:"created_at"` 41 | // The server location the check ran 42 | Location *string `json:"location,omitempty"` 43 | // Recorded loadtime (ms) 44 | Performance *int64 `json:"performance,omitempty"` 45 | // Uptime check status code 46 | StatusCode *int32 `json:"status_code,omitempty"` 47 | } 48 | 49 | // NewUptimeTestHistoryResult instantiates a new UptimeTestHistoryResult object. 50 | // This constructor will assign default values to properties that have it 51 | // defined, and makes sure properties required by API are set, but the set of 52 | // arguments will change when the set of required properties is changed. 53 | func NewUptimeTestHistoryResult(createdAt time.Time) *UptimeTestHistoryResult { 54 | return &UptimeTestHistoryResult{ 55 | Created: createdAt, 56 | } 57 | } 58 | 59 | // MarshalJSON serialises data in the struct to JSON. 60 | func (o UptimeTestHistoryResult) MarshalJSON() ([]byte, error) { 61 | toSerialize := map[string]interface{}{} 62 | if true { 63 | toSerialize["created_at"] = o.Created 64 | } 65 | if o.Location != nil { 66 | toSerialize["location"] = o.Location 67 | } 68 | if o.Performance != nil { 69 | toSerialize["performance"] = o.Performance 70 | } 71 | if o.StatusCode != nil { 72 | toSerialize["status_code"] = o.StatusCode 73 | } 74 | return json.Marshal(toSerialize) 75 | } 76 | -------------------------------------------------------------------------------- /model_uptime_test_overview.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // UptimeTestOverview struct for UptimeTestOverview 37 | type UptimeTestOverview struct { 38 | // Uptime check ID 39 | ID string `json:"id"` 40 | // Name of the check 41 | Name string `json:"name"` 42 | // URL or IP address of the server under test 43 | WebsiteURL string `json:"website_url"` 44 | TestType UptimeTestType `json:"test_type"` 45 | CheckRate UptimeTestCheckRate `json:"check_rate"` 46 | // List of contact group IDs 47 | ContactGroups []string `json:"contact_groups"` 48 | // Whether the check should be run 49 | Paused bool `json:"paused"` 50 | Status UptimeTestStatus `json:"status"` 51 | // List of tags 52 | Tags []string `json:"tags"` 53 | // Uptime percentage for a check 54 | Uptime *float32 `json:"uptime,omitempty"` 55 | } 56 | 57 | // NewUptimeTestOverview instantiates a new UptimeTestOverview object. 58 | // This constructor will assign default values to properties that have it 59 | // defined, and makes sure properties required by API are set, but the set of 60 | // arguments will change when the set of required properties is changed. 61 | func NewUptimeTestOverview(id string, name string, websiteUrl string, testType UptimeTestType, checkRate UptimeTestCheckRate, contactGroups []string, paused bool, status UptimeTestStatus, tags []string) *UptimeTestOverview { 62 | return &UptimeTestOverview{ 63 | ID: id, 64 | Name: name, 65 | WebsiteURL: websiteUrl, 66 | TestType: testType, 67 | CheckRate: checkRate, 68 | ContactGroups: contactGroups, 69 | Paused: paused, 70 | Status: status, 71 | Tags: tags, 72 | } 73 | } 74 | 75 | // MarshalJSON serialises data in the struct to JSON. 76 | func (o UptimeTestOverview) MarshalJSON() ([]byte, error) { 77 | toSerialize := map[string]interface{}{} 78 | if true { 79 | toSerialize["id"] = o.ID 80 | } 81 | if true { 82 | toSerialize["name"] = o.Name 83 | } 84 | if true { 85 | toSerialize["website_url"] = o.WebsiteURL 86 | } 87 | if true { 88 | toSerialize["test_type"] = o.TestType 89 | } 90 | if true { 91 | toSerialize["check_rate"] = o.CheckRate 92 | } 93 | if true { 94 | toSerialize["contact_groups"] = o.ContactGroups 95 | } 96 | if true { 97 | toSerialize["paused"] = o.Paused 98 | } 99 | if true { 100 | toSerialize["status"] = o.Status 101 | } 102 | if true { 103 | toSerialize["tags"] = o.Tags 104 | } 105 | if o.Uptime != nil { 106 | toSerialize["uptime"] = o.Uptime 107 | } 108 | return json.Marshal(toSerialize) 109 | } 110 | -------------------------------------------------------------------------------- /model_uptime_test_period.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "time" 35 | ) 36 | 37 | // UptimeTestPeriod struct for UptimeTestPeriod 38 | type UptimeTestPeriod struct { 39 | // When the status period was created (RFC3339 format) 40 | Created time.Time `json:"created_at"` 41 | // Status period duration (ms) 42 | Duration *int64 `json:"duration,omitempty"` 43 | // When the status period ended (RFC3339 format) 44 | Ended *time.Time `json:"ended_at,omitempty"` 45 | Status UptimeTestStatus `json:"status"` 46 | } 47 | 48 | // NewUptimeTestPeriod instantiates a new UptimeTestPeriod object. 49 | // This constructor will assign default values to properties that have it 50 | // defined, and makes sure properties required by API are set, but the set of 51 | // arguments will change when the set of required properties is changed. 52 | func NewUptimeTestPeriod(createdAt time.Time, status UptimeTestStatus) *UptimeTestPeriod { 53 | return &UptimeTestPeriod{ 54 | Created: createdAt, 55 | Status: status, 56 | } 57 | } 58 | 59 | // MarshalJSON serialises data in the struct to JSON. 60 | func (o UptimeTestPeriod) MarshalJSON() ([]byte, error) { 61 | toSerialize := map[string]interface{}{} 62 | if true { 63 | toSerialize["created_at"] = o.Created 64 | } 65 | if o.Duration != nil { 66 | toSerialize["duration"] = o.Duration 67 | } 68 | if o.Ended != nil { 69 | toSerialize["ended_at"] = o.Ended 70 | } 71 | if true { 72 | toSerialize["status"] = o.Status 73 | } 74 | return json.Marshal(toSerialize) 75 | } 76 | -------------------------------------------------------------------------------- /model_uptime_test_periods.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // UptimeTestPeriods struct for UptimeTestPeriods 37 | type UptimeTestPeriods struct { 38 | // List of uptime check periods 39 | Data []UptimeTestPeriod `json:"data"` 40 | Links Links `json:"links"` 41 | Metadata map[string]interface{} `json:"metadata,omitempty"` 42 | } 43 | 44 | // NewUptimeTestPeriods instantiates a new UptimeTestPeriods object. 45 | // This constructor will assign default values to properties that have it 46 | // defined, and makes sure properties required by API are set, but the set of 47 | // arguments will change when the set of required properties is changed. 48 | func NewUptimeTestPeriods(data []UptimeTestPeriod, links Links) *UptimeTestPeriods { 49 | return &UptimeTestPeriods{ 50 | Data: data, 51 | Links: links, 52 | } 53 | } 54 | 55 | // MarshalJSON serialises data in the struct to JSON. 56 | func (o UptimeTestPeriods) MarshalJSON() ([]byte, error) { 57 | toSerialize := map[string]interface{}{} 58 | if true { 59 | toSerialize["data"] = o.Data 60 | } 61 | if true { 62 | toSerialize["links"] = o.Links 63 | } 64 | if o.Metadata != nil { 65 | toSerialize["metadata"] = o.Metadata 66 | } 67 | return json.Marshal(toSerialize) 68 | } 69 | -------------------------------------------------------------------------------- /model_uptime_test_processing_state.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // UptimeTestProcessingState Uptime check proccessing state 38 | type UptimeTestProcessingState string 39 | 40 | const ( 41 | // UptimeTestProcessingStateComplete a completed check state. 42 | UptimeTestProcessingStateComplete UptimeTestProcessingState = "complete" 43 | // UptimeTestProcessingStatePretest a pretest check state. 44 | UptimeTestProcessingStatePretest UptimeTestProcessingState = "pretest" 45 | // UptimeTestProcessingStateRetest a retest check state. 46 | UptimeTestProcessingStateRetest UptimeTestProcessingState = "retest" 47 | // UptimeTestProcessingStateUpRetest an up retest check state. 48 | UptimeTestProcessingStateUpRetest UptimeTestProcessingState = "up_retest" 49 | ) 50 | 51 | // Unmarshal JSON data into any of the pointers in the type. 52 | func (v *UptimeTestProcessingState) UnmarshalJSON(src []byte) error { 53 | var value string 54 | if err := json.Unmarshal(src, &value); err != nil { 55 | return err 56 | } 57 | 58 | ev := UptimeTestProcessingState(value) 59 | if !ev.Valid() { 60 | return fmt.Errorf("%+v is not a valid UptimeTestProcessingState", value) 61 | } 62 | 63 | *v = ev 64 | return nil 65 | } 66 | 67 | // Valid determines if the value is valid. 68 | func (v UptimeTestProcessingState) Valid() bool { 69 | return v == UptimeTestProcessingStateComplete || v == UptimeTestProcessingStatePretest || v == UptimeTestProcessingStateRetest || v == UptimeTestProcessingStateUpRetest 70 | } 71 | 72 | // UptimeTestProcessingStateValues returns the values of UptimeTestProcessingState. 73 | func UptimeTestProcessingStateValues() []string { 74 | return []string{ 75 | "complete", 76 | "pretest", 77 | "retest", 78 | "up_retest", 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /model_uptime_test_response.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // UptimeTestResponse struct for UptimeTestResponse 37 | type UptimeTestResponse struct { 38 | Data UptimeTest `json:"data"` 39 | } 40 | 41 | // NewUptimeTestResponse instantiates a new UptimeTestResponse object. 42 | // This constructor will assign default values to properties that have it 43 | // defined, and makes sure properties required by API are set, but the set of 44 | // arguments will change when the set of required properties is changed. 45 | func NewUptimeTestResponse(data UptimeTest) *UptimeTestResponse { 46 | return &UptimeTestResponse{ 47 | Data: data, 48 | } 49 | } 50 | 51 | // MarshalJSON serialises data in the struct to JSON. 52 | func (o UptimeTestResponse) MarshalJSON() ([]byte, error) { 53 | toSerialize := map[string]interface{}{} 54 | if true { 55 | toSerialize["data"] = o.Data 56 | } 57 | return json.Marshal(toSerialize) 58 | } 59 | -------------------------------------------------------------------------------- /model_uptime_test_status.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // UptimeTestStatus The returned status of an uptime check 38 | type UptimeTestStatus string 39 | 40 | const ( 41 | // UptimeTestStatusDown an uptime check with a down status. 42 | UptimeTestStatusDown UptimeTestStatus = "down" 43 | // UptimeTestStatusUp an uptime check with an up status. 44 | UptimeTestStatusUp UptimeTestStatus = "up" 45 | ) 46 | 47 | // Unmarshal JSON data into any of the pointers in the type. 48 | func (v *UptimeTestStatus) UnmarshalJSON(src []byte) error { 49 | var value string 50 | if err := json.Unmarshal(src, &value); err != nil { 51 | return err 52 | } 53 | 54 | ev := UptimeTestStatus(value) 55 | if !ev.Valid() { 56 | return fmt.Errorf("%+v is not a valid UptimeTestStatus", value) 57 | } 58 | 59 | *v = ev 60 | return nil 61 | } 62 | 63 | // Valid determines if the value is valid. 64 | func (v UptimeTestStatus) Valid() bool { 65 | return v == UptimeTestStatusDown || v == UptimeTestStatusUp 66 | } 67 | 68 | // UptimeTestStatusValues returns the values of UptimeTestStatus. 69 | func UptimeTestStatusValues() []string { 70 | return []string{ 71 | "down", 72 | "up", 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /model_uptime_test_type.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | "fmt" 35 | ) 36 | 37 | // UptimeTestType Uptime check type 38 | type UptimeTestType string 39 | 40 | const ( 41 | // UptimeTestTypeDNS a DNS uptime check. 42 | UptimeTestTypeDNS UptimeTestType = "DNS" 43 | // UptimeTestTypeHEAD an HTTP uptime check (HEAD verb). 44 | UptimeTestTypeHEAD UptimeTestType = "HEAD" 45 | // UptimeTestTypeHTTP an HTTP uptime check (GET or POST verbs). 46 | UptimeTestTypeHTTP UptimeTestType = "HTTP" 47 | // UptimeTestTypePING an PING uptime check. 48 | UptimeTestTypePING UptimeTestType = "PING" 49 | // UptimeTestTypeSMTP an SMTP uptime check. 50 | UptimeTestTypeSMTP UptimeTestType = "SMTP" 51 | // UptimeTestTypeSSH an SSH uptime check. 52 | UptimeTestTypeSSH UptimeTestType = "SSH" 53 | // UptimeTestTypeTCP a TCP uptime check. 54 | UptimeTestTypeTCP UptimeTestType = "TCP" 55 | ) 56 | 57 | // Unmarshal JSON data into any of the pointers in the type. 58 | func (v *UptimeTestType) UnmarshalJSON(src []byte) error { 59 | var value string 60 | if err := json.Unmarshal(src, &value); err != nil { 61 | return err 62 | } 63 | 64 | ev := UptimeTestType(value) 65 | if !ev.Valid() { 66 | return fmt.Errorf("%+v is not a valid UptimeTestType", value) 67 | } 68 | 69 | *v = ev 70 | return nil 71 | } 72 | 73 | // Valid determines if the value is valid. 74 | func (v UptimeTestType) Valid() bool { 75 | return v == UptimeTestTypeDNS || v == UptimeTestTypeHEAD || v == UptimeTestTypeHTTP || v == UptimeTestTypePING || v == UptimeTestTypeSMTP || v == UptimeTestTypeSSH || v == UptimeTestTypeTCP 76 | } 77 | 78 | // UptimeTestTypeValues returns the values of UptimeTestType. 79 | func UptimeTestTypeValues() []string { 80 | return []string{ 81 | "DNS", 82 | "HEAD", 83 | "HTTP", 84 | "PING", 85 | "SMTP", 86 | "SSH", 87 | "TCP", 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /model_uptime_tests.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | import ( 33 | "encoding/json" 34 | ) 35 | 36 | // UptimeTests struct for UptimeTests 37 | type UptimeTests struct { 38 | // List of uptime checks 39 | Data []UptimeTestOverview `json:"data"` 40 | Metadata Pagination `json:"metadata"` 41 | } 42 | 43 | // NewUptimeTests instantiates a new UptimeTests object. 44 | // This constructor will assign default values to properties that have it 45 | // defined, and makes sure properties required by API are set, but the set of 46 | // arguments will change when the set of required properties is changed. 47 | func NewUptimeTests(data []UptimeTestOverview, metadata Pagination) *UptimeTests { 48 | return &UptimeTests{ 49 | Data: data, 50 | Metadata: metadata, 51 | } 52 | } 53 | 54 | // MarshalJSON serialises data in the struct to JSON. 55 | func (o UptimeTests) MarshalJSON() ([]byte, error) { 56 | toSerialize := map[string]interface{}{} 57 | if true { 58 | toSerialize["data"] = o.Data 59 | } 60 | if true { 61 | toSerialize["metadata"] = o.Metadata 62 | } 63 | return json.Marshal(toSerialize) 64 | } 65 | -------------------------------------------------------------------------------- /throttle/group.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package throttle 31 | 32 | import "context" 33 | 34 | // Group represents a slice of constraints that must all be satisfied to 35 | // succeed. 36 | type Group struct { 37 | limiters []Limiter 38 | } 39 | 40 | // NewGroup returns a new group of Limiters. 41 | func NewGroup(l ...Limiter) *Group { 42 | return &Group{limiters: l} 43 | } 44 | 45 | // Wait invoke the Wait method of all limiters concurrently. 46 | func (l *Group) Wait(ctx context.Context) error { 47 | for _, l := range l.limiters { 48 | if err := l.Wait(ctx); err != nil { 49 | return err 50 | } 51 | } 52 | return nil 53 | } 54 | -------------------------------------------------------------------------------- /throttle/throttle_test.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package throttle_test 31 | 32 | import ( 33 | "context" 34 | "errors" 35 | "net/http" 36 | "net/http/httptest" 37 | "testing" 38 | 39 | "github.com/StatusCakeDev/statuscake-go/throttle" 40 | ) 41 | 42 | // Basic handler to return a successful response. 43 | func OK(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) } 44 | 45 | func TestTransport(t *testing.T) { 46 | t.Run("returns from a request when the throttling constraints are not met", func(t *testing.T) { 47 | srv := httptest.NewServer(http.HandlerFunc(OK)) 48 | defer srv.Close() 49 | 50 | client := &http.Client{ 51 | Transport: throttle.NewWithDefaultTransport(throttle.LimiterFunc(func(ctx context.Context) error { 52 | return nil 53 | })), 54 | } 55 | 56 | _, err := client.Get(srv.URL) 57 | if err != nil { 58 | t.Errorf("expected: no error, got: %+v", err) 59 | } 60 | }) 61 | 62 | t.Run("returns an error when the throttling constaints are met", func(t *testing.T) { 63 | srv := httptest.NewServer(http.HandlerFunc(OK)) 64 | defer srv.Close() 65 | 66 | client := &http.Client{ 67 | Transport: throttle.NewWithDefaultTransport(throttle.LimiterFunc(func(ctx context.Context) error { 68 | return errors.New("something went wrong") 69 | })), 70 | } 71 | 72 | _, err := client.Get(srv.URL) 73 | if err == nil { 74 | t.Error("expected: error, got ") 75 | } 76 | }) 77 | } 78 | 79 | func TestGroup(t *testing.T) { 80 | t.Run("returns nil when there are no errors returned from any nested limiters", func(t *testing.T) { 81 | l := throttle.NewGroup( 82 | throttle.LimiterFunc(func(ctx context.Context) error { 83 | return nil 84 | }), 85 | throttle.LimiterFunc(func(ctx context.Context) error { 86 | return nil 87 | }), 88 | ) 89 | 90 | if err := l.Wait(context.Background()); err != nil { 91 | t.Errorf("expected: no error, got: %+v", err) 92 | } 93 | }) 94 | 95 | t.Run("returns an error if any of the nested limiters returns an error", func(t *testing.T) { 96 | l := throttle.NewGroup( 97 | throttle.LimiterFunc(func(ctx context.Context) error { 98 | return nil 99 | }), 100 | throttle.LimiterFunc(func(ctx context.Context) error { 101 | return errors.New("something went wrong") 102 | }), 103 | throttle.LimiterFunc(func(ctx context.Context) error { 104 | return nil 105 | }), 106 | ) 107 | 108 | if err := l.Wait(context.Background()); err == nil { 109 | t.Error("expected: error, got: ") 110 | } 111 | }) 112 | } 113 | -------------------------------------------------------------------------------- /throttle/transport.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package throttle 31 | 32 | import ( 33 | "context" 34 | "net/http" 35 | ) 36 | 37 | // Limiter describes a common interface to describe the constraint on a 38 | // request. If the constrain is satified then the request can continue. 39 | type Limiter interface { 40 | Wait(context.Context) error 41 | } 42 | 43 | // LimiterFunc is an adapter to allow the use of functions without a receiver 44 | // as limiters. If `f` is a function with the appropriate signature, 45 | // LimiterFunc(f) is a Limiter that calls `f`. 46 | type LimiterFunc func(context.Context) error 47 | 48 | // Wait calls the underlying function reprsented by the receiver of this 49 | // method. 50 | func (f LimiterFunc) Wait(ctx context.Context) error { 51 | return f(ctx) 52 | } 53 | 54 | // Transport implements http.RoundTripper and throttles requests described by 55 | // the constraints of one or more Limiter values. 56 | type Transport struct { 57 | Transport http.RoundTripper // Used to make actual requests. 58 | limiter Limiter 59 | } 60 | 61 | // New returns a RoundTripper that throttles HTTP requests. 62 | func New(transport http.RoundTripper, l ...Limiter) *Transport { 63 | return &Transport{ 64 | Transport: transport, 65 | limiter: NewGroup(l...), 66 | } 67 | } 68 | 69 | // NewWithDefaultTransport returns a RoundTripper that throttles HTTP requests. 70 | func NewWithDefaultTransport(l ...Limiter) *Transport { 71 | return New(http.DefaultTransport, l...) 72 | } 73 | 74 | // RoundTrip ensures requests are executed within the limiting constraints. 75 | func (t *Transport) RoundTrip(r *http.Request) (*http.Response, error) { 76 | if err := t.limiter.Wait(r.Context()); err != nil { 77 | return nil, err 78 | } 79 | 80 | if t.Transport == nil { 81 | t.Transport = http.DefaultTransport 82 | } 83 | 84 | return t.Transport.RoundTrip(r) 85 | } 86 | -------------------------------------------------------------------------------- /utils.go: -------------------------------------------------------------------------------- 1 | /* 2 | * StatusCake API 3 | * 4 | * Copyright (c) 2023 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to 8 | * deal in the Software without restriction, including without limitation the 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 10 | * sell copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in 14 | * all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 22 | * IN THE SOFTWARE. 23 | * 24 | * API version: 1.2.0 25 | * Contact: support@statuscake.com 26 | */ 27 | 28 | // Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. 29 | 30 | package statuscake 31 | 32 | // This file contains functions that could not be included closer to the caller 33 | // becasue they would have either been duplicated when generated, or may 34 | // otherwise have caused syntax errors when generated due to unused imports. As 35 | // such some of the functions may not be used in the generated source. 36 | 37 | import ( 38 | "fmt" 39 | "strconv" 40 | "strings" 41 | "time" 42 | "unicode/utf8" 43 | ) 44 | 45 | // PtrBool is a helper routine that returns a pointer to given boolean value. 46 | func PtrBool(v bool) *bool { return &v } 47 | 48 | // PtrInt is a helper routine that returns a pointer to given integer value. 49 | func PtrInt(v int) *int { return &v } 50 | 51 | // PtrInt32 is a helper routine that returns a pointer to given integer value. 52 | func PtrInt32(v int32) *int32 { return &v } 53 | 54 | // PtrInt64 is a helper routine that returns a pointer to given integer value. 55 | func PtrInt64(v int64) *int64 { return &v } 56 | 57 | // PtrFloat32 is a helper routine that returns a pointer to given float value. 58 | func PtrFloat32(v float32) *float32 { return &v } 59 | 60 | // PtrFloat64 is a helper routine that returns a pointer to given float value. 61 | func PtrFloat64(v float64) *float64 { return &v } 62 | 63 | // PtrString is a helper routine that returns a pointer to given string value. 64 | func PtrString(v string) *string { return &v } 65 | 66 | // PtrTime is helper routine that returns a pointer to given Time value. 67 | func PtrTime(v time.Time) *time.Time { return &v } 68 | 69 | // atoi is a convenience function to call strconv.Atoi. 70 | func atoi(in string) (int, error) { 71 | return strconv.Atoi(in) 72 | } 73 | 74 | // contains is a case insensitive match, finding needle in a haystack. 75 | func contains(haystack []string, needle string) bool { 76 | for _, a := range haystack { 77 | if strings.ToLower(a) == strings.ToLower(needle) { 78 | return true 79 | } 80 | } 81 | return false 82 | } 83 | 84 | // strlen returns the length of a string. 85 | func strlen(s string) int { 86 | return utf8.RuneCountInString(s) 87 | } 88 | 89 | // errorf is a wrapper around fmt.Errorf necessary to prevent unused import 90 | // from individual api files. 91 | func errorf(format string, v ...interface{}) error { 92 | return fmt.Errorf(format, v...) 93 | } 94 | --------------------------------------------------------------------------------